X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=source%2Fsteps%2FValidateNodeInstall.py;h=d5de397a429f045eb6a986972402b741f853e5ae;hb=2d2b15d5cbaafd9652b55b641d571c3e286f30f5;hp=d7bd721739cec864225c97d6411059611bfad161;hpb=2151b25b18627ee01c6290d8440f8bcf662c286b;p=bootmanager.git diff --git a/source/steps/ValidateNodeInstall.py b/source/steps/ValidateNodeInstall.py index d7bd721..d5de397 100644 --- a/source/steps/ValidateNodeInstall.py +++ b/source/steps/ValidateNodeInstall.py @@ -4,6 +4,7 @@ from Exceptions import * import utils from systeminfo import systeminfo import compatibility +from GetAndUpdateNodeDetails import SMP_OPT def Run( vars, log ): @@ -17,6 +18,8 @@ def Run( vars, log ): (always starts with TEMP_PATH) BOOT_CD_VERSION A tuple of the current bootcd version ROOT_MOUNTED the node root file system is mounted + NODE_ID The db node_id for this machine + PLCONF_DIR The directory to store the configuration file in Set the following variables upon successfully running: ROOT_MOUNTED the node root file system is mounted @@ -34,6 +37,16 @@ def Run( vars, log ): if SYSIMG_PATH == "": raise ValueError, "SYSIMG_PATH" + NODE_ID= vars["NODE_ID"] + if NODE_ID == "": + raise ValueError, "NODE_ID" + + PLCONF_DIR= vars["PLCONF_DIR"] + if PLCONF_DIR == "": + raise ValueError, "PLCONF_DIR" + + NODE_MODEL_OPTIONS= vars["NODE_MODEL_OPTIONS"] + except KeyError, var: raise BootManagerException, "Missing variable in vars: %s\n" % var except ValueError, var: @@ -71,6 +84,7 @@ def Run( vars, log ): utils.sysexec( "mount /dev/planetlab/root %s" % SYSIMG_PATH, log ) utils.sysexec( "mount /dev/planetlab/vservers %s/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" % str(e) ) @@ -79,15 +93,34 @@ def Run( vars, log ): ROOT_MOUNTED= 1 vars['ROOT_MOUNTED']= 1 - valid= 0 - if os.access("%s/boot/kernel-boot" % SYSIMG_PATH, os.F_OK | os.R_OK) and \ - os.access("%s/boot/initrd-boot" % SYSIMG_PATH, os.F_OK | os.R_OK): - valid= 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: - log.write( "Node does not appear to be installed correctly:\n" ) - log.write( "missing file /boot/ initrd-boot or kernel-boot\n" ) + return 0 + + # write out the node id to /etc/planetlab/node_id. if this fails, return + # 0, indicating the node isn't a valid install. + try: + node_id_file_path= "%s/%s/node_id" % (SYSIMG_PATH,PLCONF_DIR) + node_id_file= file( node_id_file_path, "w" ) + node_id_file.write( str(NODE_ID) ) + node_id_file.close() + node_id_file= None + log.write( "Updated /etc/planetlab/node_id" ) + except IOError, e: + log.write( "Unable to write out /etc/planetlab/node_id" ) return 0 log.write( "Everything appears to be ok\n" )