X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FAdmGetNodeGroupNodes.py;h=857e1b5d8a3265285264616594a2aeb9e3be0e46;hb=b0d2dea38d0136e256330b561ec1c6efd652f4dc;hp=8e845a671de5489c61dd4647573886e2b5b8ec56;hpb=5ac399f349470a15dc57d7261c97a69a17059f9f;p=plcapi.git diff --git a/PLC/Methods/AdmGetNodeGroupNodes.py b/PLC/Methods/AdmGetNodeGroupNodes.py index 8e845a6..857e1b5 100644 --- a/PLC/Methods/AdmGetNodeGroupNodes.py +++ b/PLC/Methods/AdmGetNodeGroupNodes.py @@ -1,47 +1,38 @@ -import os - from PLC.Faults import * from PLC.Method import Method from PLC.Parameter import Parameter, Mixed -from PLC.Sites import Site, Sites -from PLC.Nodes import Node, Nodes -from PLC.Auth import PasswordAuth +from PLC.Auth import Auth from PLC.NodeGroups import NodeGroup, NodeGroups + class AdmGetNodeGroupNodes(Method): """ - Return a list of node_ids for the node group specified. + Deprecated. See GetNodeGroups. + Returns a list of node_ids for the node group specified. """ + status = "deprecated" + + object_type = 'Node' + roles = ['admin', 'pi', 'user', 'tech'] accepts = [ - PasswordAuth(), - NodeGroup.fields['nodegroup_id'] + Auth(), + Mixed(NodeGroup.fields['nodegroup_id'], + NodeGroup.fields['name']) ] - returns = [NodeGroup.join_fields['node_ids']] + returns = NodeGroup.fields['node_ids'] - def __init__(self, *args, **kwds): - Method.__init__(self, *args, **kwds) - # Update documentation with list of default fields returned - self.__doc__ += os.linesep.join(Site.default_fields.keys()) + 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" - def call(self, auth, nodegroup_id): - # Authenticated function - assert self.caller is not None + # Get the info for the node group specified + nodegroup = nodegroups[0] - # Get nodes in this nodegroup - nodegroup = NodeGroups(self.api, [nodegroup_id]) - - # make sure sites are found - if not nodegroup: - raise PLCInvalidArgument, "No such site" - - #get the info for the node group specified - nodegroup_values = nodegroup.values()[0] - - #grab the list of node ides fromt the disctioary - node_ids = nodegroup_values['node_ids'] - - return node_ids + # Return the list of node_ids + return nodegroup['node_ids']