]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Support installing ceph kernels from gitbuilder on rpm machines.
authorSandon Van Ness <sandon@inktank.com>
Wed, 4 Jun 2014 01:36:40 +0000 (18:36 -0700)
committerSandon Van Ness <sandon@inktank.com>
Wed, 4 Jun 2014 01:36:40 +0000 (18:36 -0700)
Signed-off-by: Sandon Van Ness <sandon@inktank.com>
teuthology/misc.py
teuthology/run.py
teuthology/task/kernel.py

index bee5e3fcaf7c553e1aa9c1df1f3a574b51736804..0ef57bc0f006d2db0043722c49a8212004b5b1c8 100644 (file)
@@ -1100,7 +1100,7 @@ def stop_daemons_of_type(ctx, type_):
         raise exc_info[0], exc_info[1], exc_info[2]
 
 
-def get_system_type(remote, distro=False):
+def get_system_type(remote, distro=False, version=False):
     """
     Return this system type (deb or rpm) or Distro.
     """
@@ -1112,12 +1112,19 @@ def get_system_type(remote, distro=False):
     )
     system_value = r.stdout.getvalue().strip()
     log.debug("System to be installed: %s" % system_value)
+    if version:
+        v = remote.run(args=['sudo', 'lsb_release', '-rs'], stdout=StringIO())
+        version = v.stdout.getvalue().strip()
+    if distro and version:
+        return system_value.lower(), version
     if distro:
         return system_value.lower()
     if system_value in ['Ubuntu', 'Debian']:
         return "deb"
     if system_value in ['CentOS', 'Fedora', 'RedHatEnterpriseServer']:
         return "rpm"
+    if version:
+        return version
     return system_value
 
 
index 5d2dd9d5ac84bcbee3ce35005a658fdf0f01510b..84ca9c26b5803e0d9f1066d8dabf0dc1551671bd 100644 (file)
@@ -139,8 +139,7 @@ def main(ctx):
     if 'kernel' in ctx.config:
         sha1 = ctx.config['kernel'].get('sha1')
         distro = get_distro(ctx)
