Merge from trunk
[plcapi.git] / trunk / PLC / Methods / AdmGetNodeGroupNodes.py
diff --git a/trunk/PLC/Methods/AdmGetNodeGroupNodes.py b/trunk/PLC/Methods/AdmGetNodeGroupNodes.py
new file mode 100644 (file)
index 0000000..51c392a
--- /dev/null
@@ -0,0 +1,36 @@
+from PLC.Faults import *
+from PLC.Method import Method
+from PLC.Parameter import Parameter, Mixed
+from PLC.Auth import Auth
+from PLC.NodeGroups import NodeGroup, NodeGroups
+
+class AdmGetNodeGroupNodes(Method):
+    """
+    Deprecated. See GetNodeGroups.
+
+    Returns a list of node_ids for the node group specified.
+    """
+
+    status = "deprecated"
+
+    roles = ['admin', 'pi', 'user', 'tech']
+
+    accepts = [
+        Auth(),
+        Mixed(NodeGroup.fields['nodegroup_id'],
+             NodeGroup.fields['name'])
+        ]
+
+    returns = NodeGroup.fields['node_ids']
+
+    def call(self, auth, nodegroup_id_or_name):
+        # Get nodes in this nodegroup
+       nodegroups = NodeGroups(self.api, [nodegroup_id_or_name])
+       if not nodegroups:
+            raise PLCInvalidArgument, "No such node group"
+
+       # Get the info for the node group specified
+       nodegroup = nodegroups[0]
+
+       # Return the list of node_ids
+        return nodegroup['node_ids']