From: Tony Mack Date: Tue, 27 Feb 2007 19:19:39 +0000 (+0000) Subject: - now using event_objects to log affected objects X-Git-Tag: PLCAPI-4.2-0~167 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=41063c2352286a103b95821293a961f219900f39;p=plcapi.git - now using event_objects to log affected objects --- diff --git a/PLC/Methods/DeleteAddress.py b/PLC/Methods/DeleteAddress.py index ece41bfb..d4f98bc7 100644 --- a/PLC/Methods/DeleteAddress.py +++ b/PLC/Methods/DeleteAddress.py @@ -37,7 +37,7 @@ class DeleteAddress(Method): address.delete() # Logging variables - self.object_ids = [address['address_id']] + self.event_objects = {'Address': [address['address_id']]} self.message = 'Address %d deleted' % address['address_id'] return 1 diff --git a/PLC/Methods/DeleteAddressType.py b/PLC/Methods/DeleteAddressType.py index 9dbe6522..4fd1d9b6 100644 --- a/PLC/Methods/DeleteAddressType.py +++ b/PLC/Methods/DeleteAddressType.py @@ -28,6 +28,6 @@ class DeleteAddressType(Method): raise PLCInvalidArgument, "No such address type" address_type = address_types[0] address_type.delete() - self.object_ids = [address_type['address_type_id']] + self.event_objects = {'AddressType': [address_type['address_type_id']]} return 1 diff --git a/PLC/Methods/DeleteAddressTypeFromAddress.py b/PLC/Methods/DeleteAddressTypeFromAddress.py index dfc473a9..d4ea928b 100644 --- a/PLC/Methods/DeleteAddressTypeFromAddress.py +++ b/PLC/Methods/DeleteAddressTypeFromAddress.py @@ -42,6 +42,7 @@ class DeleteAddressTypeFromAddress(Method): raise PLCPermissionDenied, "Address must be associated with one of your sites" address.remove_address_type(address_type) - self.object_ids = [address['address_id']] + self.event_objects = {'Address' : [address['address_id']], + 'AddressType': [address_type['address_type_id']]} return 1 diff --git a/PLC/Methods/DeleteConfFileFromNode.py b/PLC/Methods/DeleteConfFileFromNode.py index 0c30cf9b..50b08e6f 100644 --- a/PLC/Methods/DeleteConfFileFromNode.py +++ b/PLC/Methods/DeleteConfFileFromNode.py @@ -24,9 +24,6 @@ class DeleteConfFileFromNode(Method): returns = Parameter(int, '1 if successful') - object_type = 'Node' - - def call(self, auth, conf_file_id, node_id_or_hostname): # Get configuration file conf_files = ConfFiles(self.api, [conf_file_id]) @@ -45,6 +42,7 @@ class DeleteConfFileFromNode(Method): conf_file.remove_node(node) # Log affected objects - self.object_ids = [conf_file_id, node['node_id']] + self.event_objects = {'ConfFile': [conf_file_id], + 'Node': [node['node_id']]} return 1 diff --git a/PLC/Methods/DeleteConfFileFromNodeGroup.py b/PLC/Methods/DeleteConfFileFromNodeGroup.py index 1b4e8909..5504b0fc 100644 --- a/PLC/Methods/DeleteConfFileFromNodeGroup.py +++ b/PLC/Methods/DeleteConfFileFromNodeGroup.py @@ -43,6 +43,7 @@ class DeleteConfFileFromNodeGroup(Method): conf_file.remove_nodegroup(nodegroup) # Log affected objects - self.object_ids = [conf_file_id, nodegroup['nodegroup_id']] + self.event_objects = {'ConfFile': [conf_file_id], + 'NodeGroup': [nodegroup['nodegroup_id']]} return 1 diff --git a/PLC/Methods/DeleteKey.py b/PLC/Methods/DeleteKey.py index 313c2a42..86c16a50 100644 --- a/PLC/Methods/DeleteKey.py +++ b/PLC/Methods/DeleteKey.py @@ -40,7 +40,7 @@ class DeleteKey(Method): key.delete() # Logging variables - self.object_ids = [key['key_id']] + self.event_objects = {'Key': [key['key_id']]} self.message = 'Key %d deleted' % key['key_id'] return 1 diff --git a/PLC/Methods/DeleteMessage.py b/PLC/Methods/DeleteMessage.py index 7a6713d6..49899421 100644 --- a/PLC/Methods/DeleteMessage.py +++ b/PLC/Methods/DeleteMessage.py @@ -29,6 +29,6 @@ class DeleteMessage(Method): message = messages[0] message.delete() - self.object_ids = [message['message_id']] + self.event_objects = {'Message': [message['message_id']]} return 1 diff --git a/PLC/Methods/DeleteNode.py b/PLC/Methods/DeleteNode.py index d0bf3a51..bc92718c 100644 --- a/PLC/Methods/DeleteNode.py +++ b/PLC/Methods/DeleteNode.py @@ -24,9 +24,6 @@ class DeleteNode(Method): returns = Parameter(int, '1 if successful') - object_type = 'Node' - - def call(self, auth, node_id_or_hostname): # Get account information nodes = Nodes(self.api, [node_id_or_hostname]) @@ -49,7 +46,7 @@ class DeleteNode(Method): node.delete() # Logging variables - self.object_ids = [node['node_id']] + self.event_objects = {'Node': [node['node_id']]} self.message = "Node %d deleted" % node['node_id'] return 1 diff --git a/PLC/Methods/DeleteNodeFromNodeGroup.py b/PLC/Methods/DeleteNodeFromNodeGroup.py index 0cd41a5e..2bc67704 100644 --- a/PLC/Methods/DeleteNodeFromNodeGroup.py +++ b/PLC/Methods/DeleteNodeFromNodeGroup.py @@ -45,7 +45,8 @@ class DeleteNodeFromNodeGroup(Method): nodegroup.remove_node(node) # Logging variables - self.object_ids = [nodegroup['nodegroup_id']] + self.event_objects = {'NodeGroup': [nodegroup['nodegroup_id']], + 'Node': [node['node_id']]} self.message = 'node %d deleted from node group %d' % \ (node['node_id'], nodegroup['nodegroup_id']) diff --git a/PLC/Methods/DeleteNodeFromPCU.py b/PLC/Methods/DeleteNodeFromPCU.py index cf7f93f9..d2682986 100644 --- a/PLC/Methods/DeleteNodeFromPCU.py +++ b/PLC/Methods/DeleteNodeFromPCU.py @@ -25,9 +25,6 @@ class DeleteNodeFromPCU(Method): returns = Parameter(int, '1 if successful') - object_type = 'Node' - - def call(self, auth, node_id_or_hostname, pcu_id): # Get node nodes = Nodes(self.api, [node_id_or_hostname]) @@ -59,7 +56,8 @@ class DeleteNodeFromPCU(Method): pcu.remove_node(node) # Logging variables - self.object_ids = [pcu['pcu_id']] + self.event_objects = {'PCU': [pcu['pcu_id']], + 'Node': [node['node_id']]} self.message = 'Node %d removed from PCU %d' % \ (node['node_id'], pcu['pcu_id']) diff --git a/PLC/Methods/DeleteNodeGroup.py b/PLC/Methods/DeleteNodeGroup.py index 76066075..76501504 100644 --- a/PLC/Methods/DeleteNodeGroup.py +++ b/PLC/Methods/DeleteNodeGroup.py @@ -35,7 +35,7 @@ class DeleteNodeGroup(Method): nodegroup.delete() # Logging variables - self.object_ids = [nodegroup['nodegroup_id']] + self.event_objects = {'NodeGroup': [nodegroup['nodegroup_id']]} self.message = 'Node group %d deleted' % nodegroup['nodegroup_id'] return 1 diff --git a/PLC/Methods/DeleteNodeNetwork.py b/PLC/Methods/DeleteNodeNetwork.py index 6cba6a68..4bdda21c 100644 --- a/PLC/Methods/DeleteNodeNetwork.py +++ b/PLC/Methods/DeleteNodeNetwork.py @@ -51,7 +51,7 @@ class DeleteNodeNetwork(Method): nodenetwork.delete() # Logging variables - self.object_ids = [nodenetwork['nodenetwork_id']] + self.event_objects = {'NodeNetwork': [nodenetwork['nodenetwork_id']]} self.message = "Node network %d deleted" % nodenetwork['nodenetwork_id'] return 1 diff --git a/PLC/Methods/DeletePCU.py b/PLC/Methods/DeletePCU.py index 0d7a09ae..944882bc 100644 --- a/PLC/Methods/DeletePCU.py +++ b/PLC/Methods/DeletePCU.py @@ -37,7 +37,7 @@ class DeletePCU(Method): pcu.delete() # Logging variables - self.object_ids = [pcu['pcu_id']] + self.event_objects = {'PCU': [pcu['pcu_id']]} self.message = 'PCU %d deleted' % pcu['pcu_id'] return 1 diff --git a/PLC/Methods/DeletePeer.py b/PLC/Methods/DeletePeer.py index dcc19130..4260d259 100644 --- a/PLC/Methods/DeletePeer.py +++ b/PLC/Methods/DeletePeer.py @@ -33,6 +33,6 @@ class DeletePeer(Method): peer.delete() # Log affected objects - self.object_ids = [peer['peer_id']] + self.event_objects = {'Peer': [peer['peer_id']]} return 1 diff --git a/PLC/Methods/DeletePerson.py b/PLC/Methods/DeletePerson.py index dcb2e52d..448f8085 100644 --- a/PLC/Methods/DeletePerson.py +++ b/PLC/Methods/DeletePerson.py @@ -25,9 +25,6 @@ class DeletePerson(Method): returns = Parameter(int, '1 if successful') - object_type = 'Person' - - def call(self, auth, person_id_or_email): # Get account information persons = Persons(self.api, [person_id_or_email]) @@ -48,7 +45,7 @@ class DeletePerson(Method): person.delete() # Logging variables - self.object_ids = [person['person_id']] + self.event_objects = {'Person': [person['person_id']]} self.message = 'Person %d deleted' % person['person_id'] return 1 diff --git a/PLC/Methods/DeletePersonFromSite.py b/PLC/Methods/DeletePersonFromSite.py index 0b7280cd..db2af2df 100644 --- a/PLC/Methods/DeletePersonFromSite.py +++ b/PLC/Methods/DeletePersonFromSite.py @@ -26,9 +26,6 @@ class DeletePersonFromSite(Method): returns = Parameter(int, '1 if successful') - object_type = 'Site' - - def call(self, auth, person_id_or_email, site_id_or_login_base): # Get account information persons = Persons(self.api, [person_id_or_email]) @@ -52,7 +49,8 @@ class DeletePersonFromSite(Method): site.remove_person(person) # Logging variables - self.object_ids = [site['site_id']] + self.event_objects = {'Site': [site['site_id']], + 'Person': [person['person_id']]} self.message = 'Person %d deleted from site %d ' % \ (person['person_id'], site['site_id']) return 1 diff --git a/PLC/Methods/DeletePersonFromSlice.py b/PLC/Methods/DeletePersonFromSlice.py index 9bab6abd..c990ccd3 100644 --- a/PLC/Methods/DeletePersonFromSlice.py +++ b/PLC/Methods/DeletePersonFromSlice.py @@ -25,9 +25,6 @@ class DeletePersonFromSlice(Method): returns = Parameter(int, '1 if successful') - object_type = 'Slice' - - def call(self, auth, person_id_or_email, slice_id_or_name): # Get account information persons = Persons(self.api, [person_id_or_email]) @@ -56,6 +53,7 @@ class DeletePersonFromSlice(Method): if slice['slice_id'] in person['slice_ids']: slice.remove_person(person) - self.object_ids = [slice['slice_id']] + self.event_objects = {'Slice': [slice['slice_id']], + 'Person': [person['person_id']]} return 1 diff --git a/PLC/Methods/DeleteRole.py b/PLC/Methods/DeleteRole.py index e254a130..f7072809 100644 --- a/PLC/Methods/DeleteRole.py +++ b/PLC/Methods/DeleteRole.py @@ -33,6 +33,6 @@ class DeleteRole(Method): role = roles[0] role.delete() - self.object_ids = [role['role_id']] + self.event_objects = {'Role': [role['role_id']]} return 1 diff --git a/PLC/Methods/DeleteRoleFromPerson.py b/PLC/Methods/DeleteRoleFromPerson.py index 439857f9..151ba258 100644 --- a/PLC/Methods/DeleteRoleFromPerson.py +++ b/PLC/Methods/DeleteRoleFromPerson.py @@ -27,9 +27,6 @@ class DeleteRoleFromPerson(Method): returns = Parameter(int, '1 if successful') - object_type = 'Person' - - def call(self, auth, role_id_or_name, person_id_or_email): # Get role roles = Roles(self.api, [role_id_or_name]) @@ -62,7 +59,8 @@ class DeleteRoleFromPerson(Method): person.remove_role(role) # Logging variables - self.object_ids = [person['person_id']] + self.event_objects = {'Person': [person['person_id']], + 'Role': [role['role_id']]} self.message = "Role %d revoked from person %d" % \ (role['role_id'], person['person_id']) diff --git a/PLC/Methods/DeleteSite.py b/PLC/Methods/DeleteSite.py index af5dedd9..c23fff45 100644 --- a/PLC/Methods/DeleteSite.py +++ b/PLC/Methods/DeleteSite.py @@ -27,9 +27,6 @@ class DeleteSite(Method): returns = Parameter(int, '1 if successful') - object_type = 'Site' - - def call(self, auth, site_id_or_login_base): # Get account information sites = Sites(self.api, [site_id_or_login_base]) @@ -43,7 +40,7 @@ class DeleteSite(Method): site.delete() # Logging variables - self.object_ids = [site['site_id']] + self.event_objects = {'Site': [site['site_id']]} self.message = 'Site %d deleted' % site['site_id'] return 1 diff --git a/PLC/Methods/DeleteSlice.py b/PLC/Methods/DeleteSlice.py index 7011de80..297f8a94 100644 --- a/PLC/Methods/DeleteSlice.py +++ b/PLC/Methods/DeleteSlice.py @@ -25,9 +25,6 @@ class DeleteSlice(Method): returns = Parameter(int, '1 if successful') - object_type = 'Slice' - - def call(self, auth, slice_id_or_name): slices = Slices(self.api, [slice_id_or_name]) if not slices: @@ -46,6 +43,6 @@ class DeleteSlice(Method): raise PLCPermissionDenied, "Specified slice not associated with any of your sites" slice.delete() - self.object_ids = [slice['slice_id']] + self.event_objects = {'Slice': [slice['slice_id']]} return 1 diff --git a/PLC/Methods/DeleteSliceAttribute.py b/PLC/Methods/DeleteSliceAttribute.py index ea3ecb20..871e2416 100644 --- a/PLC/Methods/DeleteSliceAttribute.py +++ b/PLC/Methods/DeleteSliceAttribute.py @@ -28,9 +28,6 @@ class DeleteSliceAttribute(Method): returns = Parameter(int, '1 if successful') - object_type = 'Slice' - - def call(self, auth, slice_attribute_id): slice_attributes = SliceAttributes(self.api, [slice_attribute_id]) if not slice_attributes: @@ -60,6 +57,6 @@ class DeleteSliceAttribute(Method): raise PLCPermissioinDenied, "Not allowed to delete the specified attribute" slice_attribute.delete() - self.object_ids = [slice_attribute['slice_attribute_id']] + self.event_objects = {'SliceAttribute': [slice_attribute['slice_attribute_id']]} return 1 diff --git a/PLC/Methods/DeleteSliceAttributeType.py b/PLC/Methods/DeleteSliceAttributeType.py index 922b6acc..e6c1a8a7 100644 --- a/PLC/Methods/DeleteSliceAttributeType.py +++ b/PLC/Methods/DeleteSliceAttributeType.py @@ -29,6 +29,6 @@ class DeleteSliceAttributeType(Method): attribute_type = attribute_types[0] attribute_type.delete() - self.object_ids = [attribute_type['attribute_type_id']] + self.event_objects = {'AttributeType': [attribute_type['attribute_type_id']]} return 1 diff --git a/PLC/Methods/DeleteSliceFromNodes.py b/PLC/Methods/DeleteSliceFromNodes.py index 87e2e07c..b2705d5b 100644 --- a/PLC/Methods/DeleteSliceFromNodes.py +++ b/PLC/Methods/DeleteSliceFromNodes.py @@ -25,9 +25,6 @@ class DeleteSliceFromNodes(Method): returns = Parameter(int, '1 if successful') - object_type = 'Node' - - def call(self, auth, slice_id_or_name, node_id_or_hostname_list): # Get slice information slices = Slices(self.api, [slice_id_or_name]) @@ -56,6 +53,7 @@ class DeleteSliceFromNodes(Method): slice.sync() - self.object_ids = [node['node_id'] for node in nodes] + self.event_objects = {'Node': [node['node_id'] for node in nodes], + 'Slice': [slice['slice_id']]} return 1 diff --git a/PLC/Methods/NotifyPersons.py b/PLC/Methods/NotifyPersons.py index b8c0979f..70c273d6 100644 --- a/PLC/Methods/NotifyPersons.py +++ b/PLC/Methods/NotifyPersons.py @@ -42,8 +42,7 @@ class NotifyPersons(Method): Body = body) # Logging variables - self.object_type = "Person" - self.object_ids = [person['person_id'] for person in persons] + self.event_objects = {'Person': [person['person_id'] for person in persons]} self.message = subject return 1 diff --git a/PLC/Methods/RebootNode.py b/PLC/Methods/RebootNode.py index bffa3dab..bea6b894 100644 --- a/PLC/Methods/RebootNode.py +++ b/PLC/Methods/RebootNode.py @@ -30,8 +30,6 @@ class RebootNode(Method): returns = Parameter(int, '1 if successful') - object_type = 'Node' - def call(self, auth, node_id_or_hostname): # Get account information nodes = Nodes(self.api, [node_id_or_hostname]) @@ -69,6 +67,7 @@ class RebootNode(Method): # Ignore socket errors pass + self.event_objects = {'Node': [node['node_id']]} self.message = "RebootNode called" return 1 diff --git a/PLC/Methods/ResetPassword.py b/PLC/Methods/ResetPassword.py index 43ee8ba1..367b7c88 100644 --- a/PLC/Methods/ResetPassword.py +++ b/PLC/Methods/ResetPassword.py @@ -39,8 +39,6 @@ class ResetPassword(Method): returns = Parameter(int, '1 if verification_key is valid') - object_type = 'Person' - def call(self, auth, person_id_or_email, verification_key = None, verification_expires = None): # Get account information persons = Persons(self.api, [person_id_or_email]) @@ -116,7 +114,7 @@ class ResetPassword(Method): print >> log, "Warning: No message template '%s'" % message_id # Logging variables - self.object_ids = [person['person_id']] + self.event_objects = {'Person': [person['person_id']]} self.message = message_id return 1 diff --git a/PLC/Methods/SliceCreate.py b/PLC/Methods/SliceCreate.py index 668f46d7..cc30b520 100644 --- a/PLC/Methods/SliceCreate.py +++ b/PLC/Methods/SliceCreate.py @@ -20,8 +20,6 @@ class SliceCreate(AddSlice): returns = Parameter(int, 'New slice_id (> 0) if successful') - object_type = 'Slice' - def call(self, auth, name, slice_fields = {}): slice_fields['name'] = name return AddSlice.call(self, auth, slice_fields) diff --git a/PLC/Methods/SliceDelete.py b/PLC/Methods/SliceDelete.py index 75eef3f5..70f6696d 100644 --- a/PLC/Methods/SliceDelete.py +++ b/PLC/Methods/SliceDelete.py @@ -24,9 +24,6 @@ class SliceDelete(DeleteSlice): returns = Parameter(int, 'Returns 1 if successful, a fault otherwise.') - object_type = 'Slice' - - def call(self, auth, slice_name): return DeleteSlice.call(self, auth, slice_name) diff --git a/PLC/Methods/SliceNodesAdd.py b/PLC/Methods/SliceNodesAdd.py index 547bd5c7..35ccabef 100644 --- a/PLC/Methods/SliceNodesAdd.py +++ b/PLC/Methods/SliceNodesAdd.py @@ -24,11 +24,6 @@ class SliceNodesAdd(AddSliceToNodes): returns = Parameter(int, '1 if successful') - object_type = 'Slice' - - - - def call(self, auth, slice_name, nodes_list): return AddSliceToNodes.call(self, auth, slice_name, nodes_list) diff --git a/PLC/Methods/SliceNodesDel.py b/PLC/Methods/SliceNodesDel.py index 513c9437..66c0ed23 100644 --- a/PLC/Methods/SliceNodesDel.py +++ b/PLC/Methods/SliceNodesDel.py @@ -24,11 +24,6 @@ class SliceNodesDel(DeleteSliceFromNodes): returns = Parameter(int, '1 if successful') - object_type = 'Slice' - - - - def call(self, auth, slice_name, nodes_list): return DeleteSliceFromNodes.call(self, auth, slice_name, nodes_list) diff --git a/PLC/Methods/SliceRenew.py b/PLC/Methods/SliceRenew.py index 44f0e520..4ac6f895 100644 --- a/PLC/Methods/SliceRenew.py +++ b/PLC/Methods/SliceRenew.py @@ -25,8 +25,6 @@ class SliceRenew(UpdateSlice): returns = Parameter(int, '1 if successful') - object_type = 'Slice' - def call(self, auth, slice_name, slice_expires): slice_fields = {} diff --git a/PLC/Methods/SliceUpdate.py b/PLC/Methods/SliceUpdate.py index 2f53ad02..9e82d3ad 100644 --- a/PLC/Methods/SliceUpdate.py +++ b/PLC/Methods/SliceUpdate.py @@ -26,8 +26,6 @@ class SliceUpdate(UpdateSlice): returns = Parameter(int, '1 if successful') - object_type = 'Slice' - def call(self, auth, slice_name, url, description): slice_fields = {} diff --git a/PLC/Methods/SliceUserAdd.py b/PLC/Methods/SliceUserAdd.py index cee64c12..560a66a5 100644 --- a/PLC/Methods/SliceUserAdd.py +++ b/PLC/Methods/SliceUserAdd.py @@ -24,8 +24,6 @@ class SliceUserAdd(AddPersonToSlice): returns = Parameter(int, '1 if successful') - object_type = 'Slice' - def call(self, auth, slice_name, user_list): for user in user_list: diff --git a/PLC/Methods/SliceUserDel.py b/PLC/Methods/SliceUserDel.py index 15295f29..0b41b158 100644 --- a/PLC/Methods/SliceUserDel.py +++ b/PLC/Methods/SliceUserDel.py @@ -28,8 +28,6 @@ class SliceUserDel(Method): returns = Parameter(int, '1 if successful') - object_type = 'Slice' - def call(self, auth, slice_name, user_list): for user in user_list: DeletePersonFromSlice.call(self, auth, user, slice_name)