3 from Exceptions import *
5 from systeminfo import systeminfo
7 from GetAndUpdateNodeDetails import SMP_OPT
12 See if a node installation is valid. More checks should certainly be
13 done in the future, but for now, make sure that the sym links kernel-boot
14 and initrd-boot exist in /boot
16 Expect the following variables to be set:
17 SYSIMG_PATH the path where the system image will be mounted
18 (always starts with TEMP_PATH)
19 BOOT_CD_VERSION A tuple of the current bootcd version
20 ROOT_MOUNTED the node root file system is mounted
21 NODE_ID The db node_id for this machine
22 PLCONF_DIR The directory to store the configuration file in
24 Set the following variables upon successfully running:
25 ROOT_MOUNTED the node root file system is mounted
28 log.write( "\n\nStep: Validating node installation.\n" )
30 # make sure we have the variables we need
32 BOOT_CD_VERSION= vars["BOOT_CD_VERSION"]
33 if BOOT_CD_VERSION == "":
34 raise ValueError, "BOOT_CD_VERSION"
36 SYSIMG_PATH= vars["SYSIMG_PATH"]
38 raise ValueError, "SYSIMG_PATH"
40 NODE_ID= vars["NODE_ID"]
42 raise ValueError, "NODE_ID"
44 PLCONF_DIR= vars["PLCONF_DIR"]
46 raise ValueError, "PLCONF_DIR"
48 NODE_MODEL_OPTIONS= vars["NODE_MODEL_OPTIONS"]
51 raise BootManagerException, "Missing variable in vars: %s\n" % var
52 except ValueError, var:
53 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
57 if 'ROOT_MOUNTED' in vars.keys():
58 ROOT_MOUNTED= vars['ROOT_MOUNTED']
60 # mount the root system image if we haven't already.
61 # capture BootManagerExceptions during the vgscan/change and mount
62 # calls, so we can return 0 instead
64 # old cds need extra utilities to run lvm
65 if BOOT_CD_VERSION[0] == 2:
66 compatibility.setup_lvm_2x_cd( vars, log )
68 # simply creating an instance of this class and listing the system
69 # block devices will make them show up so vgscan can find the planetlab
71 systeminfo().get_block_device_list()
74 utils.sysexec( "vgscan", log )
75 utils.sysexec( "vgchange -ay planetlab", log )
76 except BootManagerException, e:
77 log.write( "BootManagerException during vgscan/vgchange: %s\n" %
81 utils.makedirs( SYSIMG_PATH )
84 utils.sysexec( "mount /dev/planetlab/root %s" % SYSIMG_PATH, log )
85 utils.sysexec( "mount /dev/planetlab/vservers %s/vservers" %
87 utils.sysexec( "mount -t proc none %s/proc" % SYSIMG_PATH, log )
88 except BootManagerException, e:
89 log.write( "BootManagerException during vgscan/vgchange: %s\n" %
94 vars['ROOT_MOUNTED']= 1
97 # get the kernel version
99 if NODE_MODEL_OPTIONS & SMP_OPT:
102 files = ("kernel-boot%s" % option, "initrd-boot%s" % option)
104 for filepath in files:
105 if not os.access("%s/boot/%s"%(SYSIMG_PATH,filepath),os.F_OK|os.R_OK):
106 log.write( "Node not properly installed:\n")
107 log.write( "\tmissing file /boot/%s\n" % filepath )
113 # write out the node id to /etc/planetlab/node_id. if this fails, return
114 # 0, indicating the node isn't a valid install.
116 node_id_file_path= "%s/%s/node_id" % (SYSIMG_PATH,PLCONF_DIR)
117 node_id_file= file( node_id_file_path, "w" )
118 node_id_file.write( str(NODE_ID) )
121 log.write( "Updated /etc/planetlab/node_id" )
123 log.write( "Unable to write out /etc/planetlab/node_id" )
126 log.write( "Everything appears to be ok\n" )