Merge from trunk
[plcapi.git] / trunk / PLC / Methods / AdmGetAllNodeNetworks.py
diff --git a/trunk/PLC/Methods/AdmGetAllNodeNetworks.py b/trunk/PLC/Methods/AdmGetAllNodeNetworks.py
new file mode 100644 (file)
index 0000000..c00bdec
--- /dev/null
@@ -0,0 +1,37 @@
+from PLC.Faults import *
+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 Auth
+from PLC.Methods.GetNodeNetworks import GetNodeNetworks
+
+class AdmGetAllNodeNetworks(GetNodeNetworks):
+    """
+    Deprecated. Functionality can be implemented with GetNodes and
+    GetNodeNetworks.
+    """
+
+    status = "deprecated"
+
+    roles = ['admin', 'pi', 'user', 'tech']
+
+    accepts = [
+        Auth(),
+        Mixed(Node.fields['node_id'],
+              Node.fields['hostname'])
+        ]
+
+    returns = [NodeNetwork.fields]
+
+    def call(self, auth, node_id_or_hostname):
+        # Get node information
+        nodes = Nodes(self.api, [node_id_or_hostname])
+       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'])