3 from Exceptions import *
5 from systeminfo import systeminfo
11 See if a node installation is valid. More checks should certainly be
12 done in the future, but for now, make sure that the sym links kernel-boot
13 and initrd-boot exist in /boot
15 Expect the following variables to be set:
16 SYSIMG_PATH the path where the system image will be mounted
17 (always starts with TEMP_PATH)
18 BOOT_CD_VERSION A tuple of the current bootcd version
19 ROOT_MOUNTED the node root file system is mounted
20 NODE_ID The db node_id for this machine
21 PLCONF_DIR The directory to store the configuration file in
23 Set the following variables upon successfully running:
24 ROOT_MOUNTED the node root file system is mounted
27 log.write( "\n\nStep: Validating node installation.\n" )
29 # make sure we have the variables we need
31 BOOT_CD_VERSION= vars["BOOT_CD_VERSION"]
32 if BOOT_CD_VERSION == "":
33 raise ValueError, "BOOT_CD_VERSION"
35 SYSIMG_PATH= vars["SYSIMG_PATH"]
37 raise ValueError, "SYSIMG_PATH"
39 NODE_ID= vars["NODE_ID"]
41 raise ValueError, "NODE_ID"
43 PLCONF_DIR= vars["PLCONF_DIR"]
45 raise ValueError, "PLCONF_DIR"
48 raise BootManagerException, "Missing variable in vars: %s\n" % var
49 except ValueError, var:
50 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
54 if 'ROOT_MOUNTED' in vars.keys():
55 ROOT_MOUNTED= vars['ROOT_MOUNTED']
57 # mount the root system image if we haven't already.
58 # capture BootManagerExceptions during the vgscan/change and mount
59 # calls, so we can return 0 instead
61 # old cds need extra utilities to run lvm
62 if BOOT_CD_VERSION[0] == 2:
63 compatibility.setup_lvm_2x_cd( vars, log )
65 # simply creating an instance of this class and listing the system
66 # block devices will make them show up so vgscan can find the planetlab
68 systeminfo().get_block_device_list()
71 utils.sysexec( "vgscan", log )
72 utils.sysexec( "vgchange -ay planetlab", log )
73 except BootManagerException, e:
74 log.write( "BootManagerException during vgscan/vgchange: %s\n" %
78 utils.makedirs( SYSIMG_PATH )
81 utils.sysexec( "mount /dev/planetlab/root %s" % SYSIMG_PATH, log )
82 utils.sysexec( "mount /dev/planetlab/vservers %s/vservers" %
84 except BootManagerException, e:
85 log.write( "BootManagerException during vgscan/vgchange: %s\n" %
90 vars['ROOT_MOUNTED']= 1
94 if os.access("%s/boot/kernel-boot" % SYSIMG_PATH, os.F_OK | os.R_OK) and \
95 os.access("%s/boot/initrd-boot" % SYSIMG_PATH, os.F_OK | os.R_OK):
99 log.write( "Node does not appear to be installed correctly:\n" )
100 log.write( "missing file /boot/ initrd-boot or kernel-boot\n" )
103 # write out the node id to /etc/planetlab/node_id. if this fails, return
104 # 0, indicating the node isn't a valid install.
106 node_id_file_path= "%s/%s/node_id" % (SYSIMG_PATH,PLCONF_DIR)
107 node_id_file= file( node_id_file_path, "w" )
108 node_id_file.write( str(NODE_ID) )
111 log.write( "Updated /etc/planetlab/node_id" )
113 log.write( "Unable to write out /etc/planetlab/node_id" )
116 log.write( "Everything appears to be ok\n" )