Merge remote-tracking branch 'origin/pycurl' into planetlab-4_0-branch
[plcapi.git] / PLC / Methods / AdmGetNodeGroupNodes.py
1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Auth import Auth
5 from PLC.NodeGroups import NodeGroup, NodeGroups
6
7 class AdmGetNodeGroupNodes(Method):
8     """
9     Deprecated. See GetNodeGroups.
10
11     Returns a list of node_ids for the node group specified.
12     """
13
14     status = "deprecated"
15
16     roles = ['admin', 'pi', 'user', 'tech']
17
18     accepts = [
19         Auth(),
20         Mixed(NodeGroup.fields['nodegroup_id'],
21               NodeGroup.fields['name'])
22         ]
23
24     returns = NodeGroup.fields['node_ids']
25
26     def call(self, auth, nodegroup_id_or_name):
27         # Get nodes in this nodegroup
28         nodegroups = NodeGroups(self.api, [nodegroup_id_or_name])
29         if not nodegroups:
30             raise PLCInvalidArgument, "No such node group"
31
32         # Get the info for the node group specified
33         nodegroup = nodegroups[0]
34
35         # Return the list of node_ids
36         return nodegroup['node_ids']