X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FUpdateNodeGroup.py;h=5d31026e9f98ddec2f79b1b1f5605b69d63f9475;hb=2cff66789332935b816d21e4bf433b83218635df;hp=a47591b48f6c2cd3b151b9db599e35af6ff32b5a;hpb=1d38462c0f3983b50994f00e6602c4c80b4604a8;p=plcapi.git diff --git a/PLC/Methods/UpdateNodeGroup.py b/PLC/Methods/UpdateNodeGroup.py index a47591b..5d31026 100644 --- a/PLC/Methods/UpdateNodeGroup.py +++ b/PLC/Methods/UpdateNodeGroup.py @@ -2,7 +2,7 @@ from PLC.Faults import * from PLC.Method import Method from PLC.Parameter import Parameter, Mixed from PLC.NodeGroups import NodeGroup, NodeGroups -from PLC.Auth import PasswordAuth +from PLC.Auth import Auth can_update = lambda (field, value): field in \ ['name', 'description'] @@ -16,27 +16,31 @@ class UpdateNodeGroup(Method): roles = ['admin'] - update_fields = dict(filter(can_update, NodeGroup.fields.items())) + nodegroup_fields = dict(filter(can_update, NodeGroup.fields.items())) accepts = [ - PasswordAuth(), + Auth(), Mixed(NodeGroup.fields['nodegroup_id'], NodeGroup.fields['name']), - update_fields + nodegroup_fields ] returns = Parameter(int, '1 if successful') - def call(self, auth, nodegroup_id_or_name, nodegroup_fields = {}): + def call(self, auth, nodegroup_id_or_name, nodegroup_fields): nodegroup_fields = dict(filter(can_update, nodegroup_fields.items())) # Get nodegroup information nodegroups = NodeGroups(self.api, [nodegroup_id_or_name]) if not nodegroups: raise PLCInvalidArgument, "No such nodegroup" - nodegroup = nodegroups.values()[0] + nodegroup = nodegroups[0] nodegroup.update(nodegroup_fields) nodegroup.sync() - + + # Logging variables + self.object_ids = [nodegroup['nodegroup_id']] + self.message = 'Node group %d updated: %s' % \ + (nodegroup['nodegroup_id'], ", ".join(nodegroup_fields.keys())) return 1