1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.NodeGroups import NodeGroup, NodeGroups
5 from PLC.Nodes import Node, Nodes
6 from PLC.Auth import Auth
8 class DeleteNodeFromNodeGroup(Method):
10 Removes a node from the specified node group.
12 Returns 1 if successful, faults otherwise.
19 Mixed(Node.fields['node_id'],
20 Node.fields['hostname']),
21 Mixed(NodeGroup.fields['nodegroup_id'],
22 NodeGroup.fields['name']),
25 returns = Parameter(int, '1 if successful')
27 def call(self, auth, node_id_or_hostname, nodegroup_id_or_name):
29 nodes = Nodes(self.api, [node_id_or_hostname])
31 raise PLCInvalidArgument, "No such node"
36 nodegroups = NodeGroups(self.api, [nodegroup_id_or_name])
38 raise PLCInvalidArgument, "No such nodegroup"
40 nodegroup = nodegroups[0]
42 # Remove node from nodegroup
43 if node['node_id'] in nodegroup['node_ids']:
44 nodegroup.remove_node(node)