1 from PLC.Method import Method
2 from PLC.Parameter import Parameter, Mixed
3 from PLC.Auth import BootAuth
4 from PLC.Nodes import Node, Nodes
5 from PLC.NodeNetworks import NodeNetwork, NodeNetworks
6 from PLC.Sessions import Session, Sessions
8 class BootGetNodeDetails(Method):
10 Returns a set of details about the calling node, including a new
16 accepts = [BootAuth()]
19 'hostname': Node.fields['hostname'],
20 'boot_state': Node.fields['boot_state'],
21 'model': Node.fields['model'],
22 'networks': [NodeNetwork.fields],
23 'session': Session.fields['session_id'],
28 'hostname': self.caller['hostname'],
29 'boot_state': self.caller['boot_state'],
30 # XXX Boot Manager cannot unmarshal None
31 'model': self.caller['model'] or "",
34 # Generate a new session value
35 session = Session(self.api)
36 session.sync(commit = False)
37 session.add_node(self.caller, commit = True)
39 details['session'] = session['session_id']
41 if self.caller['nodenetwork_ids']:
42 details['networks'] = NodeNetworks(self.api, self.caller['nodenetwork_ids'])
43 # XXX Boot Manager cannot unmarshal None
44 for network in details['networks']:
46 if network[field] is None:
47 if isinstance(network[field], (int, long)):
52 self.messge = "Node request boot_state (%s) and networks" % \
53 (details['boot_state'])