X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FRebootNode.py;h=bffa3dab53148f20da21a09c0b35c5d380435445;hb=d22aea71d8cd39db72394cad0b8943b387fc3b4b;hp=59eb688b7cffa473a2019e80110d7a3dac02b72c;hpb=9f85220044eae8b00c0400ed87d069bc58ca9d4d;p=plcapi.git diff --git a/PLC/Methods/RebootNode.py b/PLC/Methods/RebootNode.py index 59eb688..bffa3da 100644 --- a/PLC/Methods/RebootNode.py +++ b/PLC/Methods/RebootNode.py @@ -5,7 +5,7 @@ from PLC.Method import Method from PLC.Parameter import Parameter, Mixed from PLC.Nodes import Node, Nodes from PLC.NodeNetworks import NodeNetwork, NodeNetworks -from PLC.Auth import PasswordAuth +from PLC.Auth import Auth from PLC.POD import udp_pod class RebootNode(Method): @@ -23,16 +23,18 @@ class RebootNode(Method): roles = ['admin', 'pi', 'tech'] accepts = [ - PasswordAuth(), + Auth(), Mixed(Node.fields['node_id'], Node.fields['hostname']) ] returns = Parameter(int, '1 if successful') + object_type = 'Node' + def call(self, auth, node_id_or_hostname): # Get account information - nodes = Nodes(self.api, [node_id_or_hostname]).values() + nodes = Nodes(self.api, [node_id_or_hostname]) if not nodes: raise PLCInvalidArgument, "No such node" @@ -55,7 +57,7 @@ class RebootNode(Method): # Only use the hostname as a backup, try to use the primary ID # address instead. host = node['hostname'] - nodenetworks = NodeNetworks(self.api, node['nodenetwork_ids']).values() + nodenetworks = NodeNetworks(self.api, node['nodenetwork_ids']) for nodenetwork in nodenetworks: if nodenetwork['is_primary'] == 1: host = nodenetwork['ip'] @@ -66,5 +68,7 @@ class RebootNode(Method): except socket.error, e: # Ignore socket errors pass - + + self.message = "RebootNode called" + return 1