Skip to content

Commit

Permalink
fab environment for Rhosp8 installation
Browse files Browse the repository at this point in the history
Partial-Bug: 1583456

support new kernel version in update_kernel_all for centos/rhel
Partial-Bug: 1566608
(cherry picked from commit b26fa33)

update kernel-headers version from 3.10.0-229 to 3.10.0-327.10.1

Change-Id: Ic844f193fea2f594bae73faee23d7e834f2d209b
  • Loading branch information
npchandran committed May 23, 2016
1 parent 7f9fd71 commit 36db2db
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 25 deletions.
9 changes: 8 additions & 1 deletion fabfile/contraillabs/rdo.py
Expand Up @@ -35,12 +35,19 @@ def install_rhosp6_repo():
put('fabfile/contraillabs/repo/rhosp6_local.repo', '/etc/yum.repos.d/rhosp6_local.repo', use_sudo=True)
sudo('yum clean all')

@task
@roles('openstack')
def install_rhosp8_repo():
""" copy local rhosp8 repo locations """
put('fabfile/contraillabs/repo/rhosp8_local.repo', '/etc/yum.repos.d/rhosp8_local.repo', use_sudo=True)
sudo('yum clean all && yum clean expire-cache')

@task
@roles('all')
def update_all_node(reboot='True'):
with settings(warn_only=True):
sudo("yum -y install yum-utils")
sudo("yum -y install kernel-headers-3.10.0-229.el7")
sudo("yum -y install kernel-headers-3.10.0-327.10.1.el7")
sudo("yum update -y --exclude=kernel*")
print "[%s]: Disable NeworkManager and reboot" % env.host_string
sudo("systemctl stop NetworkManager")
Expand Down
27 changes: 27 additions & 0 deletions fabfile/contraillabs/repo/rhosp8_local.repo
@@ -0,0 +1,27 @@
[RH7-RHOS-8.0]
name=RH7-RHOS-8.0
baseurl=http://10.84.5.120/cs-shared/builder/cache/redhatenterpriselinuxserver70/rhosp8_local_repo/RH7-RHOS-8.0/
enabled=1
priority=1
gpgcheck=0

[rhel-7-server-extras-rpms]
name=rhel-7-server-extras-rpms
baseurl=http://10.84.5.120/cs-shared/builder/cache/redhatenterpriselinuxserver70/rhosp8_local_repo/rhel-7-server-extras-rpms/
enabled=1
priority=1
gpgcheck=0

[rhel-7-server-optional-rpms]
name=rhel-7-server-optional-rpms
baseurl=http://10.84.5.120/cs-shared/builder/cache/redhatenterpriselinuxserver70/rhosp8_local_repo/rhel-7-server-optional-rpms/
enabled=1
priority=1
gpgcheck=0

[rhel-7-server-rpms]
name=rhel-7-server-rpms
baseurl=http://10.84.5.120/cs-shared/builder/cache/redhatenterpriselinuxserver70/rhosp8_local_repo/rhel-7-server-rpms/
enabled=1
priority=1
gpgcheck=0
44 changes: 32 additions & 12 deletions fabfile/tasks/kernel.py
Expand Up @@ -7,12 +7,18 @@
@task
def set_grub_default_node(*args, **kwargs):
'''Set default kernel version to bootup for given list of nodes'''
value = kwargs.get('value', 'Advanced options for Ubuntu>Ubuntu, with Linux 3.13.0-85-generic')
value = kwargs.get('value')
for host_string in args:
with settings(host_string=host_string):
sudo("sed -i \'s/^GRUB_DEFAULT=.*/GRUB_DEFAULT=\"%s\"/g\' /etc/default/grub" % value)
sudo('update-grub')
sudo("grep '^GRUB_DEFAULT=\"%s\"' /etc/default/grub" % value)
dist, version, extra = get_linux_distro()
if 'ubuntu' in dist.lower():
sudo("sed -i \'s/^GRUB_DEFAULT=.*/GRUB_DEFAULT=\"%s\"/g\' /etc/default/grub" % value)
sudo('update-grub')
sudo("grep '^GRUB_DEFAULT=\"%s\"' /etc/default/grub" % value)
elif 'red hat' in dist.lower() or 'centos linux' in dist.lower():
sudo("grub2-set-default \'%s\'" % value)
sudo('grub2-mkconfig -o /boot/grub2/grub.cfg')
sudo("grub2-editenv list | grep \'%s\'" % value)
print '[%s]: Updated Default Grub to (%s)' % (host_string, value)

