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.Nodes import Node, Nodes
6 from PLC.NodeGroups import NodeGroup, NodeGroups
8 class AdmDeleteNodeGroup(Method):
10 Delete an existing Node Group.
12 Admins my delete any node group
14 Returns 1 if successful, faults otherwise.
21 Mixed(NodeGroup.fields['nodegroup_id'],
22 NodeGroup.fields['name'])
25 returns = Parameter(int, '1 if successful')
27 def call(self, auth, node_group_id_or_name):
28 # Get account information
29 nodegroups = NodeGroups(self.api, [node_group_id_or_name])
31 raise PLCInvalidArgument, "No such node group"
33 nodegroup = nodegroups.values()[0]
35 # If we are not an admin, make sure that the caller is a
36 # member of the site at which the node is located.
37 if 'admin' not in self.caller['roles']:
38 # Authenticated function
39 raise PLCPermissionDenied, "Not allowed to delete nodes groups"