From: Tony Mack Date: Tue, 27 Feb 2007 19:10:16 +0000 (+0000) Subject: - now using event_objects to log affected objects X-Git-Tag: PLCAPI-4.2-0~168 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;ds=sidebyside;h=9db56cccde6cc7e7095c90702e30026e13feaa71;p=plcapi.git - now using event_objects to log affected objects --- diff --git a/PLC/Methods/AddAddressType.py b/PLC/Methods/AddAddressType.py index 0dcc66d..9fc771b 100644 --- a/PLC/Methods/AddAddressType.py +++ b/PLC/Methods/AddAddressType.py @@ -31,6 +31,6 @@ class AddAddressType(Method): address_type = AddressType(self.api, address_type_fields) address_type.sync() - self.object_ids = [address_type['address_type_id']] + self.event_objects = {'AddressType' : [address_type['address_type_id']]} return address_type['address_type_id'] diff --git a/PLC/Methods/AddAddressTypeToAddress.py b/PLC/Methods/AddAddressTypeToAddress.py index b4cf700..d69e627 100644 --- a/PLC/Methods/AddAddressTypeToAddress.py +++ b/PLC/Methods/AddAddressTypeToAddress.py @@ -42,6 +42,6 @@ class AddAddressTypeToAddress(Method): raise PLCPermissionDenied, "Address must be associated with one of your sites" address.add_address_type(address_type) - self.object_ids = [address['address_id']] + self.event_objects = {'Address': [address['address_id']]} return 1 diff --git a/PLC/Methods/AddConfFile.py b/PLC/Methods/AddConfFile.py index 5cc0828..5604cef 100644 --- a/PLC/Methods/AddConfFile.py +++ b/PLC/Methods/AddConfFile.py @@ -32,6 +32,6 @@ class AddConfFile(Method): conf_file = ConfFile(self.api, conf_file_fields) conf_file.sync() - self.object_ids = [conf_file['conf_file_id']] + self.event_objects = {'ConfFile': [conf_file['conf_file_id']]} return conf_file['conf_file_id'] diff --git a/PLC/Methods/AddConfFileToNode.py b/PLC/Methods/AddConfFileToNode.py index 4290cf8..2d1542c 100644 --- a/PLC/Methods/AddConfFileToNode.py +++ b/PLC/Methods/AddConfFileToNode.py @@ -24,9 +24,6 @@ class AddConfFileToNode(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]) @@ -48,6 +45,7 @@ class AddConfFileToNode(Method): conf_file.add_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/AddConfFileToNodeGroup.py b/PLC/Methods/AddConfFileToNodeGroup.py index 9212f70..6ff642c 100644 --- a/PLC/Methods/AddConfFileToNodeGroup.py +++ b/PLC/Methods/AddConfFileToNodeGroup.py @@ -44,6 +44,7 @@ class AddConfFileToNodeGroup(Method): conf_file.add_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/AddNode.py b/PLC/Methods/AddNode.py index e355dca..8d253df 100644 --- a/PLC/Methods/AddNode.py +++ b/PLC/Methods/AddNode.py @@ -33,9 +33,6 @@ class AddNode(Method): returns = Parameter(int, 'New node_id (> 0) if successful') - object_type = 'Node' - - def call(self, auth, site_id_or_login_base, node_fields): node_fields = dict(filter(can_update, node_fields.items())) @@ -62,7 +59,8 @@ class AddNode(Method): node['site_id'] = site['site_id'] node.sync() - self.object_ids = [site['site_id'], node['node_id']] + self.event_objects = {'Site': [site['site_id']], + 'Node': [node['node_id']]} self.message = "Node %s created" % node['node_id'] return node['node_id'] diff --git a/PLC/Methods/AddNodeGroup.py b/PLC/Methods/AddNodeGroup.py index bdde7fe..34f5f97 100644 --- a/PLC/Methods/AddNodeGroup.py +++ b/PLC/Methods/AddNodeGroup.py @@ -33,7 +33,7 @@ class AddNodeGroup(Method): nodegroup.sync() # Logging variables - self.object_ids = [nodegroup['nodegroup_id']] + self.event_objects = {'NodeGroup': [nodegroup['nodegroup_id']]} self.message = 'Node group %d created' % nodegroup['nodegroup_id'] return nodegroup['nodegroup_id'] diff --git a/PLC/Methods/AddNodeToNodeGroup.py b/PLC/Methods/AddNodeToNodeGroup.py index 6829daf..a552b11 100644 --- a/PLC/Methods/AddNodeToNodeGroup.py +++ b/PLC/Methods/AddNodeToNodeGroup.py @@ -48,7 +48,8 @@ class AddNodeToNodeGroup(Method): nodegroup.add_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 added to node group %d' % \ (node['node_id'], nodegroup['nodegroup_id']) return 1 diff --git a/PLC/Methods/AddNodeToPCU.py b/PLC/Methods/AddNodeToPCU.py index f1c1961..2da5cd6 100644 --- a/PLC/Methods/AddNodeToPCU.py +++ b/PLC/Methods/AddNodeToPCU.py @@ -27,8 +27,6 @@ class AddNodeToPCU(Method): returns = Parameter(int, '1 if successful') - object_type = 'Node' - def call(self, auth, node_id_or_hostname, pcu_id, port): # Get node nodes = Nodes(self.api, [node_id_or_hostname]) @@ -68,7 +66,8 @@ class AddNodeToPCU(Method): pcu.add_node(node, port) # Logging variables - self.object_ids = [node['node_id'], pcu['pcu_id']] + self.event_objects = {'Node': [node['node_id']], + 'PCU': [pcu['pcu_id']]} self.message = 'Node %d added to pcu %d on port %d' % \ (node['node_id'], pcu['pcu_id'], port) return 1 diff --git a/PLC/Methods/AddPCU.py b/PLC/Methods/AddPCU.py index 2d5b034..3c46194 100644 --- a/PLC/Methods/AddPCU.py +++ b/PLC/Methods/AddPCU.py @@ -53,7 +53,8 @@ class AddPCU(Method): pcu.sync() # Logging variables - self.object_ids = [site['site_id'], pcu['pcu_id']] + self.event_objects = {'Site': [site['site_id']], + 'PCU': [pcu['pcu_id']]} self.message = 'PCU %d added site %s' % \ (pcu['pcu_id'], site['site_id']) diff --git a/PLC/Methods/AddPeer.py b/PLC/Methods/AddPeer.py index d0ee32f..d6dc576 100644 --- a/PLC/Methods/AddPeer.py +++ b/PLC/Methods/AddPeer.py @@ -31,4 +31,6 @@ class AddPeer(Method): def call(self, auth, peer_fields): peer = Peer(self.api, peer_fields); peer.sync() + self.event_objects = {'Peer': [peer['peer_id']]} + return peer['peer_id'] diff --git a/PLC/Methods/AddPerson.py b/PLC/Methods/AddPerson.py index bd634cb..cb0aa71 100644 --- a/PLC/Methods/AddPerson.py +++ b/PLC/Methods/AddPerson.py @@ -30,9 +30,6 @@ class AddPerson(Method): returns = Parameter(int, 'New person_id (> 0) if successful') - object_type = 'Person' - - def call(self, auth, person_fields): person_fields = dict(filter(can_update, person_fields.items())) person_fields['enabled'] = False @@ -40,7 +37,7 @@ class AddPerson(Method): person.sync() # Logging variables - self.object_ids = [person['person_id']] + self.event_objects = {'Person': [person['person_id']]} self.message = 'Person %d added' % person['person_id'] return person['person_id'] diff --git a/PLC/Methods/AddPersonKey.py b/PLC/Methods/AddPersonKey.py index 3c7fc97..aa4ed00 100644 --- a/PLC/Methods/AddPersonKey.py +++ b/PLC/Methods/AddPersonKey.py @@ -29,9 +29,6 @@ class AddPersonKey(Method): returns = Parameter(int, 'New key_id (> 0) if successful') - object_type = 'Person' - - def call(self, auth, person_id_or_email, key_fields): key_fields = dict(filter(can_update, key_fields.items())) @@ -54,7 +51,8 @@ class AddPersonKey(Method): person.add_key(key, commit = True) # Logging variables - self.object_ids = [person['person_id'], key['key_id']] + self.event_objects = {'Person': [person['person_id']], + 'Key': [key['key_id']]} self.message = 'Key %d added to person %d' % \ (key['key_id'], person['person_id']) diff --git a/PLC/Methods/AddPersonToSite.py b/PLC/Methods/AddPersonToSite.py index 391a39a..7d5ac10 100644 --- a/PLC/Methods/AddPersonToSite.py +++ b/PLC/Methods/AddPersonToSite.py @@ -26,8 +26,6 @@ class AddPersonToSite(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]) @@ -51,7 +49,8 @@ class AddPersonToSite(Method): site.add_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 added to site %d' % \ (person['person_id'], site['site_id']) return 1 diff --git a/PLC/Methods/AddPersonToSlice.py b/PLC/Methods/AddPersonToSlice.py index e9c0016..e3392eb 100644 --- a/PLC/Methods/AddPersonToSlice.py +++ b/PLC/Methods/AddPersonToSlice.py @@ -25,8 +25,6 @@ class AddPersonToSlice(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 +54,8 @@ class AddPersonToSlice(Method): slice.add_person(person) # Logging variables + self.event_objects = {'Person': [person['person_id']], + 'Slice': [slice['slice_id']]} self.object_ids = [slice['slice_id']] return 1 diff --git a/PLC/Methods/AddRole.py b/PLC/Methods/AddRole.py index bed028a..7266180 100644 --- a/PLC/Methods/AddRole.py +++ b/PLC/Methods/AddRole.py @@ -27,6 +27,6 @@ class AddRole(Method): role['role_id'] = role_id role['name'] = name role.sync(insert = True) - self.object_ids = [role['role_id']] + self.event_objects = {'Role': [role['role_id']]} return 1 diff --git a/PLC/Methods/AddRoleToPerson.py b/PLC/Methods/AddRoleToPerson.py index b90f1f9..5a8e241 100644 --- a/PLC/Methods/AddRoleToPerson.py +++ b/PLC/Methods/AddRoleToPerson.py @@ -27,9 +27,6 @@ class AddRoleToPerson(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]) @@ -61,7 +58,8 @@ class AddRoleToPerson(Method): if role['role_id'] not in person['role_ids']: person.add_role(role) - self.object_ids = [person['person_id']] + self.event_objects = {'Person': [person['person_id']], + 'Role': [role['role_id']]} self.message = "Role %d granted to person %d" % \ (role['role_id'], person['person_id']) diff --git a/PLC/Methods/AddSite.py b/PLC/Methods/AddSite.py index a37a7f0..475c8b1 100644 --- a/PLC/Methods/AddSite.py +++ b/PLC/Methods/AddSite.py @@ -29,16 +29,13 @@ class AddSite(Method): returns = Parameter(int, 'New site_id (> 0) if successful') - object_type = 'Site' - - def call(self, auth, site_fields): site_fields = dict(filter(can_update, site_fields.items())) site = Site(self.api, site_fields) site.sync() # Logging variables - self.object_ids = [site['site_id']] + self.event_objects = {'Site': [site['site_id']]} self.message = 'Site %d created' % site['site_id'] return site['site_id'] diff --git a/PLC/Methods/AddSiteAddress.py b/PLC/Methods/AddSiteAddress.py index 42fc027..a3a4eff 100644 --- a/PLC/Methods/AddSiteAddress.py +++ b/PLC/Methods/AddSiteAddress.py @@ -32,9 +32,6 @@ class AddSiteAddress(Method): returns = Parameter(int, 'New address_id (> 0) if successful') - object_type = 'Site' - - def call(self, auth, site_id_or_login_base, address_fields): address_fields = dict(filter(can_update, address_fields.items())) @@ -53,7 +50,8 @@ class AddSiteAddress(Method): site.add_address(address, commit = True) # Logging variables - self.object_ids = [site['site_id'], address['address_id']] + self.event_objects = {'Site': [site['site_id']], + 'Address': [address['address_id']]} self.message = 'Address %d assigned to Site %d' % \ (address['address_id'], site['site_id']) diff --git a/PLC/Methods/AddSlice.py b/PLC/Methods/AddSlice.py index 683931c..cbb0d85 100644 --- a/PLC/Methods/AddSlice.py +++ b/PLC/Methods/AddSlice.py @@ -38,9 +38,6 @@ class AddSlice(Method): returns = Parameter(int, 'New slice_id (> 0) if successful') - object_type = 'Slice' - - def call(self, auth, slice_fields): slice_fields = dict(filter(can_update, slice_fields.items())) @@ -75,6 +72,6 @@ class AddSlice(Method): slice['site_id'] = site['site_id'] slice.sync() - self.object_ids = [slice['slice_id']] + self.event_objects = {'Slice': [slice['slice_id']]} return slice['slice_id'] diff --git a/PLC/Methods/AddSliceAttribute.py b/PLC/Methods/AddSliceAttribute.py index 2a95505..83acef0 100644 --- a/PLC/Methods/AddSliceAttribute.py +++ b/PLC/Methods/AddSliceAttribute.py @@ -37,9 +37,6 @@ class AddSliceAttribute(Method): returns = Parameter(int, 'New slice_attribute_id (> 0) if successful') - object_type = 'Slice' - - def call(self, auth, slice_id_or_name, attribute_type_id_or_name, value, node_id_or_hostname = None): slices = Slices(self.api, [slice_id_or_name]) if not slices: @@ -81,6 +78,6 @@ class AddSliceAttribute(Method): slice_attribute['node_id'] = node['node_id'] slice_attribute.sync() - self.object_ids = [slice_attribute['slice_attribute_id']] + self.event_objects = {'SliceAttribute': [slice_attribute['slice_attribute_id']]} return slice_attribute['slice_attribute_id'] diff --git a/PLC/Methods/AddSliceAttributeType.py b/PLC/Methods/AddSliceAttributeType.py index aec8930..095ae83 100644 --- a/PLC/Methods/AddSliceAttributeType.py +++ b/PLC/Methods/AddSliceAttributeType.py @@ -33,6 +33,6 @@ class AddSliceAttributeType(Method): attribute_type = SliceAttributeType(self.api, attribute_type_fields) attribute_type.sync() - self.object_ids = [attribute_type['attribute_type_id']] + self.event_objects = {'AttributeType': [attribute_type['attribute_type_id']]} return attribute_type['attribute_type_id'] diff --git a/PLC/Methods/AddSliceToNodes.py b/PLC/Methods/AddSliceToNodes.py index c57cfb2..e5a60f9 100644 --- a/PLC/Methods/AddSliceToNodes.py +++ b/PLC/Methods/AddSliceToNodes.py @@ -28,9 +28,6 @@ class AddSliceToNodes(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]) @@ -57,6 +54,7 @@ class AddSliceToNodes(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/BlacklistKey.py b/PLC/Methods/BlacklistKey.py index 1c03d6e..7953e7a 100644 --- a/PLC/Methods/BlacklistKey.py +++ b/PLC/Methods/BlacklistKey.py @@ -24,10 +24,6 @@ class BlacklistKey(Method): returns = Parameter(int, '1 if successful') - event_type = 'Update' - object_type = 'Key' - object_ids = [] - def call(self, auth, key_id): # Get associated key details keys = Keys(self.api, [key_id]) @@ -40,7 +36,7 @@ class BlacklistKey(Method): key.blacklist() # Logging variables - self.object_ids = [key['key_id']] + self.event_objects = {'Key': [key['key_id']]} self.message = 'Key %d blacklisted' % key['key_id'] return 1 diff --git a/PLC/Methods/BootUpdateNode.py b/PLC/Methods/BootUpdateNode.py index 5c1762a..271da9f 100644 --- a/PLC/Methods/BootUpdateNode.py +++ b/PLC/Methods/BootUpdateNode.py @@ -30,8 +30,6 @@ class BootUpdateNode(Method): returns = Parameter(int, '1 if successful') - object_type = 'Node' - def call(self, auth, node_fields): # Update node state if node_fields.has_key('boot_state'):