3 # Copyright (c) 2003 Intel Corporation
6 # Copyright (c) 2004-2006 The Trustees of Princeton University
11 from Exceptions import *
18 Contact PLC and get the attributes for this node. Also, parse in
19 options from the node model strong.
21 Also, update any node network settings at PLC, minus the ip address,
22 so, upload the mac (if node_id was in conf file), gateway, network,
23 broadcast, netmask, dns1/2, and the hostname/domainname.
25 Expect the following keys to be set:
26 BOOT_CD_VERSION A tuple of the current bootcd version
27 SKIP_HARDWARE_REQUIREMENT_CHECK Whether or not we should skip hardware
30 The following keys are set/updated:
31 WAS_NODE_ID_IN_CONF Set to 1 if the node id was in the conf file
32 WAS_NODE_KEY_IN_CONF Set to 1 if the node key was in the conf file
33 BOOT_STATE The current node boot state
34 NODE_MODEL The user specified model of this node
35 NODE_MODEL_OPTIONS The options extracted from the user specified
37 NETWORK_SETTINGS A dictionary of the values of the network settings
38 SKIP_HARDWARE_REQUIREMENT_CHECK Whether or not we should skip hardware
40 NODE_SESSION The session value returned from BootGetNodeDetails
41 NODE_NETWORKS The networks associated with this node
43 Return 1 if able to contact PLC and get node info.
44 Raise a BootManagerException if anything fails.
47 log.write( "\n\nStep: Retrieving details of node from PLC.\n" )
49 # make sure we have the variables we need
51 BOOT_CD_VERSION= vars["BOOT_CD_VERSION"]
52 if BOOT_CD_VERSION == "":
53 raise ValueError, "BOOT_CD_VERSION"
55 SKIP_HARDWARE_REQUIREMENT_CHECK= vars["SKIP_HARDWARE_REQUIREMENT_CHECK"]
56 if SKIP_HARDWARE_REQUIREMENT_CHECK == "":
57 raise ValueError, "SKIP_HARDWARE_REQUIREMENT_CHECK"
59 NETWORK_SETTINGS= vars["NETWORK_SETTINGS"]
60 if NETWORK_SETTINGS == "":
61 raise ValueError, "NETWORK_SETTINGS"
63 WAS_NODE_ID_IN_CONF= vars["WAS_NODE_ID_IN_CONF"]
64 if WAS_NODE_ID_IN_CONF == "":
65 raise ValueError, "WAS_NODE_ID_IN_CONF"
67 WAS_NODE_KEY_IN_CONF= vars["WAS_NODE_KEY_IN_CONF"]
68 if WAS_NODE_KEY_IN_CONF == "":
69 raise ValueError, "WAS_NODE_KEY_IN_CONF"
72 raise BootManagerException, "Missing variable in vars: %s\n" % var
73 except ValueError, var:
74 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
76 details= BootAPI.call_api_function( vars, "BootGetNodeDetails", () )
78 vars['BOOT_STATE']= details['boot_state']
79 vars['NODE_MODEL']= string.strip(details['model'])
80 vars['NODE_SESSION']= details['session']
82 log.write( "Successfully retrieved node record.\n" )
83 log.write( "Current boot state: %s\n" % vars['BOOT_STATE'] )
84 log.write( "Node make/model: %s\n" % vars['NODE_MODEL'] )
86 # parse in the model options from the node_model string
87 model= vars['NODE_MODEL']
88 options= ModelOptions.Get(model)
89 vars['NODE_MODEL_OPTIONS']=options
91 # Check if we should skip hardware requirement check
92 if options & ModelOptions.MINHW:
93 vars['SKIP_HARDWARE_REQUIREMENT_CHECK']=1
94 log.write( "node model indicates override to hardware requirements.\n" )
96 # this contains all the node networks, for now, we are only concerned
97 # in the primary network
98 node_networks= details['networks']
100 for network in node_networks:
101 if network['is_primary'] == 1:
106 raise BootManagerException, "Node did not have a primary network."
108 vars['NODE_NETWORKS']= node_networks
110 log.write( "Primary network as returned from PLC: %s\n" % str(network) )
112 # if we got this far, the ip on the floppy and the ip in plc match,
113 # make the rest of the PLC information match whats on the floppy
114 network['method']= NETWORK_SETTINGS['method']
116 # only nodes that have the node_id specified directly in the configuration
117 # file can change their mac address
118 if WAS_NODE_ID_IN_CONF == 1:
119 network['mac']= NETWORK_SETTINGS['mac']
121 network['gateway']= NETWORK_SETTINGS['gateway']
122 network['network']= NETWORK_SETTINGS['network']
123 network['broadcast']= NETWORK_SETTINGS['broadcast']
124 network['netmask']= NETWORK_SETTINGS['netmask']
125 network['dns1']= NETWORK_SETTINGS['dns1']
126 network['dns2']= NETWORK_SETTINGS['dns2']
128 log.write( "Updating network settings at PLC to match floppy " \
129 "(except for node ip).\n" )
131 update_vals['primary_network']= network
132 BootAPI.call_api_function( vars, "BootUpdateNode", (update_vals,) )