X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=source%2Fsteps%2FInstallWriteConfig.py;h=a0dfac526259943dfa74adc46ad6999576b70873;hb=f79098df1d4acd219916038b8c9fcf2ec8f3bf01;hp=9349f5446b4967dc4573930342e640fbf76a4ec5;hpb=644716f1b688e140b5be6ce44342197fa3f69136;p=bootmanager.git diff --git a/source/steps/InstallWriteConfig.py b/source/steps/InstallWriteConfig.py index 9349f54..a0dfac5 100644 --- a/source/steps/InstallWriteConfig.py +++ b/source/steps/InstallWriteConfig.py @@ -46,7 +46,7 @@ from Exceptions import * import utils from systeminfo import systeminfo import BootAPI - +import ModelOptions def Run( vars, log ): @@ -220,20 +220,19 @@ def Run( vars, log ): log.write( "Making initrd\n" ) # trick mkinitrd in case the current environment does not have device mapper - fake_root_lvm= 0 + fake_root_lvm= False if not os.path.exists( "%s/%s" % (SYSIMG_PATH,PARTITIONS["mapper-root"]) ): - fake_root_lvm= 1 + fake_root_lvm= True utils.makedirs( "%s/dev/mapper" % SYSIMG_PATH ) rootdev= file( "%s/%s" % (SYSIMG_PATH,PARTITIONS["mapper-root"]), "w" ) rootdev.close() - initrd= os.readlink( "%s/boot/initrd-boot" % SYSIMG_PATH ) - kernel_version= initrd.replace("initrd-", "").replace(".img", "") + initrd, kernel_version= getKernelVersion(vars,log) utils.removefile( "%s/boot/%s" % (SYSIMG_PATH, initrd) ) utils.sysexec( "chroot %s mkinitrd /boot/initrd-%s.img %s" % \ (SYSIMG_PATH, kernel_version, kernel_version), log ) - if fake_root_lvm == 1: + if fake_root_lvm == True: utils.removefile( "%s/%s" % (SYSIMG_PATH,PARTITIONS["mapper-root"]) ) log.write( "Writing node install version\n" ) @@ -410,11 +409,7 @@ def write_modprobeconf_file( vars, log, filename = "/etc/modprobe.conf"): except ValueError, var: raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var - - # get the kernel version - initrd= os.readlink( "%s/boot/initrd-boot" % SYSIMG_PATH ) - kernel_version= initrd.replace("initrd-", "").replace(".img", "") - + initrd, kernel_version= getKernelVersion(vars,log) sysinfo= systeminfo() sysmods= sysinfo.get_system_modules(SYSIMG_PATH, kernel_version) if sysmods is None: @@ -447,3 +442,33 @@ def write_modprobeconf_file( vars, log, filename = "/etc/modprobe.conf"): return (eth_count,scsi_count) +def getKernelVersion( vars, log): + # make sure we have the variables we need + try: + SYSIMG_PATH= vars["SYSIMG_PATH"] + if SYSIMG_PATH == "": + raise ValueError, "SYSIMG_PATH" + + NODE_MODEL_OPTIONS=vars["NODE_MODEL_OPTIONS"] + except KeyError, var: + raise BootManagerException, "Missing variable in vars: %s\n" % var + except ValueError, var: + raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var + + option = '' + if NODE_MODEL_OPTIONS & ModelOptions.SMP: + option = 'smp' + try: + os.stat("%s/boot/kernel-boot%s" % (SYSIMG_PATH,option)) + os.stat("%s/boot/initrd-boot%s" % (SYSIMG_PATH,option)) + except OSError, e: + # smp kernel is not there; remove option from modeloptions + # such that the rest of the code base thinks we are just + # using the base kernel. + NODE_MODEL_OPTIONS = NODE_MODEL_OPTIONS & ~ModelOptions.SMP + vars["NODE_MODEL_OPTIONS"] = NODE_MODEL_OPTIONS + log.write( "WARNING: Couldn't locate smp kernel.\n") + option = '' + initrd= os.readlink( "%s/boot/initrd-boot%s" % (SYSIMG_PATH,option) ) + kernel_version= initrd.replace("initrd-", "").replace(".img", "") + return (initrd, kernel_version)