3 from PLC.Faults import *
4 from PLC.Method import Method
5 from PLC.Parameter import Parameter, Mixed
6 from PLC.Sites import Site, Sites
7 from PLC.Nodes import Node, Nodes
8 from PLC.Auth import PasswordAuth
9 from PLC.NodeGroups import NodeGroup, NodeGroups
10 class AdmGetNodeGroupNodes(Method):
12 Return a list of node_ids for the node group specified.
16 roles = ['admin', 'pi', 'user', 'tech']
20 Mixed(NodeGroup.fields['nodegroup_id'],
21 NodeGroup.fields['name'])
24 returns = [NodeGroup.join_fields['node_ids']]
26 def __init__(self, *args, **kwds):
27 Method.__init__(self, *args, **kwds)
28 # Update documentation with list of default fields returned
29 self.__doc__ += os.linesep.join(Site.default_fields.keys())
31 def call(self, auth, nodegroup_id_or_name):
32 # Authenticated function
33 assert self.caller is not None
35 # Get nodes in this nodegroup
36 nodegroup = NodeGroups(self.api, [nodegroup_id_or_name])
38 # make sure sites are found
40 raise PLCInvalidArgument, "No such site"
42 #get the info for the node group specified
43 nodegroup_values = nodegroup.values()[0]
45 #grab the list of node ides fromt the disctioary
46 node_ids = nodegroup_values['node_ids']