- removed 'Adm' prefix
[plcapi.git] / PLC / Methods / AddNodeGroup.py
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 PasswordAuth
6
7 class AddNodeGroup(Method):
8     """
9     Adds a new node group. Any values specified in optional_vals are used,
10     otherwise defaults are used.
11
12     Returns the new nodegroup_id (> 0) if successful, faults otherwise.
13     """
14
15     roles = ['admin']
16
17     accepts = [
18         PasswordAuth(),
19         NodeGroup.fields['name'],
20         NodeGroup.fields['description']
21         ]
22
23     returns = Parameter(int, 'New nodegroup_id (> 0) if successful')
24
25     def call(self, auth, name, description):
26         # Create node group
27         nodegroup = NodeGroup(self.api, {'name': name, 'description': description})
28         nodegroup.sync()
29
30         return nodegroup['nodegroup_id']