3 # Copyright (c) 2003 Intel Corporation
6 # Copyright (c) 2004-2006 The Trustees of Princeton University
12 from Exceptions import *
19 Contact PLC and get the attributes for this node. Also, parse in
20 options from the node model strong.
22 Also, update any node network settings at PLC, minus the ip address,
23 so, upload the mac (if node_id was in conf file), gateway, network,
24 broadcast, netmask, dns1/2, and the hostname/domainname.
26 Expect the following keys to be set:
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 SKIP_HARDWARE_REQUIREMENT_CHECK Whether or not we should skip hardware
39 NODE_SESSION The session value returned from BootGetNodeDetails
40 INTERFACES The network interfaces associated with this node
41 INTERFACE_SETTINGS A dictionary of the values of the interface settings
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 SKIP_HARDWARE_REQUIREMENT_CHECK= vars["SKIP_HARDWARE_REQUIREMENT_CHECK"]
52 if SKIP_HARDWARE_REQUIREMENT_CHECK == "":
53 raise ValueError, "SKIP_HARDWARE_REQUIREMENT_CHECK"
55 INTERFACE_SETTINGS= vars["INTERFACE_SETTINGS"]
56 if INTERFACE_SETTINGS == "":
57 raise ValueError, "INTERFACE_SETTINGS"
59 WAS_NODE_ID_IN_CONF= vars["WAS_NODE_ID_IN_CONF"]
60 if WAS_NODE_ID_IN_CONF == "":
61 raise ValueError, "WAS_NODE_ID_IN_CONF"
63 WAS_NODE_KEY_IN_CONF= vars["WAS_NODE_KEY_IN_CONF"]
64 if WAS_NODE_KEY_IN_CONF == "":
65 raise ValueError, "WAS_NODE_KEY_IN_CONF"
68 raise BootManagerException, "Missing variable in vars: %s\n" % var
69 except ValueError, var:
70 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
72 node_details= BootAPI.call_api_function( vars, "GetNodes",
74 ['boot_state', 'nodegroup_ids', 'interface_ids', 'model', 'site_id']))[0]
76 vars['BOOT_STATE']= node_details['boot_state']
77 vars['RUN_LEVEL']= node_details['boot_state']
78 vars['NODE_MODEL']= string.strip(node_details['model'])
79 vars['SITE_ID'] = node_details['site_id']
80 log.write( "Successfully retrieved node record.\n" )
81 log.write( "Current boot state: %s\n" % vars['BOOT_STATE'] )
82 log.write( "Node make/model: %s\n" % vars['NODE_MODEL'] )
84 # parse in the model options from the node_model string
85 model= vars['NODE_MODEL']
86 options= ModelOptions.Get(model)
87 vars['NODE_MODEL_OPTIONS']=options
89 # Check if we should skip hardware requirement check
90 if options & ModelOptions.MINHW:
91 vars['SKIP_HARDWARE_REQUIREMENT_CHECK']=1
92 log.write( "node model indicates override to hardware requirements.\n" )
94 # this contains all the node networks, for now, we are only concerned
95 # in the primary network
96 interfaces= BootAPI.call_api_function( vars, "GetInterfaces", (node_details['interface_ids'],))
98 for network in interfaces:
99 if network['is_primary'] == 1:
100 log.write( "Primary network as returned from PLC: %s\n" % str(network) )
105 raise BootManagerException, "Node did not have a primary network."
107 vars['INTERFACES']= interfaces
109 # call getNodeFlavour and store in VARS['node_flavour']
111 node_flavour = BootAPI.call_api_function(vars, "GetNodeFlavour", (vars['NODE_ID'], ) )
112 nodefamily = node_flavour['nodefamily']
113 extensions = node_flavour['extensions']
114 plain = node_flavour['plain']
116 exc_type, exc_value, exc_traceback = sys.exc_info()
117 lines=traceback.format_exception(exc_type,exc_value,exc_traceback)
118 for line in lines: log.write(line)
119 raise BootManagerException ("Could not call GetNodeFlavour - need PLCAPI-5.2")
122 'virt',# 'vs' or 'lxc'
123 'nodefamily',# the basename for downloading nodeimage
124 'extensions',# extensions to be applied on top of the base nodeimage
125 'plain'# false if compressed image, true if not
128 # MyPLC 5.0 workaround
129 if (vars['extensions']==''):
130 vars['extensions']=[]
132 for k in flavour_keys:
134 if (not vars.has_key(k)):
135 vars[k] = node_flavour[k]
137 log.write ("NodeFlavour as returned from PLC: %s\n"%node_flavour)