- - added logging variable 'object_type'
[plcapi.git] / PLC / Methods / RebootNode.py
index 59eb688..bffa3da 100644 (file)
@@ -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