-        if (distro == 'ubuntu') or (sha1 == 'distro'):
-            init_tasks.append({'kernel': ctx.config['kernel']})
+        init_tasks.append({'kernel': ctx.config['kernel']})
     init_tasks.extend([
         {'internal.base': None},
         {'internal.archive': None},
index 2011eb8d22e0d39ebb163ffce81d9c15c4410761..b72eadec5ac4e098c5505321d9ffa672848ec7f9 100644 (file)
@@ -190,6 +190,9 @@ def install_firmware(ctx, config):
             log.info('Skipping firmware on distro kernel');
             return
         (role_remote,) = ctx.cluster.only(role).remotes.keys()
+        machine_type = teuthology.get_system_type(role_remote)
+        if machine_type == 'rpm':
+            return
         log.info('Installing linux-firmware on {role}...'.format(role=role))
         role_remote.run(
             args=[
@@ -229,7 +232,7 @@ def install_firmware(ctx, config):
                 ],
             )
 
-def download_deb(ctx, config):
+def download_kernel(ctx, config):
     """
     Download a Debian kernel and copy the assocated linux image.
 
@@ -243,7 +246,7 @@ def download_deb(ctx, config):
        if src.find('distro') >= 0:
             log.info('Installing newest kernel distro');
             return
-
+        machine_type = teuthology.get_system_type(role_remote)
         if src.find('/') >= 0:
             # local deb
             log.info('Copying kernel deb {path} to {role}...'.format(path=src,
@@ -259,10 +262,38 @@ def download_deb(ctx, config):
                 stdin=f
                 )
             procs[role_remote.name] = proc
-
         else:
             log.info('Downloading kernel {sha1} on {role}...'.format(sha1=src,
                                                                      role=role))
+            if machine_type == 'rpm':
+                dist, ver = teuthology.get_system_type(role_remote, distro=True, version=True)
+                if '.' in ver:
+                    ver = ver.split('.')[0]
+                ldist = '{dist}{ver}'.format(dist=dist, ver=ver)
+                _, rpm_url = teuthology.get_ceph_binary_url(
+                    package='kernel',
+                    sha1=src,
+                    format='rpm',
+                    flavor='basic',
+                    arch='x86_64',
+                    dist=ldist,
+                    )
+
+                kernel_url = urlparse.urljoin(rpm_url, 'kernel.x86_64.rpm')
+                output, err_mess = StringIO(), StringIO()
+                role_remote.run(args=['sudo', 'yum', 'list', 'installed', 'kernel'], stdout=output, stderr=err_mess )
+                if src[0:7] in output.getvalue():
+                    output.close()
+                    err_mess.close()
+                    continue
+                output.close()
+                err_mess.close()
+                proc = role_remote.run(args=['sudo', 'yum', 'install', '-y', kernel_url], wait=False)
+                procs[role_remote.name] = proc
+
+                #download_rpm_kernel(role_remote, kernel_url, src)
+                continue
+
             larch, ldist = _find_arch_and_dist(ctx)
             _, deb_url = teuthology.get_ceph_binary_url(
                 package='kernel',
@@ -334,11 +365,14 @@ def install_and_reboot(ctx, config):
         (role_remote,) = ctx.cluster.only(role).remotes.keys()
         if src.find('distro') >= 0:
             log.info('Installing distro kernel on {role}...'.format(role=role))
-            install_distro_kernel(role_remote)
+            install_kernel(role_remote)
             continue
-
         log.info('Installing kernel {src} on {role}...'.format(src=src,
                                                                role=role))
+        system_type = teuthology.get_system_type(role_remote)
+        if system_type == 'rpm':
+            install_kernel(role_remote, src)
+            continue
         proc = role_remote.run(
             args=[
                 # install the kernel deb
@@ -558,11 +592,14 @@ def need_to_install_distro(ctx, role):
     role_remote.run(args=['uname', '-r' ], stdout=output, stderr=err_mess )
     current = output.getvalue().strip()
     if system_type == 'rpm':
-        role_remote.run(args=['sudo', 'yum', 'install', '-y', 'kernel' ], stdout=output, stderr=err_mess )
+        role_remote.run(args=['sudo', 'yum', 'install', '-y', 'kernel'], stdout=output, stderr=err_mess )
         #reset stringIO output.
         output, err_mess = StringIO(), StringIO()
         role_remote.run(args=['rpm', '-q', 'kernel', '--last' ], stdout=output, stderr=err_mess )
-        newest=output.getvalue().split()[0]
+        for kernel in output.getvalue().split():
+            if kernel.startswith('kernel'):
+                if 'ceph' not in kernel:
+                    newest = kernel
 
     if system_type == 'deb':
         distribution = teuthology.get_system_type(role_remote, distro=True)
@@ -575,19 +612,48 @@ def need_to_install_distro(ctx, role):
     log.info('Not newest distro kernel. Curent: {cur} Expected: {new}'.format(cur=current, new=newest))
     return True
 
-def install_distro_kernel(remote):
+
+def download_rpm_kernel(remote, url, sha1):
+    """
+    Install RPM kernel from URL.
+    """
+    output, err_mess = StringIO(), StringIO()
+    remote.run(args=['sudo', 'yum', 'list', 'installed', 'kernel'], stdout=output, stderr=err_mess )
+    if sha1[0:7] in output.getvalue():
+        return
+    remote.run(args=['sudo', 'yum', 'install', '-y', url], stdout=output, stderr=err_mess )
+
+def install_kernel(remote, sha1=None):
     """
     RPM: Find newest kernel on the machine and update grub to use kernel + reboot.
     DEB: Find newest kernel. Parse grub.cfg to figure out the entryname/subentry.
     then modify 01_ceph_kernel to have correct entry + updategrub + reboot.
     """
+    if sha1:
+        short = sha1[0:7]
+    else:
+        short = None
     system_type = teuthology.get_system_type(remote)
     distribution = ''
     if system_type == 'rpm':
         output, err_mess = StringIO(), StringIO()
-        remote.run(args=['rpm', '-q', 'kernel', '--last' ], stdout=output, stderr=err_mess )
-        newest=output.getvalue().split()[0].split('kernel-')[1]
-        log.info('Distro Kernel Version: {version}'.format(version=newest))
+        kern_out, kern_err = StringIO(), StringIO()
+        if short:
+            remote.run(args=['rpm', '-q', 'kernel' ], stdout=output, stderr=err_mess )
+            if short in output.getvalue():
+                for kernel in output.getvalue().split('\n'):
+                    if short in kernel:
+                        remote.run(args=['rpm', '-ql', kernel ], stdout=kern_out, stderr=kern_err )
+                        for file in kern_out.getvalue().split('\n'):
+                            if 'vmlinuz' in file:
+                                newest = file.split('/boot/vmlinuz-')[1]
+                                log.info('Kernel Version: {version}'.format(version=newest)) 
+            else:
+                raise 'Something went wrong kernel file was installed but version is missing'
+        else:
+            remote.run(args=['rpm', '-q', 'kernel', '--last' ], stdout=output, stderr=err_mess )
+            newest=output.getvalue().split()[0].split('kernel-')[1]
+            log.info('Distro Kernel Version: {version}'.format(version=newest))
         update_grub_rpm(remote, newest)
         remote.run( args=['sudo', 'shutdown', '-r', 'now'], wait=False )
         output.close()
@@ -891,7 +957,7 @@ def task(ctx, config):
 
     if need_install:
         install_firmware(ctx, need_install)
-        download_deb(ctx, need_install)
+        download_kernel(ctx, need_install)
         install_and_reboot(ctx, need_install)
         wait_for_reboot(ctx, need_version, timeout)