3 # Copyright (c) 2003 Intel Corporation
6 # Copyright (c) 2004-2006 The Trustees of Princeton University
11 from Exceptions import *
19 See if a node installation is valid. More checks should certainly be
20 done in the future, but for now, make sure that the sym links kernel-boot
21 and initrd-boot exist in /boot
23 Expect the following variables to be set:
24 SYSIMG_PATH the path where the system image will be mounted
25 (always starts with TEMP_PATH)
26 ROOT_MOUNTED the node root file system is mounted
27 NODE_ID The db node_id for this machine
28 PLCONF_DIR The directory to store the configuration file in
30 Set the following variables upon successfully running:
31 ROOT_MOUNTED the node root file system is mounted
34 log.write( "\n\nStep: Validating node installation.\n" )
36 # make sure we have the variables we need
38 SYSIMG_PATH= vars["SYSIMG_PATH"]
40 raise ValueError, "SYSIMG_PATH"
42 NODE_ID= vars["NODE_ID"]
44 raise ValueError, "NODE_ID"
46 PLCONF_DIR= vars["PLCONF_DIR"]
48 raise ValueError, "PLCONF_DIR"
50 NODE_MODEL_OPTIONS= vars["NODE_MODEL_OPTIONS"]
52 PARTITIONS= vars["PARTITIONS"]
53 if PARTITIONS == None:
54 raise ValueError, "PARTITIONS"
57 raise BootManagerException, "Missing variable in vars: %s\n" % var
58 except ValueError, var:
59 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
63 if vars.has_key('ROOT_MOUNTED'):
64 ROOT_MOUNTED= vars['ROOT_MOUNTED']
66 # mount the root system image if we haven't already.
67 # capture BootManagerExceptions during the vgscan/change and mount
68 # calls, so we can return 0 instead
71 # simply creating an instance of this class and listing the system
72 # block devices will make them show up so vgscan can find the planetlab
74 systeminfo.get_block_device_list(vars, log)
77 utils.sysexec( "vgscan", log )
78 utils.sysexec( "vgchange -ay planetlab", log )
79 except BootManagerException, e:
80 log.write( "BootManagerException during vgscan/vgchange: %s\n" %
84 utils.makedirs( SYSIMG_PATH )
87 log.write( "mounting root file system\n" )
88 utils.sysexec("mount -t ext3 %s %s" % (PARTITIONS["root"],SYSIMG_PATH),log)
90 log.write( "mounting vserver partition in root file system\n" )
91 utils.sysexec("mount -t ext3 %s %s/vservers" % \
92 (PARTITIONS["vservers"], SYSIMG_PATH), log)
94 log.write( "mounting /proc\n" )
95 utils.sysexec( "mount -t proc none %s/proc" % SYSIMG_PATH, log )
96 except BootManagerException, e:
97 log.write( "BootManagerException during mount of /root, /vservers and /proc: %s\n" %
102 vars['ROOT_MOUNTED']= 1
105 # check if the base kernel is installed
107 os.stat("%s/boot/kernel-boot" % SYSIMG_PATH)
108 os.stat("%s/boot/initrd-boot" % SYSIMG_PATH)
110 log.write( "FATAL: Couldn't locate base kernel.\n")
113 # check if the model specified kernel is installed
115 if NODE_MODEL_OPTIONS & ModelOptions.SMP:
118 os.stat("%s/boot/kernel-boot%s" % (SYSIMG_PATH,option))
119 os.stat("%s/boot/initrd-boot%s" % (SYSIMG_PATH,option))
121 # smp kernel is not there; remove option from modeloptions
122 # such that the rest of the code base thinks we are just
123 # using the base kernel.
124 NODE_MODEL_OPTIONS = NODE_MODEL_OPTIONS & ~ModelOptions.SMP
125 vars["NODE_MODEL_OPTIONS"] = NODE_MODEL_OPTIONS
126 log.write( "WARNING: Couldn't locate smp kernel.\n")
128 # write out the node id to /etc/planetlab/node_id. if this fails, return
129 # 0, indicating the node isn't a valid install.
131 node_id_file_path= "%s/%s/node_id" % (SYSIMG_PATH,PLCONF_DIR)
132 node_id_file= file( node_id_file_path, "w" )
133 node_id_file.write( str(NODE_ID) )
136 log.write( "Updated /etc/planetlab/node_id\n" )
138 log.write( "Unable to write out /etc/planetlab/node_id\n" )
141 log.write( "Everything appears to be ok\n" )