- added logging variable 'object_type'
[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     object_type = 'Node'
17
18     roles = ['admin', 'pi', 'user', 'tech']
19
20     accepts = [
21         Auth(),
22         Mixed(NodeGroup.fields['nodegroup_id'],
23               NodeGroup.fields['name'])
24         ]
25
26     returns = NodeGroup.fields['node_ids']
27
28     def call(self, auth, nodegroup_id_or_name):
29         # Get nodes in this nodegroup
30         nodegroups = NodeGroups(self.api, [nodegroup_id_or_name])
31         if not nodegroups:
32             raise PLCInvalidArgument, "No such node group"
33
34         # Get the info for the node group specified
35         nodegroup = nodegroups[0]
36
37         # Return the list of node_ids
38         return nodegroup['node_ids']