3 # Copyright (c) 2003 Intel Corporation
6 # Copyright (c) 2004-2006 The Trustees of Princeton University
12 import InstallBuildVServer
13 from Exceptions import *
20 Reconfigure a node if necessary, including rewriting any network init
21 scripts based on what PLC has. Also, update any slivers on the machine
22 incase their network files are out of date (primarily /etc/hosts).
24 Also write out /etc/planetlab/session, a random string that gets
25 a new value at every request of BootGetNodeDetails (ie, every boot)
27 This step expects the root to be already mounted on SYSIMG_PATH.
29 Except the following keys to be set:
30 SYSIMG_PATH the path where the system image will be mounted
31 (always starts with TEMP_PATH)
32 ROOT_MOUNTED the node root file system is mounted
33 NETWORK_SETTINGS A dictionary of the values from the network
37 log.write( "\n\nStep: Updating node configuration.\n" )
39 # make sure we have the variables we need
41 NETWORK_SETTINGS= vars["NETWORK_SETTINGS"]
42 if NETWORK_SETTINGS == "":
43 raise ValueError, "NETWORK_SETTINGS"
45 SYSIMG_PATH= vars["SYSIMG_PATH"]
47 raise ValueError, "SYSIMG_PATH"
49 ROOT_MOUNTED= vars["ROOT_MOUNTED"]
50 if ROOT_MOUNTED == "":
51 raise ValueError, "ROOT_MOUNTED"
54 raise BootManagerException, "Missing variable in vars: %s\n" % var
55 except ValueError, var:
56 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
59 ip= NETWORK_SETTINGS['ip']
60 method= NETWORK_SETTINGS['method']
61 hostname= NETWORK_SETTINGS['hostname']
62 domainname= NETWORK_SETTINGS['domainname']
64 raise BootManagerException, \
65 "Missing network value %s in var NETWORK_SETTINGS\n" % var
69 raise BootManagerException, "Root isn't mounted on SYSIMG_PATH\n"
71 log.write( "Updating vserver's /etc/hosts and /etc/resolv.conf files\n" )
73 # create a list of the full directory paths of all the vserver images that
77 for base_dir in ('/vservers','/vservers/.vcache'):
79 full_dir_path= "%s/%s" % (SYSIMG_PATH,base_dir)
80 slices= os.listdir( full_dir_path )
83 slices.remove("lost+found")
87 update_path_list= update_path_list + map(lambda x: \
94 log.write( "Updating network configuration in:\n" )
95 if len(update_path_list) == 0:
96 log.write( "No vserver images found to update.\n" )
98 for base_dir in update_path_list:
99 log.write( "%s\n" % base_dir )
102 # now, update /etc/hosts and /etc/resolv.conf in each dir if
103 # the update flag is there
104 for base_dir in update_path_list:
105 InstallBuildVServer.update_vserver_network_files(base_dir,vars,log)