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