From: Mark Huang Date: Fri, 27 Oct 2006 15:37:26 +0000 (+0000) Subject: - BootGetNodeDetails implementation X-Git-Tag: pycurl-7_13_1~432 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=8a487f290fe09f77b4e1c1bf7ddb38a5ab4832e6;p=plcapi.git - BootGetNodeDetails implementation --- diff --git a/PLC/Methods/BootGetNodeDetails.py b/PLC/Methods/BootGetNodeDetails.py new file mode 100644 index 00000000..4a877926 --- /dev/null +++ b/PLC/Methods/BootGetNodeDetails.py @@ -0,0 +1,41 @@ +from PLC.Method import Method +from PLC.Parameter import Parameter, Mixed +from PLC.Auth import BootAuth +from PLC.Nodes import Node, Nodes +from PLC.NodeNetworks import NodeNetwork, NodeNetworks +from PLC.Sessions import Session, Sessions + +class BootGetNodeDetails(Method): + """ + Returns a set of details about the calling node, including a new + node session value. + """ + + accepts = [BootAuth()] + returns = { + 'hostname': Node.fields['hostname'], + 'boot_state': Node.fields['boot_state'], + 'model': Node.fields['model'], + 'networks': [NodeNetwork.fields], + 'session': Session.fields['session_id'], + } + + def call(self, auth, update_fields): + details = { + 'hostname': self.caller['hostname'], + 'boot_state': self.caller['boot_state'], + 'model': self.caller['model'], + } + + # Generate a new session value + session = Session(self.api) + session.sync(commit = False) + session.add_node(self.caller, commit = True) + + details['session'] = session['session_id'] + + if self.caller['nodenetwork_ids']: + details['networks'] = NodeNetworks(self.api, self.caller['nodenetwork_ids']).values() + + return details +