*** empty log message ***
[plcapi.git] / PLC / Methods / AdmDeleteNodeGroup.py
1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Auth import PasswordAuth
5 from PLC.NodeGroups import NodeGroup, NodeGroups
6
7 class AdmDeleteNodeGroup(Method):
8     """
9     Delete an existing Node Group.
10
11     Admins may delete any node group
12
13     Returns 1 if successful, faults otherwise.
14     """
15
16     roles = ['admin']
17
18     accepts = [
19         PasswordAuth(),
20         Mixed(NodeGroup.fields['nodegroup_id'],
21               NodeGroup.fields['name'])
22         ]
23
24     returns = Parameter(int, '1 if successful')
25
26     def call(self, auth, node_group_id_or_name):
27         # Get account information
28         nodegroups = NodeGroups(self.api, [node_group_id_or_name])
29         if not nodegroups:
30             raise PLCInvalidArgument, "No such node group"
31
32         nodegroup = nodegroups.values()[0]
33
34         nodegroup.delete()
35
36         return 1