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 This step expects the root to be already mounted on SYSIMG_PATH.
18 Except the following keys to be set:
19 SYSIMG_PATH the path where the system image will be mounted
20 (always starts with TEMP_PATH)
21 ROOT_MOUNTED the node root file system is mounted
22 NETWORK_SETTINGS A dictionary of the values from the network
26 log.write( "\n\nStep: Updating node configuration.\n" )
28 # make sure we have the variables we need
30 NETWORK_SETTINGS= vars["NETWORK_SETTINGS"]
31 if NETWORK_SETTINGS == "":
32 raise ValueError, "NETWORK_SETTINGS"
34 SYSIMG_PATH= vars["SYSIMG_PATH"]
36 raise ValueError, "SYSIMG_PATH"
38 ROOT_MOUNTED= vars["ROOT_MOUNTED"]
39 if ROOT_MOUNTED == "":
40 raise ValueError, "ROOT_MOUNTED"
43 raise BootManagerException, "Missing variable in vars: %s\n" % var
44 except ValueError, var:
45 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
48 ip= NETWORK_SETTINGS['ip']
49 method= NETWORK_SETTINGS['method']
50 hostname= NETWORK_SETTINGS['hostname']
51 domainname= NETWORK_SETTINGS['domainname']
53 raise BootManagerException, \
54 "Missing network value %s in var NETWORK_SETTINGS\n" % var
58 raise BootManagerException, "Root isn't mounted on SYSIMG_PATH\n"
61 log.write( "Updating node network configuration\n" )
62 InstallWriteConfig.write_network_configuration( vars, log )
65 log.write( "Updating vserver's /etc/hosts and /etc/resolv.conf files\n" )
67 # create a list of the full directory paths of all the vserver images that
71 for base_dir in ('/vservers','/vservers/.vcache'):
73 full_dir_path= "%s/%s" % (SYSIMG_PATH,base_dir)
74 slices= os.listdir( full_dir_path )
77 slices.remove("lost+found")
81 update_path_list= update_path_list + map(lambda x: \
88 log.write( "Updating network configuration in:\n" )
89 if len(update_path_list) == 0:
90 log.write( "No vserver images found to update.\n" )
92 for base_dir in update_path_list:
93 log.write( "%s\n" % base_dir )
96 # now, update /etc/hosts and /etc/resolv.conf in each dir if
97 # the update flag is there
98 for base_dir in update_path_list:
99 InstallBuildVServer.update_vserver_network_files(base_dir,vars,log)