X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=source%2Fsteps%2FChainBootNode.py;h=9c1e06c149e085fcc7e1cca36b07f3f3f501b202;hb=3a2a07818ad1b9a374a7ec78e8c4573a043dc338;hp=78337abc961dde6228394b28e0dad3748fcc78e3;hpb=d531cfaf5185ca1e74a5f15c2e3b1254968200de;p=bootmanager.git diff --git a/source/steps/ChainBootNode.py b/source/steps/ChainBootNode.py index 78337ab..9c1e06c 100644 --- a/source/steps/ChainBootNode.py +++ b/source/steps/ChainBootNode.py @@ -29,7 +29,7 @@ def Run(vars, log): This step assumes the disks are mounted on SYSIMG_PATH. If successful, this function will not return. If it returns, no chain booting has occurred. - + Expect the following variables: SYSIMG_PATH the path where the system image will be mounted (always starts with TEMP_PATH) @@ -37,7 +37,7 @@ def Run(vars, log): NODE_SESSION the unique session val set when we requested the current boot state PLCONF_DIR The directory to store PL configuration files in - + Sets the following variables: ROOT_MOUNTED the node root file system is mounted """ @@ -71,15 +71,15 @@ def Run(vars, log): ROOT_MOUNTED = 0 if vars.has_key('ROOT_MOUNTED'): ROOT_MOUNTED = vars['ROOT_MOUNTED'] - + if ROOT_MOUNTED == 0: log.write("Mounting node partitions\n") # simply creating an instance of this class and listing the system # block devices will make them show up so vgscan can find the planetlab # volume group - systeminfo.get_block_device_list(vars, log) - + systeminfo.get_block_devices_dict(vars, log) + utils.sysexec("vgscan", log) utils.sysexec("vgchange -ay planetlab", log) @@ -94,7 +94,8 @@ def Run(vars, log): ROOT_MOUNTED = 1 vars['ROOT_MOUNTED'] = 1 - + + utils.display_disks_status(PARTITIONS, "In ChainBootNode", log) # write out the session value /etc/planetlab/session try: @@ -113,19 +114,23 @@ def Run(vars, log): if (vars['ONE_PARTITION'] != '1'): try: - cmd = "/usr/bin/env python /usr/share/NodeManager/conf_files.py --noscripts" + # used to call /usr/bin/env python here, but as nodemanager + # now exists both in python2 and python3, we use a shebang + # in conf_files instead + cmd = "/usr/share/NodeManager/conf_files.py --noscripts" utils.sysexec_chroot(SYSIMG_PATH, cmd, log) except IOError as e: log.write("conf_files failed with \n {}".format(e)) # update node packages - log.write("Running node update.\n") - if os.path.exists(SYSIMG_PATH + "/usr/bin/NodeUpdate.py"): - cmd = "/usr/bin/NodeUpdate.py start noreboot" - else: + #log.write("Running node update.\n") + #if os.path.exists(SYSIMG_PATH + "/usr/bin/NodeUpdate.py"): + # cmd = "/usr/bin/NodeUpdate.py start noreboot" + #else: # for backwards compatibility - cmd = "/usr/local/planetlab/bin/NodeUpdate.py start noreboot" - utils.sysexec_chroot(SYSIMG_PATH, cmd, log) + # cmd = "/usr/local/planetlab/bin/NodeUpdate.py start noreboot" + #utils.sysexec_chroot(SYSIMG_PATH, cmd, log) + log.write("NodeUpdate skipped\n") # Re-generate initrd right before kexec call # this is not required anymore on recent depls. @@ -167,34 +172,44 @@ def Run(vars, log): major_version = int(kversion[0]) # Check if the string looks like a kernel version except: # Try a different method for non-rpm-based distributions - kversion = os.popen("ls -lrt {}/lib/modules | tail -1 | awk '{print $9;}'"\ + kversion = os.popen("ls -lrt {}/lib/modules | tail -1 | awk '{{print $9;}}'"\ .format(SYSIMG_PATH)).read().rstrip() - utils.sysexec("cp {}/boot/vmlinuz-{} /tmp/kernel".format(SYSIMG_PATH, kversion), log) - candidates = [] + # kernel and initrd come in various locations depending on the distro + + kernel_candidates = [] + kernel_candidates.append("/boot/vmlinuz-{}*".format(kversion)) + # on f23 starting dec. 2015 - what a twisted naming scheme + kernel_candidates.append("/boot/*/{}*/linux".format(kversion)) + + initrd_candidates = [] # f16/18: expect initramfs image here - candidates.append ("/boot/initramfs-{}.img".format(kversion)) + initrd_candidates.append ("/boot/initramfs-{}.img".format(kversion)) # f20: uses a uid of some kind, e.g. /boot/543f88c129de443baaa65800cf3927ce//initrd - candidates.append ("/boot/*/{}/initrd".format(kversion)) + initrd_candidates.append ("/boot/*/{}/initrd".format(kversion)) # Ubuntu: - candidates.append ("/boot/initrd.img-{}".format(kversion)) - def find_file_in_sysimg (candidates): + initrd_candidates.append ("/boot/initrd.img-{}".format(kversion)) + + def install_from_sysimg_to_tmp (candidates, name): import glob + found = None for pattern in candidates: matches = glob.glob(SYSIMG_PATH+pattern) - log.write("locating initrd: found {} matches in {}\n".format(len(matches), pattern)) + log.write("locating {}: found {} matches in {}\n".format(name, len(matches), pattern)) if matches: - return matches[0] - initrd = find_file_in_sysimg(candidates) - if initrd: - utils.sysexec("cp {} /tmp/initrd".format(initrd), log) - else: - raise Exception("Unable to locate initrd - bailing out") + found = matches[0] + break + if not found: + raise Exception("Unable to locate {} for kexec'ing".format(name)) + utils.sysexec("cp {} /tmp/{}".format(found, name)) + + install_from_sysimg_to_tmp(kernel_candidates, 'kernel') + install_from_sysimg_to_tmp(initrd_candidates, 'initrd') BootAPI.save(vars) log.write("Unmounting disks.\n") - + if (vars['ONE_PARTITION'] != '1'): utils.sysexec("umount {}/vservers".format(SYSIMG_PATH), log) utils.sysexec("umount {}/proc".format(SYSIMG_PATH), log) @@ -223,23 +238,24 @@ def Run(vars, log): # to get kexec to work correctly. Even on 3.x cds (2.6 kernel), # there are a few buggy drivers that don't disable their hardware # correctly unless they are first unloaded. - - utils.sysexec_noerr("ifconfig eth0 down", log) + + utils.sysexec_noerr("ifconfig eth0 down || /usr/libexec/nm-ifdown eth0", + log, shell=True) utils.sysexec_noerr("killall dhclient", log) - + if vars['virt'] == 'vs': utils.sysexec_noerr("umount -a -r -t ext2,ext3", log) else: utils.sysexec_noerr("umount -a -r -t ext2,ext3,btrfs", log) utils.sysexec_noerr("modprobe -r lvm-mod", log) - + # modules that should not get unloaded # unloading cpqphp causes a kernel panic blacklist = [ "floppy", "cpqphp", "i82875p_edac", "mptspi"] try: modules = file("/tmp/loadedmodules","r") - + for line in modules: module = string.strip(line) if module in blacklist : @@ -296,7 +312,7 @@ def Run(vars, log): log.write("Couldn't read /proc/modules, continuing.\n") - kargs = "root={} ramdisk_size=8192".format(PARTITIONS["mapper-root"]) + kargs = "root={} ramdisk_size=8192".format(PARTITIONS["root"]) if NODE_MODEL_OPTIONS & ModelOptions.SMP: kargs = kargs + " " + "acpi=off" try: @@ -309,7 +325,7 @@ def Run(vars, log): except IOError: # /kargs.txt does not exist, which is fine. Just kexec with default # kargs, which is ramdisk_size=8192 - pass + pass utils.sysexec_noerr('hwclock --systohc --utc ', log) # utils.breakpoint("Before kexec");