@task
Expand All @@ -37,6 +43,10 @@ def upgrade_kernel_all(*tgzs, **kwargs):
elif version == '14.04':
(package, os_type) = ('linux-image-3.13.0-85-generic', 'ubuntu')
default_grub='Advanced options for Ubuntu>Ubuntu, with Linux 3.13.0-85-generic'
elif 'centos linux' in dist.lower() and version.startswith('7'):
(package, os_type) = ('kernel-3.10.0-327.10.1.el7.x86_64', 'centoslinux')
elif 'red hat' in dist.lower() and version.startswith('7'):
(package, os_type) = ('kernel-3.10.0-327.10.1.el7.x86_64', 'redhat')
else:
raise RuntimeError("Unsupported platfrom (%s, %s, %s) for"
" kernel upgrade." % (dist, version, extra))
Expand Down Expand Up @@ -66,8 +76,8 @@ def upgrade_kernel_without_openstack(*tgzs, **kwargs):
with settings(host_string=env.roledefs['cfgm'][0], warn_only=True):
dist, version, extra = get_linux_distro()

if 'red hat' in dist.lower() and version == '7.0':
(package, os_type) = ('kernel-3.10.0-229.el7.x86_64', 'redhat')
if ('red hat' in dist.lower() or 'centos linux' in dist.lower()) and version.startswith('7'):
(package, os_type) = ('kernel-3.10.0-327.10.1.el7.x86_64', 'redhat')
else:
raise RuntimeError("Unsupported platfrom (%s, %s, %s) for"
" kernel upgrade." % (dist, version, extra))
Expand Down Expand Up @@ -121,12 +131,22 @@ def upgrade_kernel_node(*args):
"linux-image-extra-3.13.0-85-generic"])
default_grub='Advanced options for Ubuntu>Ubuntu, with Linux 3.13.0-85-generic'
execute('set_grub_default_node', host_string, value=default_grub)
elif 'red hat' in dist.lower() and version == '7.0':
print "Upgrading kernel to version 3.10.0-229"
pkg_install(["kernel-3.10.0-229.el7.x86_64",
"kernel-tools-3.10.0-229.el7.x86_64",
"kernel-tools-libs-3.10.0-229.el7.x86_64",
"kernel-headers-3.10.0-229.el7.x86_64"], disablerepo=False)
elif 'red hat' in dist.lower() and version.startswith('7'):
print "Upgrading RHEL kernel to version 3.10.0-327.10.1"
pkg_install(["kernel-3.10.0-327.10.1.el7.x86_64",
"kernel-tools-3.10.0-327.10.1.el7.x86_64",
"kernel-tools-libs-3.10.0-327.10.1.el7.x86_64",
"kernel-headers-3.10.0-327.10.1.el7.x86_64"], disablerepo=False)
default_grub='Red Hat Enterprise Linux Server (3.10.0-327.10.1.el7.x86_64) 7.2 (Maipo)'
execute('set_grub_default_node', host_string, value=default_grub)
elif 'centos linux' in dist.lower() and version.startswith('7'):
print "Upgrading Centos kernel to version 3.10.0-327.10.1"
pkg_install(["kernel-3.10.0-327.10.1.el7.x86_64",
"kernel-tools-3.10.0-327.10.1.el7.x86_64",
"kernel-tools-libs-3.10.0-327.10.1.el7.x86_64",
"kernel-headers-3.10.0-327.10.1.el7.x86_64"], disablerepo=False)
default_grub='CentOS Linux (3.10.0-327.10.1.el7.x86_64) 7 (Core)'
execute('set_grub_default_node', host_string, value=default_grub)

@task
@EXECUTE_TASK
Expand Down
25 changes: 13 additions & 12 deletions fabfile/utils/cluster.py
Expand Up @@ -197,20 +197,21 @@ def get_nodes_to_upgrade_pkg(package, os_type, *args, **kwargs):
version = kwargs.get('version', None)
for host_string in args:
with settings(host_string=host_string, warn_only=True):
act_os_type = detect_ostype()
if act_os_type == os_type:
if os_type in ['ubuntu']:
installed = sudo("dpkg -l | grep %s" % package)
if not installed:
nodes.append(host_string)
elif (version and
version != '%s-%s' %
(get_release(package), get_build(package))):
nodes.append(host_string)
else:
print 'Required package %s installed. Skipping!' % package
elif os_type in ['centos', 'redhat', 'centoslinux']:
installed = sudo("rpm -qa | grep %s" % package)
else:
raise RuntimeError('Unsupported OS type!')

if not installed:
nodes.append(host_string)
elif (version and
version != '%s-%s' %
(get_release(package), get_build(package))):
nodes.append(host_string)
else:
raise RuntimeError('Actual OS Type (%s) != Expected OS Type (%s)'
'Aborting!' % (act_os_type, os_type))
print 'Required package %s installed. Skipping!' % package
return nodes

def get_package_installed_info(package, os_type, *nodes):
Expand Down

0 comments on commit 36db2db

Please sign in to comment.