X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=source%2Fsteps%2FValidateNodeInstall.py;h=30cb0afb8077d3361975f8a112caa31131794d04;hb=6582d10277c2041a840c54612c6255f9eaac5e4f;hp=d5de397a429f045eb6a986972402b741f853e5ae;hpb=2d2b15d5cbaafd9652b55b641d571c3e286f30f5;p=bootmanager.git diff --git a/source/steps/ValidateNodeInstall.py b/source/steps/ValidateNodeInstall.py index d5de397..30cb0af 100644 --- a/source/steps/ValidateNodeInstall.py +++ b/source/steps/ValidateNodeInstall.py @@ -1,10 +1,18 @@ +#!/usr/bin/python2 -u + +# Copyright (c) 2003 Intel Corporation +# All rights reserved. +# +# Copyright (c) 2004-2006 The Trustees of Princeton University +# All rights reserved. + import os from Exceptions import * import utils -from systeminfo import systeminfo +import systeminfo import compatibility -from GetAndUpdateNodeDetails import SMP_OPT +import ModelOptions def Run( vars, log ): @@ -47,6 +55,10 @@ def Run( vars, log ): NODE_MODEL_OPTIONS= vars["NODE_MODEL_OPTIONS"] + PARTITIONS= vars["PARTITIONS"] + if PARTITIONS == None: + raise ValueError, "PARTITIONS" + except KeyError, var: raise BootManagerException, "Missing variable in vars: %s\n" % var except ValueError, var: @@ -68,7 +80,7 @@ def Run( vars, log ): # 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() + systeminfo.get_block_device_list(vars, log) try: utils.sysexec( "vgscan", log ) @@ -81,9 +93,9 @@ def Run( vars, log ): utils.makedirs( SYSIMG_PATH ) try: - utils.sysexec( "mount /dev/planetlab/root %s" % SYSIMG_PATH, log ) - utils.sysexec( "mount /dev/planetlab/vservers %s/vservers" % - SYSIMG_PATH, log ) + utils.sysexec("mount %s %s" % (PARTITIONS["root"],SYSIMG_PATH),log) + utils.sysexec("mount %s %s/vservers" % \ + (PARTITIONS["vservers"], SYSIMG_PATH), log) utils.sysexec( "mount -t proc none %s/proc" % SYSIMG_PATH, log ) except BootManagerException, e: log.write( "BootManagerException during vgscan/vgchange: %s\n" % @@ -94,22 +106,29 @@ def Run( vars, log ): vars['ROOT_MOUNTED']= 1 - # get the kernel version - option = '' - if NODE_MODEL_OPTIONS & SMP_OPT: - option = 'smp' - - files = ("kernel-boot%s" % option, "initrd-boot%s" % option) - valid= 1 - for filepath in files: - if not os.access("%s/boot/%s"%(SYSIMG_PATH,filepath),os.F_OK|os.R_OK): - log.write( "Node not properly installed:\n") - log.write( "\tmissing file /boot/%s\n" % filepath ) - valid= 0 - - if not valid: + # check if the base kernel is installed + try: + os.stat("%s/boot/kernel-boot" % SYSIMG_PATH) + os.stat("%s/boot/initrd-boot" % SYSIMG_PATH) + except OSError, e: + log.write( "FATAL: Couldn't locate base kernel.\n") return 0 + # check if the model specified kernel is installed + 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") + # write out the node id to /etc/planetlab/node_id. if this fails, return # 0, indicating the node isn't a valid install. try: @@ -118,9 +137,9 @@ def Run( vars, log ): node_id_file.write( str(NODE_ID) ) node_id_file.close() node_id_file= None - log.write( "Updated /etc/planetlab/node_id" ) + log.write( "Updated /etc/planetlab/node_id\n" ) except IOError, e: - log.write( "Unable to write out /etc/planetlab/node_id" ) + log.write( "Unable to write out /etc/planetlab/node_id\n" ) return 0 log.write( "Everything appears to be ok\n" )