3 from Exceptions import *
5 from systeminfo import systeminfo
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 # check if the base kernel is installed
99 os.stat("%s/boot/kernel-boot" % SYSIMG_PATH)
100 os.stat("%s/boot/initrd-boot" % SYSIMG_PATH)
102 log.write( "FATAL: Couldn't locate base kernel.\n")
105 # check if the model specified kernel is installed
107 if NODE_MODEL_OPTIONS & ModelOptions.SMP:
110 os.stat("%s/boot/kernel-boot%s" % (SYSIMG_PATH,option))
111 os.stat("%s/boot/initrd-boot%s" % (SYSIMG_PATH,option))
113 # smp kernel is not there; remove option from modeloptions
114 # such that the rest of the code base thinks we are just
115 # using the base kernel.
116 NODE_MODEL_OPTIONS = NODE_MODEL_OPTIONS & ~ModelOptions.SMP
117 vars["NODE_MODEL_OPTIONS"] = NODE_MODEL_OPTIONS
118 log.write( "WARNING: Couldn't locate smp kernel.\n")
120 # write out the node id to /etc/planetlab/node_id. if this fails, return
121 # 0, indicating the node isn't a valid install.
123 node_id_file_path= "%s/%s/node_id" % (SYSIMG_PATH,PLCONF_DIR)
124 node_id_file= file( node_id_file_path, "w" )
125 node_id_file.write( str(NODE_ID) )
128 log.write( "Updated /etc/planetlab/node_id\n" )
130 log.write( "Unable to write out /etc/planetlab/node_id\n" )
133 log.write( "Everything appears to be ok\n" )