3 import InstallWriteConfig
4 import InstallBuildVServer
5 from Exceptions import *
12 Reconfigure a node if necessary, including rewriting any network init
13 scripts based on what PLC has. Also, update any slivers on the machine
14 incase their network files are out of date (primarily /etc/hosts).
16 Also write out /etc/planetlab/session, a random string that gets
17 a new value at every request of BootGetNodeDetails (ie, every boot)
19 This step expects the root to be already mounted on SYSIMG_PATH.
21 Except the following keys to be set:
22 SYSIMG_PATH the path where the system image will be mounted
23 (always starts with TEMP_PATH)
24 ROOT_MOUNTED the node root file system is mounted
25 NETWORK_SETTINGS A dictionary of the values from the network
27 NODE_SESSION the unique session val set when we requested
28 the current boot state
29 PLCONF_DIR The directory to store PL configuration files in
32 log.write( "\n\nStep: Updating node configuration.\n" )
34 # make sure we have the variables we need
36 NETWORK_SETTINGS= vars["NETWORK_SETTINGS"]
37 if NETWORK_SETTINGS == "":
38 raise ValueError, "NETWORK_SETTINGS"
40 SYSIMG_PATH= vars["SYSIMG_PATH"]
42 raise ValueError, "SYSIMG_PATH"
44 ROOT_MOUNTED= vars["ROOT_MOUNTED"]
45 if ROOT_MOUNTED == "":
46 raise ValueError, "ROOT_MOUNTED"
48 PLCONF_DIR= vars["PLCONF_DIR"]
50 raise ValueError, "PLCONF_DIR"
52 # its ok if this is blank
53 NODE_SESSION= vars["NODE_SESSION"]
56 raise BootManagerException, "Missing variable in vars: %s\n" % var
57 except ValueError, var:
58 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
61 ip= NETWORK_SETTINGS['ip']
62 method= NETWORK_SETTINGS['method']
63 hostname= NETWORK_SETTINGS['hostname']
64 domainname= NETWORK_SETTINGS['domainname']
66 raise BootManagerException, \
67 "Missing network value %s in var NETWORK_SETTINGS\n" % var
71 raise BootManagerException, "Root isn't mounted on SYSIMG_PATH\n"
74 log.write( "Updating node network configuration\n" )
75 InstallWriteConfig.write_network_configuration( vars, log )
78 log.write( "Updating vserver's /etc/hosts and /etc/resolv.conf files\n" )
80 # create a list of the full directory paths of all the vserver images that
84 for base_dir in ('/vservers','/vservers/.vcache'):
86 full_dir_path= "%s/%s" % (SYSIMG_PATH,base_dir)
87 slices= os.listdir( full_dir_path )
90 slices.remove("lost+found")
94 update_path_list= update_path_list + map(lambda x: \
101 log.write( "Updating network configuration in:\n" )
102 if len(update_path_list) == 0:
103 log.write( "No vserver images found to update.\n" )
105 for base_dir in update_path_list:
106 log.write( "%s\n" % base_dir )
109 # now, update /etc/hosts and /etc/resolv.conf in each dir if
110 # the update flag is there
111 for base_dir in update_path_list:
112 InstallBuildVServer.update_vserver_network_files(base_dir,vars,log)
115 # write out the session value /etc/planetlab/session
117 session_file_path= "%s/%s/session" % (SYSIMG_PATH,PLCONF_DIR)
118 session_file= file( session_file_path, "w" )
119 session_file.write( str(NODE_SESSION) )
122 log.write( "Updated /etc/planetlab/session" )
124 log.write( "Unable to write out /etc/planetlab/session, continuing anyway" )