From: Sandon Van Ness Date: Thu, 31 Oct 2013 00:06:14 +0000 (-0700) Subject: Initial ugly commit. X-Git-Tag: 1.1.0~1755^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=84d8b49f6343c08c5324f92f86d1eee742712545;p=teuthology.git Initial ugly commit. Definitely some enhancements can be done. I think I have everything needed but I have not been able to test this yet. If this needs to get done before I am back feel free to work on it. Completely untested and probably a few mistakes somewhere... Signed-off-by: Sandon Van Ness --- diff --git a/teuthology/task/kernel.py b/teuthology/task/kernel.py index ce73f4d54a..729eaaf270 100644 --- a/teuthology/task/kernel.py +++ b/teuthology/task/kernel.py @@ -141,8 +141,12 @@ def install_firmware(ctx, config): uri = teuth_config.linux_firmware_git_url or linux_firmware_git_upstream fw_dir = '/lib/firmware/updates' - for role in config.iterkeys(): + for role, src in config.iterkeys(): (role_remote,) = ctx.cluster.only(role).remotes.keys() + if src.find('distro') >= 0: + log.info('Skipping firmware on distro kernel'); + return + log.info('Installing linux-firmware on {role}...'.format(role=role)) role_remote.run( args=[ @@ -184,8 +188,14 @@ def install_firmware(ctx, config): def download_deb(ctx, config): procs = {} + #Don't need to download distro kernels for role, src in config.iteritems(): (role_remote,) = ctx.cluster.only(role).remotes.keys() + if src.find('distro') >= 0: + log.info('Installing newest kernel distro'); + return + + if src.find('/') >= 0: # local deb log.info('Copying kernel deb {path} to {role}...'.format(path=src, @@ -254,9 +264,14 @@ def install_and_reboot(ctx, config): procs = {} kernel_title = '' for role, src in config.iteritems(): + (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(remote) + return + log.info('Installing kernel {src} on {role}...'.format(src=src, role=role)) - (role_remote,) = ctx.cluster.only(role).remotes.keys() proc = role_remote.run( args=[ # install the kernel deb @@ -436,6 +451,180 @@ def wait_for_reboot(ctx, need_install, timeout): time.sleep(1) +def need_to_install_distro(ctx, role): + system_type = teuthology.get_system_type(role.remote) + ctx.cluster.only(role).run(args=['uname', '-r' ], stdout=output, stderr=err_mess ) + current = output.strip() + + if system_type == 'rpm': + try: + ctx.cluster.only(role).run(args=['sudo', 'yum', 'list', 'available', 'kernel' ], stdout=output, stderr=err_mess ) + ctx.cluster.only(role).run(args=['sudo', 'yum', 'install', '-y', 'kernel' ], stdout=output, stderr=err_mess ) + return True + except: + ctx.cluster.only(role).run(args=['rpm', '-q', 'kernel', '--last' ], stdout=output, stderr=err_mess ) + newest=output.split()[0] + + if system_type == 'deb': + ctx.cluster.only(role).run(args=['lsb_release', '-is'], stdout=system, stderr=err_mess ) + distribution = system.lower() + newest = get_version_from_pkg(ctx.cluster.only(role), distribution) + + if current in newest: + return False + return True + +def install_distro_kernel(remote): + system_type = teuthology.get_system_type(remote) + if system_type == 'rpm': + ctx.cluster.only(role).run(args=['rpm', '-q', 'kernel', '--last' ], stdout=output, stderr=err_mess ) + newest=output.split()[0].split('kernel-')[1] + update_grub_rpm(remote, newest) + remote.run( args=['sudo', 'shutdown', '-r'], wait=False ) + return + + if system_type == 'deb': + remote.run(args=['lsb_release', '-is'], stdout=system, stderr=err_mess ) + distribution = system.lower() + newversion = get_version_from_pkg(remote, type) + if 'ubuntu' in distribution: + grub2conf = teuthology.get_file(remote, '/boot/grub/grub.cfg', true) + submenu = '' + for line in grub2conf: + if 'submenu' in line: + submenu = line.split('"')[1] + if 'menuentry' in line: + if newversion in line and 'recovery' not in line: + menuentry = line.split('\'')[1] + break + if submenu: + grubvalue = submenu + '>' + menuentry + else: + grubvalue = menuentry + + grubfile = 'cat <