3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.Auth import BootAuth
6 from PLC.Nodes import Node, Nodes
7 from PLC.Interfaces import Interface, Interfaces
8 from PLC.Sessions import Session, Sessions
10 class BootGetNodeDetails(Method):
12 Returns a set of details about the calling node, including a new
18 accepts = [BootAuth()]
21 'hostname': Node.fields['hostname'],
22 'boot_state': Node.fields['boot_state'],
23 'model': Node.fields['model'],
24 'networks': [Interface.fields],
25 'session': Session.fields['session_id'],
30 'hostname': self.caller['hostname'],
31 'boot_state': self.caller['boot_state'],
32 # XXX Boot Manager cannot unmarshal None
33 'model': self.caller['model'] or "",
36 # Generate a new session value
37 session = Session(self.api)
38 session.sync(commit = False)
39 session.add_node(self.caller, commit = True)
41 details['session'] = session['session_id']
43 if self.caller['interface_ids']:
44 details['networks'] = Interfaces(self.api, self.caller['interface_ids'])
45 # XXX Boot Manager cannot unmarshal None
46 for network in details['networks']:
48 if network[field] is None:
49 if isinstance(network[field], (int, long)):
54 self.message = "Node request boot_state (%s) and networks" % \
55 (details['boot_state'])