2 from PLC.Faults import *
3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.Nodes import Node, Nodes
6 from PLC.NodeGroups import NodeGroup, NodeGroups
7 #from PLC.Sites import Site, Sites
8 from PLC.Auth import PasswordAuth
10 class AdmAddNodeGroup(Method):
12 Adds a new node group. Any values specified in optional_vals are used,
13 otherwise defaults are used.
15 Returns the new nodegroup_id (> 0) if successful, faults otherwise.
20 can_update = lambda (field, value): field in \
21 ['name', 'description', 'is_custom']
22 update_fields = dict(filter(can_update, NodeGroup.fields.items()))
26 NodeGroup.fields['name'],
27 NodeGroup.fields['description'],
31 returns = Parameter(int, 'New nodegroup_id (> 0) if successful')
33 def call(self, auth, name, description, optional_vals = {}):
34 if filter(lambda field: field not in self.update_fields, optional_vals):
35 raise PLCInvalidArgument, "Invalid fields specified"
38 node_group = NodeGroup(self.api, optional_vals)
39 node_group['name'] = name
40 node_group['description'] = description
43 return node_group['nodegroup_id']