3 from Exceptions import *
10 Contact PLC and get the attributes for this node. Also, parse in
11 options from the node model strong.
13 Also, update any node network settings at PLC, minus the ip address,
14 so, upload the mac (if node_id was in conf file), gateway, network,
15 broadcast, netmask, dns1/2, and the hostname/domainname.
17 Expect the following keys to be set:
18 BOOT_CD_VERSION A tuple of the current bootcd version
19 SKIP_HARDWARE_REQUIREMENT_CHECK Whether or not we should skip hardware
22 The following keys are set/updated:
23 WAS_NODE_ID_IN_CONF Set to 1 if the node id was in the conf file
24 WAS_NODE_KEY_IN_CONF Set to 1 if the node key was in the conf file
25 BOOT_STATE The current node boot state
26 NODE_MODEL The user specified model of this node
27 NODE_MODEL_OPTIONS The options extracted from the user specified
29 NETWORK_SETTINGS A dictionary of the values of the network settings
30 SKIP_HARDWARE_REQUIREMENT_CHECK Whether or not we should skip hardware
32 NODE_SESSION The session value returned from BootGetNodeDetails
34 Return 1 if able to contact PLC and get node info.
35 Raise a BootManagerException if anything fails.
38 log.write( "\n\nStep: Retrieving details of node from PLC.\n" )
40 # make sure we have the variables we need
42 BOOT_CD_VERSION= vars["BOOT_CD_VERSION"]
43 if BOOT_CD_VERSION == "":
44 raise ValueError, "BOOT_CD_VERSION"
46 SKIP_HARDWARE_REQUIREMENT_CHECK= vars["SKIP_HARDWARE_REQUIREMENT_CHECK"]
47 if SKIP_HARDWARE_REQUIREMENT_CHECK == "":
48 raise ValueError, "SKIP_HARDWARE_REQUIREMENT_CHECK"
50 NETWORK_SETTINGS= vars["NETWORK_SETTINGS"]
51 if NETWORK_SETTINGS == "":
52 raise ValueError, "NETWORK_SETTINGS"
54 WAS_NODE_ID_IN_CONF= vars["WAS_NODE_ID_IN_CONF"]
55 if WAS_NODE_ID_IN_CONF == "":
56 raise ValueError, "WAS_NODE_ID_IN_CONF"
58 WAS_NODE_KEY_IN_CONF= vars["WAS_NODE_KEY_IN_CONF"]
59 if WAS_NODE_KEY_IN_CONF == "":
60 raise ValueError, "WAS_NODE_KEY_IN_CONF"
63 raise BootManagerException, "Missing variable in vars: %s\n" % var
64 except ValueError, var:
65 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
67 details= BootAPI.call_api_function( vars, "BootGetNodeDetails", () )
69 vars['BOOT_STATE']= details['boot_state']
70 vars['NODE_MODEL']= string.strip(details['model'])
71 vars['NODE_SESSION']= details['session']
73 log.write( "Successfully retrieved node record.\n" )
74 log.write( "Current boot state: %s\n" % vars['BOOT_STATE'] )
75 log.write( "Node make/model: %s\n" % vars['NODE_MODEL'] )
77 # parse in the model options from the node_model string
78 model= vars['NODE_MODEL']
79 options= ModelOptions.Get(model)
80 vars['NODE_MODEL_OPTIONS']=options
82 # Check if we should skip hardware requirement check
83 if options & ModelOptions.MINHW:
84 vars['SKIP_HARDWARE_REQUIREMENT_CHECK']=1
85 log.write( "node model indicates override to hardware requirements.\n" )
87 # this contains all the node networks, for now, we are only concerned
88 # in the primary network
89 node_networks= details['networks']
91 for network in node_networks:
92 if network['is_primary'] == 1:
97 raise BootManagerException, "Node did not have a primary network."
99 log.write( "Primary network as returned from PLC: %s\n" % str(network) )
101 # if we got this far, the ip on the floppy and the ip in plc match,
102 # make the rest of the PLC information match whats on the floppy
103 network['method']= NETWORK_SETTINGS['method']
105 # only nodes that have the node_id specified directly in the configuration
106 # file can change their mac address
107 if WAS_NODE_ID_IN_CONF == 1:
108 network['mac']= NETWORK_SETTINGS['mac']
110 network['gateway']= NETWORK_SETTINGS['gateway']
111 network['network']= NETWORK_SETTINGS['network']
112 network['broadcast']= NETWORK_SETTINGS['broadcast']
113 network['netmask']= NETWORK_SETTINGS['netmask']
114 network['dns1']= NETWORK_SETTINGS['dns1']
115 network['dns2']= NETWORK_SETTINGS['dns2']
117 log.write( "Updating network settings at PLC to match floppy " \
118 "(except for node ip).\n" )
120 update_vals['primary_network']= network
121 BootAPI.call_api_function( vars, "BootUpdateNode", (update_vals,) )