From 52aec32a7da07ca6e9a22ecedde78dafb4b74dfc Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Tue, 9 Apr 2013 15:53:49 -0700 Subject: [PATCH] kernel.py: put submenu name in 01_ceph_kernel if necessary We had been writing 01_ceph_kernel with the kernel title, and relying on the fact that grub.cfg would never have submenus in it (implemented by a hack to /etc/grub.d/10_linux which neutered its submenu creation). However, that hack was modifying a package file, and got in the way of later apt commands. Rather than doing it that way, this divines the title of the submenu and sets the default variable to "submenu>kernel", which works to select the desired kernel. It depends on there being only one level of submenu, and on the format of the menuentry and submenu commands, dictated by grub2. None of this is likely to work at all outside Ubuntu. Fixes: #4496 Signed-off-by: Dan Mick Reviewed-by: Dan Mick --- teuthology/task/kernel.py | 66 ++++++++++++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 8 deletions(-) diff --git a/teuthology/task/kernel.py b/teuthology/task/kernel.py index a5b913381f..9cb0d9e34c 100644 --- a/teuthology/task/kernel.py +++ b/teuthology/task/kernel.py @@ -2,6 +2,7 @@ from cStringIO import StringIO import logging import re +import shlex from teuthology import misc as teuthology from ..orchestra import run @@ -219,12 +220,19 @@ def install_and_reboot(ctx, config): (role_remote,) = ctx.cluster.only(role).remotes.keys() proc = role_remote.run( args=[ + # install the kernel deb 'sudo', 'dpkg', '-i', '/tmp/linux-image.deb', - run.Raw('&&'), - # and now extract the actual boot image name from the deb + ], + ) + + # collect kernel image name from the .deb + cmdout = StringIO() + proc = role_remote.run( + args=[ + # extract the actual boot image name from the deb 'dpkg-deb', '--fsys-tarfile', '/tmp/linux-image.deb', @@ -237,12 +245,53 @@ def install_and_reboot(ctx, config): '--', './boot/vmlinuz-*', run.Raw('|'), - # we can only rely on mawk being installed, so just call it explicitly - 'mawk', - # and use the image name to construct the content of - # the grub menu entry, so we can default to it; - # hardcoded to assume Ubuntu, English, etc. - r'{sub("^\\./boot/vmlinuz-", "", $6); print "cat <= 2: + command, title = fields[:2] + if command == 'submenu': + submenu_title = title + '>' + if command == 'menuentry': + if title.endswith(kernel_title): + default_title = title + break + cmdout.close() + log.info('submenu_title:{}'.format(submenu_title)) + log.info('default_title:{}'.format(default_title)) + + proc = role_remote.run( + args=[ + # use the title(s) to construct the content of + # the grub menu entry, so we can default to it. + '/bin/echo', + '-e', + r'cat <