- added 'message' instance variable (high level description of this event)
[plcapi.git] / PLC / Methods / DeleteNodeNetwork.py
index 47910e3..6cba6a6 100644 (file)
@@ -1,17 +1,16 @@
 from PLC.Faults import *
 from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
-from PLC.Auth import PasswordAuth
+from PLC.Auth import Auth
 from PLC.Nodes import Node, Nodes
 from PLC.NodeNetworks import NodeNetwork, NodeNetworks
 
 class DeleteNodeNetwork(Method):
     """
-    Delete an existing Node Network. Nodenetwork_id must be associated to 
-    node_id and not be associated with a different node.
+    Deletes an existing node network interface.
 
-    ins may delete any node network. PIs and techs can only delete 
-    nodenetworks for thier nodes.
+    Admins may delete any node network. PIs and techs may only delete
+    node network interfaces associated with nodes at their sites.
 
     Returns 1 if successful, faults otherwise.
     """
@@ -19,22 +18,23 @@ class DeleteNodeNetwork(Method):
     roles = ['admin', 'pi', 'tech']
 
     accepts = [
-        PasswordAuth(),
-       Mixed(NodeNetwork.fields['nodenetwork_id'],
-             NodeNetwork.fields['ip'])
+        Auth(),
+       NodeNetwork.fields['nodenetwork_id']
         ]
 
     returns = Parameter(int, '1 if successful')
 
-    def call(self, auth, nodenetwork_id_or_ip):
+
+    def call(self, auth, nodenetwork_id):
+
         # Get node network information
-        nodenetworks = NodeNetworks(self.api, [nodenetwork_id_or_ip]).values()
+        nodenetworks = NodeNetworks(self.api, [nodenetwork_id])
         if not nodenetworks:
             raise PLCInvalidArgument, "No such node network"
        nodenetwork = nodenetworks[0]
        
        # Get node information
-       nodes = Nodes(self.api, [nodenetwork['node_id']]).values()
+       nodes = Nodes(self.api, [nodenetwork['node_id']])
        if not nodes:
                raise PLCInvalidArgument, "No such node"
        node = nodes[0]
@@ -50,4 +50,8 @@ class DeleteNodeNetwork(Method):
 
         nodenetwork.delete()
 
+       # Logging variables
+       self.object_ids = [nodenetwork['nodenetwork_id']]
+       self.message = "Node network %d deleted" % nodenetwork['nodenetwork_id']
+
         return 1