try:
auth['node_id'] = vars['NODE_ID']
- auth['node_ip'] = vars['NETWORK_SETTINGS']['ip']
+ auth['node_ip'] = vars['INTERFACE_SETTINGS']['ip']
except KeyError, e:
return None
broadcast, netmask, dns1/2, and the hostname/domainname.
Expect the following keys to be set:
- BOOT_CD_VERSION A tuple of the current bootcd version
+ BOOT_CD_VERSION A tuple of the current bootcd version
SKIP_HARDWARE_REQUIREMENT_CHECK Whether or not we should skip hardware
requirement checks
The following keys are set/updated:
- WAS_NODE_ID_IN_CONF Set to 1 if the node id was in the conf file
- WAS_NODE_KEY_IN_CONF Set to 1 if the node key was in the conf file
- BOOT_STATE The current node boot state
- NODE_MODEL The user specified model of this node
- NODE_MODEL_OPTIONS The options extracted from the user specified
- model of this node
- NETWORK_SETTINGS A dictionary of the values of the network settings
+ WAS_NODE_ID_IN_CONF Set to 1 if the node id was in the conf file
+ WAS_NODE_KEY_IN_CONF Set to 1 if the node key was in the conf file
+ BOOT_STATE The current node boot state
+ NODE_MODEL The user specified model of this node
+ NODE_MODEL_OPTIONS The options extracted from the user specified
+ model of this node
SKIP_HARDWARE_REQUIREMENT_CHECK Whether or not we should skip hardware
- requirement checks
- NODE_SESSION The session value returned from BootGetNodeDetails
- NODE_NETWORKS The networks associated with this node
+ requirement checks
+ NODE_SESSION The session value returned from BootGetNodeDetails
+ INTERFACES The network interfaces associated with this node
+ INTERFACE_SETTINGS A dictionary of the values of the interface settings
Return 1 if able to contact PLC and get node info.
Raise a BootManagerException if anything fails.
if SKIP_HARDWARE_REQUIREMENT_CHECK == "":
raise ValueError, "SKIP_HARDWARE_REQUIREMENT_CHECK"
- NETWORK_SETTINGS= vars["NETWORK_SETTINGS"]
- if NETWORK_SETTINGS == "":
- raise ValueError, "NETWORK_SETTINGS"
+ INTERFACE_SETTINGS= vars["INTERFACE_SETTINGS"]
+ if INTERFACE_SETTINGS == "":
+ raise ValueError, "INTERFACE_SETTINGS"
WAS_NODE_ID_IN_CONF= vars["WAS_NODE_ID_IN_CONF"]
if WAS_NODE_ID_IN_CONF == "":
except ValueError, var:
raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
- details= BootAPI.call_api_function( vars, "GetNodes", (vars['NODE_ID'], ['boot_state', 'nodegroup_ids', 'interface_ids', 'model', 'site_id']))[0]
+ node_details= BootAPI.call_api_function( vars, "GetNodes",
+ (vars['NODE_ID'],
+ ['boot_state', 'nodegroup_ids', 'interface_ids', 'model', 'site_id']))[0]
- vars['BOOT_STATE']= details['boot_state']
- vars['NODE_MODEL']= string.strip(details['model'])
- vars['SITE_ID'] = details['site_id']
+ vars['BOOT_STATE']= node_details['boot_state']
+ vars['NODE_MODEL']= string.strip(node_details['model'])
+ vars['SITE_ID'] = node_details['site_id']
log.write( "Successfully retrieved node record.\n" )
log.write( "Current boot state: %s\n" % vars['BOOT_STATE'] )
log.write( "Node make/model: %s\n" % vars['NODE_MODEL'] )
# this contains all the node networks, for now, we are only concerned
# in the primary network
- node_networks= BootAPI.call_api_function( vars, "GetInterfaces", (details['interface_ids'],))
+ interfaces= BootAPI.call_api_function( vars, "GetInterfaces", (node_details['interface_ids'],))
got_primary= 0
- for network in node_networks:
+ for network in interfaces:
if network['is_primary'] == 1:
log.write( "Primary network as returned from PLC: %s\n" % str(network) )
got_primary= 1
if not got_primary:
raise BootManagerException, "Node did not have a primary network."
- vars['NODE_NETWORKS']= node_networks
+ vars['INTERFACES']= interfaces
return 1
PARTITIONS dictionary of generic part. types (root/swap)
and their associated devices.
PLCONF_DIR The directory to store the configuration file in
- NETWORK_SETTINGS A dictionary of the values from the network
+ INTERFACE_SETTINGS A dictionary of the values from the network
configuration file
BOOT_CD_VERSION A tuple of the current bootcd version
if PLCONF_DIR == "":
raise ValueError, "PLCONF_DIR"
- NETWORK_SETTINGS= vars["NETWORK_SETTINGS"]
- if NETWORK_SETTINGS == "":
- raise ValueError, "NETWORK_SETTINGS"
+ INTERFACE_SETTINGS= vars["INTERFACE_SETTINGS"]
+ if INTERFACE_SETTINGS == "":
+ raise ValueError, "INTERFACE_SETTINGS"
BOOT_CD_VERSION= vars["BOOT_CD_VERSION"]
if BOOT_CD_VERSION == "":
# the system image so we can run programs inside that need network access
method= ""
try:
- method= vars['NETWORK_SETTINGS']['method']
+ method= vars['INTERFACE_SETTINGS']['method']
except:
pass
WAS_NODE_KEY_IN_CONF Set to 1 if the node key was in the conf file
NONE_ID The db node_id for this machine
NODE_KEY The key for this node
- NETWORK_SETTINGS A dictionary of the values from the network
+ INTERFACE_SETTINGS A dictionary of the values from the network
configuration file. keys set:
method IP_METHOD
ip IP_ADDRESS
raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
- NETWORK_SETTINGS= {}
- NETWORK_SETTINGS['method']= "dhcp"
- NETWORK_SETTINGS['ip']= ""
- NETWORK_SETTINGS['mac']= ""
- NETWORK_SETTINGS['gateway']= ""
- NETWORK_SETTINGS['network']= ""
- NETWORK_SETTINGS['broadcast']= ""
- NETWORK_SETTINGS['netmask']= ""
- NETWORK_SETTINGS['dns1']= ""
- NETWORK_SETTINGS['dns2']= ""
- NETWORK_SETTINGS['hostname']= "localhost"
- NETWORK_SETTINGS['domainname']= "localdomain"
- vars['NETWORK_SETTINGS']= NETWORK_SETTINGS
+ INTERFACE_SETTINGS= {}
+ INTERFACE_SETTINGS['method']= "dhcp"
+ INTERFACE_SETTINGS['ip']= ""
+ INTERFACE_SETTINGS['mac']= ""
+ INTERFACE_SETTINGS['gateway']= ""
+ INTERFACE_SETTINGS['network']= ""
+ INTERFACE_SETTINGS['broadcast']= ""
+ INTERFACE_SETTINGS['netmask']= ""
+ INTERFACE_SETTINGS['dns1']= ""
+ INTERFACE_SETTINGS['dns2']= ""
+ INTERFACE_SETTINGS['hostname']= "localhost"
+ INTERFACE_SETTINGS['domainname']= "localdomain"
+ vars['INTERFACE_SETTINGS']= INTERFACE_SETTINGS
vars['NODE_ID']= 0
vars['NODE_KEY']= ""
def __parse_configuration_file( vars, log, file_contents ):
"""
- parse a configuration file, set keys in var NETWORK_SETTINGS
+ parse a configuration file, set keys in var INTERFACE_SETTINGS
in vars (see comment for function ReadNodeConfiguration). this
also reads the mac address from the machine if successful parsing
of the configuration file is completed.
BOOT_CD_VERSION= vars["BOOT_CD_VERSION"]
SUPPORT_FILE_DIR= vars["SUPPORT_FILE_DIR"]
- NETWORK_SETTINGS= vars["NETWORK_SETTINGS"]
+ INTERFACE_SETTINGS= vars["INTERFACE_SETTINGS"]
if file_contents is None:
log.write( "__parse_configuration_file called with no file contents\n" )
log.write( "Invalid IP_METHOD in configuration file:\n" )
log.write( line + "\n" )
return 0
- NETWORK_SETTINGS['method']= value.strip()
+ INTERFACE_SETTINGS['method']= value.strip()
if name == "IP_ADDRESS":
- NETWORK_SETTINGS['ip']= value.strip()
+ INTERFACE_SETTINGS['ip']= value.strip()
if name == "IP_GATEWAY":
- NETWORK_SETTINGS['gateway']= value.strip()
+ INTERFACE_SETTINGS['gateway']= value.strip()
if name == "IP_NETMASK":
- NETWORK_SETTINGS['netmask']= value.strip()
+ INTERFACE_SETTINGS['netmask']= value.strip()
if name == "IP_NETADDR":
- NETWORK_SETTINGS['network']= value.strip()
+ INTERFACE_SETTINGS['network']= value.strip()
if name == "IP_BROADCASTADDR":
- NETWORK_SETTINGS['broadcast']= value.strip()
+ INTERFACE_SETTINGS['broadcast']= value.strip()
if name == "IP_DNS1":
- NETWORK_SETTINGS['dns1']= value.strip()
+ INTERFACE_SETTINGS['dns1']= value.strip()
if name == "IP_DNS2":
- NETWORK_SETTINGS['dns2']= value.strip()
+ INTERFACE_SETTINGS['dns2']= value.strip()
if name == "HOST_NAME":
- NETWORK_SETTINGS['hostname']= string.lower(value)
+ INTERFACE_SETTINGS['hostname']= string.lower(value)
if name == "DOMAIN_NAME":
- NETWORK_SETTINGS['domainname']= string.lower(value)
+ INTERFACE_SETTINGS['domainname']= string.lower(value)
if name == "NET_DEVICE":
- NETWORK_SETTINGS['mac']= string.upper(value)
+ INTERFACE_SETTINGS['mac']= string.upper(value)
if name == "DISCONNECTED_OPERATION":
vars['DISCONNECTED_OPERATION']= value.strip()
# now if we are set to dhcp, clear out any fields
# that don't make sense
- if NETWORK_SETTINGS["method"] == "dhcp":
- NETWORK_SETTINGS["ip"]= ""
- NETWORK_SETTINGS["gateway"]= ""
- NETWORK_SETTINGS["netmask"]= ""
- NETWORK_SETTINGS["network"]= ""
- NETWORK_SETTINGS["broadcast"]= ""
- NETWORK_SETTINGS["dns1"]= ""
- NETWORK_SETTINGS["dns2"]= ""
+ if INTERFACE_SETTINGS["method"] == "dhcp":
+ INTERFACE_SETTINGS["ip"]= ""
+ INTERFACE_SETTINGS["gateway"]= ""
+ INTERFACE_SETTINGS["netmask"]= ""
+ INTERFACE_SETTINGS["network"]= ""
+ INTERFACE_SETTINGS["broadcast"]= ""
+ INTERFACE_SETTINGS["dns1"]= ""
+ INTERFACE_SETTINGS["dns2"]= ""
log.write("Successfully read and parsed node configuration file.\n" )
# if the mac wasn't specified, read it in from the system.
- if NETWORK_SETTINGS["mac"] == "":
+ if INTERFACE_SETTINGS["mac"] == "":
device= "eth0"
mac_addr= utils.get_mac_from_interface(device)
log.write( "Could not get mac address for device eth0.\n" )
return 0
- NETWORK_SETTINGS["mac"]= string.upper(mac_addr)
+ INTERFACE_SETTINGS["mac"]= string.upper(mac_addr)
log.write( "Got mac address %s for device %s\n" %
- (NETWORK_SETTINGS["mac"],device) )
+ (INTERFACE_SETTINGS["mac"],device) )
# now, if the conf file didn't contain a node id, post the mac address
bs_request= BootServerRequest.BootServerRequest()
- postVars= {"mac_addr" : NETWORK_SETTINGS["mac"]}
+ postVars= {"mac_addr" : INTERFACE_SETTINGS["mac"]}
result= bs_request.DownloadFile( "%s/getnodeid.php" %
SUPPORT_FILE_DIR,
None, postVars, 1, 1,
# in the configuration file matches the ip address. if it fails
# notify the owners
- hostname= NETWORK_SETTINGS['hostname'] + "." + \
- NETWORK_SETTINGS['domainname']
+ hostname= INTERFACE_SETTINGS['hostname'] + "." + \
+ INTERFACE_SETTINGS['domainname']
# set to 0 if any part of the hostname resolution check fails
hostname_resolve_ok= 1
hostname_resolve_ok= 0
- if NETWORK_SETTINGS['method'] == "dhcp":
+ if INTERFACE_SETTINGS['method'] == "dhcp":
if hostname_resolve_ok:
- NETWORK_SETTINGS['ip']= resolved_node_ip
+ INTERFACE_SETTINGS['ip']= resolved_node_ip
node_ip= resolved_node_ip
else:
can_make_api_call= 0
else:
- node_ip= NETWORK_SETTINGS['ip']
+ node_ip= INTERFACE_SETTINGS['ip']
# make sure the dns lookup matches what the configuration file says
if hostname_resolve_ok:
(hostname,node_ip) )
- vars["NETWORK_SETTINGS"]= NETWORK_SETTINGS
+ vars["INTERFACE_SETTINGS"]= INTERFACE_SETTINGS
if not hostname_resolve_ok and not vars['DISCONNECTED_OPERATION']:
log.write( "Hostname does not resolve correctly, will not continue.\n" )
SYSIMG_PATH the path where the system image will be mounted
(always starts with TEMP_PATH)
ROOT_MOUNTED the node root file system is mounted
- NETWORK_SETTINGS A dictionary of the values from the network
+ INTERFACE_SETTINGS A dictionary of the values from the network
configuration file
"""
# make sure we have the variables we need
try:
- NETWORK_SETTINGS= vars["NETWORK_SETTINGS"]
- if NETWORK_SETTINGS == "":
- raise ValueError, "NETWORK_SETTINGS"
+ INTERFACE_SETTINGS= vars["INTERFACE_SETTINGS"]
+ if INTERFACE_SETTINGS == "":
+ raise ValueError, "INTERFACE_SETTINGS"
SYSIMG_PATH= vars["SYSIMG_PATH"]
if SYSIMG_PATH == "":
raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
try:
- ip= NETWORK_SETTINGS['ip']
- method= NETWORK_SETTINGS['method']
- hostname= NETWORK_SETTINGS['hostname']
- domainname= NETWORK_SETTINGS['domainname']
+ ip= INTERFACE_SETTINGS['ip']
+ method= INTERFACE_SETTINGS['method']
+ hostname= INTERFACE_SETTINGS['hostname']
+ domainname= INTERFACE_SETTINGS['domainname']
except KeyError, var:
raise BootManagerException, \
- "Missing network value %s in var NETWORK_SETTINGS\n" % var
+ "Missing network value %s in var INTERFACE_SETTINGS\n" % var
if not ROOT_MOUNTED:
Expect the following variables from the store:
SYSIMG_PATH the path where the system image will be mounted
(always starts with TEMP_PATH)
- NETWORK_SETTINGS A dictionary of the values from the network
+ INTERFACE_SETTINGS A dictionary of the values from the network
configuration file
"""
if SYSIMG_PATH == "":
raise ValueError, "SYSIMG_PATH"
- NETWORK_SETTINGS= vars["NETWORK_SETTINGS"]
- if NETWORK_SETTINGS == "":
- raise ValueError, "NETWORK_SETTINGS"
+ INTERFACE_SETTINGS= vars["INTERFACE_SETTINGS"]
+ if INTERFACE_SETTINGS == "":
+ raise ValueError, "INTERFACE_SETTINGS"
except KeyError, var:
raise BootManagerException, "Missing variable in vars: %s\n" % var
raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
try:
- ip= NETWORK_SETTINGS['ip']
- method= NETWORK_SETTINGS['method']
- hostname= NETWORK_SETTINGS['hostname']
- domainname= NETWORK_SETTINGS['domainname']
+ ip= INTERFACE_SETTINGS['ip']
+ method= INTERFACE_SETTINGS['method']
+ hostname= INTERFACE_SETTINGS['hostname']
+ domainname= INTERFACE_SETTINGS['domainname']
except KeyError, var:
raise BootManagerException, \
- "Missing network value %s in var NETWORK_SETTINGS\n" % var
+ "Missing network value %s in var INTERFACE_SETTINGS\n" % var
try:
os.listdir(vserver_dir)
# expected /proc/partitions format
import os, string
+import traceback
-from Exceptions import *
import utils
-import BootServerRequest
-import ModelOptions
import urlparse
import httplib
+
+from Exceptions import *
+import BootServerRequest
+import ModelOptions
import BootAPI
def Run( vars, log ):
"""
Write out the network configuration for this machine:
/etc/hosts
- /etc/sysconfig/network-scripts/ifcfg-eth0
+ /etc/sysconfig/network-scripts/ifcfg-<ifname>
/etc/resolv.conf (if applicable)
/etc/sysconfig/network
The values to be used for the network settings are to be set in vars
- in the variable 'NETWORK_SETTINGS', which is a dictionary
+ in the variable 'INTERFACE_SETTINGS', which is a dictionary
with keys:
Key Used by this function
Expect the following variables from the store:
SYSIMG_PATH the path where the system image will be mounted
- (always starts with TEMP_PATH)
- NETWORK_SETTINGS A dictionary of the values from the network
- configuration file
- NODE_NETWORKS All the network associated with this node
+ (always starts with TEMP_PATH)
+ INTERFACES All the interfaces associated with this node
+ INTERFACE_SETTINGS dictionary
Sets the following variables:
None
"""
try:
- network_settings= vars['NETWORK_SETTINGS']
+ interface_settings= vars['INTERFACE_SETTINGS']
except KeyError, e:
- raise BootManagerException, "No network settings found in vars."
+ raise BootManagerException, "No interface settings found in vars."
try:
- hostname= network_settings['hostname']
- domainname= network_settings['domainname']
- method= network_settings['method']
- ip= network_settings['ip']
- gateway= network_settings['gateway']
- network= network_settings['network']
- netmask= network_settings['netmask']
- dns1= network_settings['dns1']
- mac= network_settings['mac']
+ hostname= interface_settings['hostname']
+ domainname= interface_settings['domainname']
+ method= interface_settings['method']
+ ip= interface_settings['ip']
+ gateway= interface_settings['gateway']
+ network= interface_settings['network']
+ netmask= interface_settings['netmask']
+ dns1= interface_settings['dns1']
+ mac= interface_settings['mac']
except KeyError, e:
- raise BootManagerException, "Missing value %s in network settings." % str(e)
+ raise BootManagerException, "Missing value %s in interface settings." % str(e)
try:
dns2= ''
- dns2= network_settings['dns2']
+ dns2= interface_settings['dns2']
except KeyError, e:
pass
else:
port = '80'
try:
- log.write("getting via https://%s/PlanetLabConf/get_plc_config.php" % host)
+ log.write("getting via https://%s/PlanetLabConf/get_plc_config.php " % host)
bootserver = httplib.HTTPSConnection(host, port)
bootserver.connect()
bootserver.request("GET","https://%s/PlanetLabConf/get_plc_config.php" % host)
plc_config.write("%s" % bootserver.getresponse().read())
bootserver.close()
- except:
- log.write("Failed. Using old method.")
+ log.write("Done\n")
+ except :
+ log.write(" .. Failed. Using old method. -- stack trace follows\n")
+ traceback.print_exc(file=log.OutputFile)
bs= BootServerRequest.BootServerRequest()
if bs.BOOTSERVER_CERTS:
print >> plc_config, "PLC_BOOT_HOST='%s'" % bs.BOOTSERVER_CERTS.keys()[0]
interfaces = {}
interface = 1
- for network in vars['NODE_NETWORKS']:
+ for interface in vars['INTERFACES']:
if method == "static" or method == "dhcp":
- if network['is_primary'] == 1:
+ if interface['is_primary'] == 1:
ifnum = 0
else:
ifnum = interface
interface += 1
int = {}
- if network['mac']:
- int['HWADDR'] = network['mac']
+ if interface['mac']:
+ int['HWADDR'] = interface['mac']
- if network['method'] == "static":
+ if interface['method'] == "static":
int['BOOTPROTO'] = "static"
- int['IPADDR'] = network['ip']
- int['NETMASK'] = network['netmask']
+ int['IPADDR'] = interface['ip']
+ int['NETMASK'] = interface['netmask']
- elif network['method'] == "dhcp":
+ elif interface['method'] == "dhcp":
int['BOOTPROTO'] = "dhcp"
- if network['hostname']:
- int['DHCP_HOSTNAME'] = network['hostname']
+ if interface['hostname']:
+ int['DHCP_HOSTNAME'] = interface['hostname']
else:
int['DHCP_HOSTNAME'] = hostname
- if not network['is_primary']:
+ if not interface['is_primary']:
int['DHCLIENTARGS'] = "-R subnet-mask"
alias = ""
ifname=None
- if len(network['interface_setting_ids']) > 0:
- settings = BootAPI.call_api_function(vars, "GetInterfaceSettings",
- ({'interface_setting_id': network['interface_setting_ids']},))
+ if len(interface['interface_setting_ids']) > 0:
+ settings = \
+ BootAPI.call_api_function(vars, "GetInterfaceSettings",
+ ({'interface_setting_id':
+ interface['interface_setting_ids']},))
for setting in settings:
# to explicitly set interface name
if setting['name'].upper() == "IFNAME":