DeleteNodeNetwork need not require node_id_or_hostname to be passed in
authorMark Huang <mlhuang@cs.princeton.edu>
Mon, 16 Oct 2006 20:16:13 +0000 (20:16 +0000)
committerMark Huang <mlhuang@cs.princeton.edu>
Mon, 16 Oct 2006 20:16:13 +0000 (20:16 +0000)
PLC/Methods/AdmDeleteNodeNetwork.py
PLC/Methods/AdmGetAllNodeNetworks.py
PLC/Methods/DeleteNodeNetwork.py

index e395ac1..b446183 100644 (file)
@@ -1,3 +1,9 @@
+from PLC.Faults import *
+from PLC.Method import Method
+from PLC.Parameter import Parameter, Mixed
+from PLC.Auth import PasswordAuth
+from PLC.Nodes import Node, Nodes
+from PLC.NodeNetworks import NodeNetwork, NodeNetworks
 from PLC.Methods.DeleteNodeNetwork import DeleteNodeNetwork
 
 class AdmDeleteNodeNetwork(DeleteNodeNetwork):
@@ -5,4 +11,13 @@ class AdmDeleteNodeNetwork(DeleteNodeNetwork):
     Deprecated. See DeleteNodeNetwork.
     """
 
-    status = "deprecated"
+    accepts = [
+        PasswordAuth(),
+        Mixed(Node.fields['node_id'],
+             Node.fields['hostname']),
+       Mixed(NodeNetwork.fields['nodenetwork_id'],
+             NodeNetwork.fields['hostname'])
+        ]
+
+    def call(self, auth, node_id_or_hostname, nodenetwork_id_or_hostname):
+        return DeleteNodeNetwork.call(self, auth, nodenetwork_id_or_hostname)
index 0dd73e3..c947d25 100644 (file)
@@ -25,13 +25,13 @@ class AdmGetAllNodeNetworks(GetNodeNetworks):
     returns = [NodeNetwork.fields]
 
     def call(self, auth, node_id_or_hostname):
-        # Authenticated function
-        assert self.caller is not None
-
         # Get node information
         nodes = Nodes(self.api, [node_id_or_hostname]).values()
        if not nodes:
             raise PLCInvalidArgument, "No such node"
        node = nodes[0]
 
+        if not node['nodenetwork_ids']:
+            return []
+
         return GetNodeNetworks.call(self, auth, node['nodenetwork_ids'])
index d2c6d4a..7b546de 100644 (file)
@@ -20,15 +20,13 @@ class DeleteNodeNetwork(Method):
 
     accepts = [
         PasswordAuth(),
-        Mixed(Node.fields['node_id'],
-             Node.fields['hostname']),
        Mixed(NodeNetwork.fields['nodenetwork_id'],
              NodeNetwork.fields['hostname'])
         ]
 
     returns = Parameter(int, '1 if successful')
 
-    def call(self, auth, node_id_or_hostname, nodenetwork_id_or_hostname):
+    def call(self, auth, nodenetwork_id_or_hostname):
         # Get node network information
         nodenetworks = NodeNetworks(self.api, [nodenetwork_id_or_hostname]).values()
         if not nodenetworks:
@@ -36,16 +34,11 @@ class DeleteNodeNetwork(Method):
        nodenetwork = nodenetworks[0]
        
        # Get node information
-       nodes = Nodes(self.api, [node_id_or_hostname]).values()
+       nodes = Nodes(self.api, [nodenetwork['node_id']]).values()
        if not nodes:
                raise PLCInvalidArgument, "No such node"
        node = nodes[0]
 
-       # Check if node network is associated with specified node
-       if node['node_id'] != nodenetwork['node_id'] or \
-           nodenetwork['nodenetwork_id'] not in node['nodenetwork_ids']:
-            raise PLCInvalidArgument, "Node network not associated with node"
-
         # Authenticated functino
        assert self.caller is not None