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.Auth import Auth
7 can_update = lambda (field, value): field in \
8 ['name', 'description']
10 class AddNodeGroup(Method):
12 Adds a new node group. Any values specified in nodegroup_fields
13 are used, otherwise defaults are used.
15 Returns the new nodegroup_id (> 0) if successful, faults otherwise.
20 nodegroup_fields = dict(filter(can_update, NodeGroup.fields.items()))
27 returns = Parameter(int, 'New nodegroup_id (> 0) if successful')
30 object_type = 'NodeGroup'
33 def call(self, auth, nodegroup_fields):
34 nodegroup_fields = dict(filter(can_update, nodegroup_fields.items()))
35 nodegroup = NodeGroup(self.api, nodegroup_fields)
38 self.object_ids = [nodegroup['nodegroup_id']]
40 return nodegroup['nodegroup_id']