From 3f30de17c58880c0f6f1d64ea573c3fe56e32a38 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Wed, 15 Nov 2006 21:36:04 +0000 Subject: [PATCH] - define/modify logging variables --- PLC/Methods/DeleteAddress.py | 4 ++++ PLC/Methods/DeleteAddressType.py | 5 ++++- PLC/Methods/DeleteAddressTypeFromAddress.py | 4 ++++ PLC/Methods/DeleteBootState.py | 5 ++++- PLC/Methods/DeleteConfFile.py | 4 ++++ PLC/Methods/DeleteConfFileFromNode.py | 1 - PLC/Methods/DeleteConfFileFromNodeGroup.py | 1 - PLC/Methods/DeleteKey.py | 4 ++++ PLC/Methods/DeleteKeyType.py | 5 ++++- PLC/Methods/DeleteMessage.py | 4 ++++ PLC/Methods/DeleteNetworkMethod.py | 3 +++ PLC/Methods/DeleteNetworkType.py | 3 +++ PLC/Methods/DeleteNode.py | 4 ++++ PLC/Methods/DeleteNodeFromNodeGroup.py | 5 +++++ PLC/Methods/DeleteNodeFromPCU.py | 7 ++++++- PLC/Methods/DeleteNodeGroup.py | 4 ++++ PLC/Methods/DeleteNodeNetwork.py | 5 +++++ PLC/Methods/DeletePCU.py | 4 ++++ PLC/Methods/DeletePerson.py | 4 ++++ PLC/Methods/DeletePersonFromSite.py | 5 +++++ PLC/Methods/DeletePersonFromSlice.py | 5 +++++ PLC/Methods/DeleteRole.py | 4 ++++ PLC/Methods/DeleteRoleFromPerson.py | 5 +++++ PLC/Methods/DeleteSession.py | 3 +++ PLC/Methods/DeleteSite.py | 4 ++++ PLC/Methods/DeleteSlice.py | 4 ++++ PLC/Methods/DeleteSliceAttribute.py | 6 +++++- PLC/Methods/DeleteSliceAttributeType.py | 4 ++++ PLC/Methods/DeleteSliceFromNodes.py | 5 +++++ PLC/Methods/DeleteSliceInstantiation.py | 3 +++ 30 files changed, 117 insertions(+), 7 deletions(-) diff --git a/PLC/Methods/DeleteAddress.py b/PLC/Methods/DeleteAddress.py index 99f1f51..24ec758 100644 --- a/PLC/Methods/DeleteAddress.py +++ b/PLC/Methods/DeleteAddress.py @@ -21,6 +21,9 @@ class DeleteAddress(Method): ] returns = Parameter(int, '1 if successful') + + event_type = 'Delete' + object_type = 'Address' def call(self, auth, address_id): # Get associated address details @@ -34,5 +37,6 @@ class DeleteAddress(Method): raise PLCPermissionDenied, "Address must be associated with one of your sites" address.delete() + self.object_ids = [address['address_id']] return 1 diff --git a/PLC/Methods/DeleteAddressType.py b/PLC/Methods/DeleteAddressType.py index 662af3d..e3ed947 100644 --- a/PLC/Methods/DeleteAddressType.py +++ b/PLC/Methods/DeleteAddressType.py @@ -21,12 +21,15 @@ class DeleteAddressType(Method): returns = Parameter(int, '1 if successful') + event_type = 'Delete' + object_type = 'AddressType' + def call(self, auth, address_type_id_or_name): address_types = AddressTypes(self.api, [address_type_id_or_name]) if not address_types: raise PLCInvalidArgument, "No such address type" address_type = address_types[0] - address_type.delete() + self.object_ids = [address_type['address_type_id']] return 1 diff --git a/PLC/Methods/DeleteAddressTypeFromAddress.py b/PLC/Methods/DeleteAddressTypeFromAddress.py index 3078737..9cd279c 100644 --- a/PLC/Methods/DeleteAddressTypeFromAddress.py +++ b/PLC/Methods/DeleteAddressTypeFromAddress.py @@ -24,6 +24,9 @@ class DeleteAddressTypeFromAddress(Method): ] returns = Parameter(int, '1 if successful') + + event_type = 'DeleteFrom' + object_type = 'Address' def call(self, auth, address_type_id_or_name, address_id): address_types = AddressTypes(self.api, [address_type_id_or_name]) @@ -41,5 +44,6 @@ 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']] return 1 diff --git a/PLC/Methods/DeleteBootState.py b/PLC/Methods/DeleteBootState.py index b7bce21..4773d60 100644 --- a/PLC/Methods/DeleteBootState.py +++ b/PLC/Methods/DeleteBootState.py @@ -23,6 +23,9 @@ class DeleteBootState(Method): returns = Parameter(int, '1 if successful') + event_type = 'Delete' + object_type = 'BootState' + def call(self, auth, name): boot_states = BootStates(self.api, [name]) if not boot_states: @@ -30,5 +33,5 @@ class DeleteBootState(Method): boot_state = boot_states[0] boot_state.delete() - + return 1 diff --git a/PLC/Methods/DeleteConfFile.py b/PLC/Methods/DeleteConfFile.py index e36d677..a07964a 100644 --- a/PLC/Methods/DeleteConfFile.py +++ b/PLC/Methods/DeleteConfFile.py @@ -19,6 +19,9 @@ class DeleteConfFile(Method): ] returns = Parameter(int, '1 if successful') + + event_type = 'Delete' + object_type = 'ConfFile' def call(self, auth, conf_file_id): conf_files = ConfFiles(self.api, [conf_file_id]) @@ -27,5 +30,6 @@ class DeleteConfFile(Method): conf_file = conf_files[0] conf_file.delete() + self.object_ids = [conf_file['conf_file_id']] return 1 diff --git a/PLC/Methods/DeleteConfFileFromNode.py b/PLC/Methods/DeleteConfFileFromNode.py index 80985dd..43c3e90 100644 --- a/PLC/Methods/DeleteConfFileFromNode.py +++ b/PLC/Methods/DeleteConfFileFromNode.py @@ -26,7 +26,6 @@ class DeleteConfFileFromNode(Method): event_type = 'DeleteFrom' object_type = 'ConfFile' - object_ids = [] def call(self, auth, conf_file_id, node_id_or_hostname): # Get configuration file diff --git a/PLC/Methods/DeleteConfFileFromNodeGroup.py b/PLC/Methods/DeleteConfFileFromNodeGroup.py index 300d311..2c29309 100644 --- a/PLC/Methods/DeleteConfFileFromNodeGroup.py +++ b/PLC/Methods/DeleteConfFileFromNodeGroup.py @@ -26,7 +26,6 @@ class DeleteConfFileFromNodeGroup(Method): event_type = 'DeleteFrom' object_type = 'ConfFile' - object_ids = [] def call(self, auth, conf_file_id, nodegroup_id_or_name): # Get configuration file diff --git a/PLC/Methods/DeleteKey.py b/PLC/Methods/DeleteKey.py index ae39f31..c137f7c 100644 --- a/PLC/Methods/DeleteKey.py +++ b/PLC/Methods/DeleteKey.py @@ -22,6 +22,9 @@ class DeleteKey(Method): returns = Parameter(int, '1 if successful') + event_type = 'Delete' + object_type = 'Key' + def call(self, auth, key_id): # Get associated key details keys = Keys(self.api, [key_id]) @@ -34,5 +37,6 @@ class DeleteKey(Method): raise PLCPermissionDenied, "Key must be associated with your account" key.delete() + self.object_ids = [key['key_id']] return 1 diff --git a/PLC/Methods/DeleteKeyType.py b/PLC/Methods/DeleteKeyType.py index dc05655..2554cb0 100644 --- a/PLC/Methods/DeleteKeyType.py +++ b/PLC/Methods/DeleteKeyType.py @@ -21,7 +21,10 @@ class DeleteKeyType(Method): ] returns = Parameter(int, '1 if successful') - + + event_type = 'Delete' + object_type = 'KeyType' + def call(self, auth, name): key_types = KeyTypes(self.api, [name]) if not key_types: diff --git a/PLC/Methods/DeleteMessage.py b/PLC/Methods/DeleteMessage.py index 82fbbaf..fc7e2d0 100644 --- a/PLC/Methods/DeleteMessage.py +++ b/PLC/Methods/DeleteMessage.py @@ -19,6 +19,9 @@ class DeleteMessage(Method): ] returns = Parameter(int, '1 if successful') + + event_type = 'Delete' + object_type = 'Message' def call(self, auth, message_id): # Get message information @@ -28,5 +31,6 @@ class DeleteMessage(Method): message = messages[0] message.delete() + self.object_ids = [message['message_id']] return 1 diff --git a/PLC/Methods/DeleteNetworkMethod.py b/PLC/Methods/DeleteNetworkMethod.py index aa9e273..c31c181 100644 --- a/PLC/Methods/DeleteNetworkMethod.py +++ b/PLC/Methods/DeleteNetworkMethod.py @@ -22,6 +22,9 @@ class DeleteNetworkMethod(Method): ] returns = Parameter(int, '1 if successful') + + event_type = 'Delete' + object_type = 'NetworkMethod' def call(self, auth, name): network_methods = NetworkMethods(self.api, [name]) diff --git a/PLC/Methods/DeleteNetworkType.py b/PLC/Methods/DeleteNetworkType.py index c84735f..2fa3c9a 100644 --- a/PLC/Methods/DeleteNetworkType.py +++ b/PLC/Methods/DeleteNetworkType.py @@ -22,6 +22,9 @@ class DeleteNetworkType(Method): ] returns = Parameter(int, '1 if successful') + + event_type = 'Delete' + object_type = 'NetworkType' def call(self, auth, name): network_types = NetworkTypes(self.api, [name]) diff --git a/PLC/Methods/DeleteNode.py b/PLC/Methods/DeleteNode.py index c4a2812..c6023c5 100644 --- a/PLC/Methods/DeleteNode.py +++ b/PLC/Methods/DeleteNode.py @@ -24,6 +24,9 @@ class DeleteNode(Method): returns = Parameter(int, '1 if successful') + event_type = 'Delete' + object_type = 'Node' + def call(self, auth, node_id_or_hostname): # Get account information nodes = Nodes(self.api, [node_id_or_hostname]) @@ -42,5 +45,6 @@ class DeleteNode(Method): raise PLCPermissionDenied, "Not allowed to delete nodes from specified site" node.delete() + self.object_ids = [node['node_id']] return 1 diff --git a/PLC/Methods/DeleteNodeFromNodeGroup.py b/PLC/Methods/DeleteNodeFromNodeGroup.py index 380c2cc..dc289fa 100644 --- a/PLC/Methods/DeleteNodeFromNodeGroup.py +++ b/PLC/Methods/DeleteNodeFromNodeGroup.py @@ -24,6 +24,9 @@ class DeleteNodeFromNodeGroup(Method): returns = Parameter(int, '1 if successful') + event_type = 'DeleteFrom' + object_type = 'NodeGroup' + def call(self, auth, node_id_or_hostname, nodegroup_id_or_name): # Get node info nodes = Nodes(self.api, [node_id_or_hostname]) @@ -42,5 +45,7 @@ class DeleteNodeFromNodeGroup(Method): # Remove node from nodegroup if node['node_id'] in nodegroup['node_ids']: nodegroup.remove_node(node) + + self.object_ids = [nodegroup['nodegroup_id']] return 1 diff --git a/PLC/Methods/DeleteNodeFromPCU.py b/PLC/Methods/DeleteNodeFromPCU.py index 67a45f4..02ddfcc 100644 --- a/PLC/Methods/DeleteNodeFromPCU.py +++ b/PLC/Methods/DeleteNodeFromPCU.py @@ -25,6 +25,9 @@ class DeleteNodeFromPCU(Method): returns = Parameter(int, '1 if successful') + event_type = 'DeleteFrom' + object_type = 'PCU' + def call(self, auth, node_id_or_hostname, pcu_id): # Get node nodes = Nodes(self.api, [node_id_or_hostname]) @@ -54,4 +57,6 @@ class DeleteNodeFromPCU(Method): if node['node_id'] in pcu['node_ids']: pcu.remove_node(node) - return 1 + self.object_ids = [pcu['pcu_id']] + + return 1 diff --git a/PLC/Methods/DeleteNodeGroup.py b/PLC/Methods/DeleteNodeGroup.py index 59615f3..c038401 100644 --- a/PLC/Methods/DeleteNodeGroup.py +++ b/PLC/Methods/DeleteNodeGroup.py @@ -23,6 +23,9 @@ class DeleteNodeGroup(Method): returns = Parameter(int, '1 if successful') + event_type = 'Delete' + object_type = 'NodeGroup' + def call(self, auth, node_group_id_or_name): # Get account information nodegroups = NodeGroups(self.api, [node_group_id_or_name]) @@ -32,5 +35,6 @@ class DeleteNodeGroup(Method): nodegroup = nodegroups[0] nodegroup.delete() + self.object_ids = [nodegroup['nodegroup_id']] return 1 diff --git a/PLC/Methods/DeleteNodeNetwork.py b/PLC/Methods/DeleteNodeNetwork.py index d14a5b1..f59b35f 100644 --- a/PLC/Methods/DeleteNodeNetwork.py +++ b/PLC/Methods/DeleteNodeNetwork.py @@ -24,7 +24,11 @@ class DeleteNodeNetwork(Method): returns = Parameter(int, '1 if successful') + event_type = 'Delete' + object_type = 'NodeNetwork' + def call(self, auth, nodenetwork_id): + # Get node network information nodenetworks = NodeNetworks(self.api, [nodenetwork_id]) if not nodenetworks: @@ -47,5 +51,6 @@ class DeleteNodeNetwork(Method): raise PLCPermissionDenied, "Not allowed to delete this node network" nodenetwork.delete() + self.object_ids = [nodenetwork['nodenetwork_id']] return 1 diff --git a/PLC/Methods/DeletePCU.py b/PLC/Methods/DeletePCU.py index 01382b1..50adb88 100644 --- a/PLC/Methods/DeletePCU.py +++ b/PLC/Methods/DeletePCU.py @@ -22,6 +22,9 @@ class DeletePCU(Method): returns = Parameter(int, '1 if successful') + event_type = 'Delete' + object_type = 'PCU' + def call(self, auth, pcu_id): # Get associated PCU details pcus = PCUs(self.api, [pcu_id]) @@ -34,5 +37,6 @@ class DeletePCU(Method): raise PLCPermissionDenied, "Not allowed to update that PCU" pcu.delete() + self.object_ids = [pcu['pcu_id']] return 1 diff --git a/PLC/Methods/DeletePerson.py b/PLC/Methods/DeletePerson.py index e8a1030..7046e81 100644 --- a/PLC/Methods/DeletePerson.py +++ b/PLC/Methods/DeletePerson.py @@ -25,6 +25,9 @@ class DeletePerson(Method): returns = Parameter(int, '1 if successful') + event_type = 'Delete' + object_type = 'Person' + def call(self, auth, person_id_or_email): # Get account information persons = Persons(self.api, [person_id_or_email]) @@ -41,5 +44,6 @@ class DeletePerson(Method): raise PLCPermissionDenied, "Not allowed to delete specified account" person.delete() + self.object_ids = [person['person_id']] return 1 diff --git a/PLC/Methods/DeletePersonFromSite.py b/PLC/Methods/DeletePersonFromSite.py index 9004eae..f7bd630 100644 --- a/PLC/Methods/DeletePersonFromSite.py +++ b/PLC/Methods/DeletePersonFromSite.py @@ -25,6 +25,9 @@ class DeletePersonFromSite(Method): ] returns = Parameter(int, '1 if successful') + + event_type = 'DeleteFrom' + object_type = 'Site' def call(self, auth, person_id_or_email, site_id_or_login_base): # Get account information @@ -44,4 +47,6 @@ class DeletePersonFromSite(Method): if site['site_id'] in person['site_ids']: site.remove_person(person) + self.object_ids = [site['site_id']] + return 1 diff --git a/PLC/Methods/DeletePersonFromSlice.py b/PLC/Methods/DeletePersonFromSlice.py index f21db58..4ccf40a 100644 --- a/PLC/Methods/DeletePersonFromSlice.py +++ b/PLC/Methods/DeletePersonFromSlice.py @@ -25,6 +25,9 @@ class DeletePersonFromSlice(Method): returns = Parameter(int, '1 if successful') + event_type = 'DeleteFrom' + 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]) @@ -48,5 +51,7 @@ class DeletePersonFromSlice(Method): if slice['slice_id'] in person['slice_ids']: slice.remove_person(person) + + self.object_ids = [slice['slice_id']] return 1 diff --git a/PLC/Methods/DeleteRole.py b/PLC/Methods/DeleteRole.py index 53a3903..c557851 100644 --- a/PLC/Methods/DeleteRole.py +++ b/PLC/Methods/DeleteRole.py @@ -25,6 +25,9 @@ class DeleteRole(Method): returns = Parameter(int, '1 if successful') + event_type = 'Delete' + object_type = 'Role' + def call(self, auth, role_id_or_name): roles = Roles(self.api, [role_id_or_name]) if not roles: @@ -32,5 +35,6 @@ class DeleteRole(Method): role = roles[0] role.delete() + self.object_ids = [role['role_id']] return 1 diff --git a/PLC/Methods/DeleteRoleFromPerson.py b/PLC/Methods/DeleteRoleFromPerson.py index 60ed91e..2f0d579 100644 --- a/PLC/Methods/DeleteRoleFromPerson.py +++ b/PLC/Methods/DeleteRoleFromPerson.py @@ -27,6 +27,9 @@ class DeleteRoleFromPerson(Method): returns = Parameter(int, '1 if successful') + event_type = 'DeleteFrom' + object_type = 'Person' + def call(self, auth, role_id_or_name, person_id_or_email): # Get all roles roles = {} @@ -63,5 +66,7 @@ class DeleteRoleFromPerson(Method): if role_id in person['role_ids']: person.remove_role(role_id) + + self.object_ids = [person['person_id']] return 1 diff --git a/PLC/Methods/DeleteSession.py b/PLC/Methods/DeleteSession.py index be5a8ae..1b8bbb7 100644 --- a/PLC/Methods/DeleteSession.py +++ b/PLC/Methods/DeleteSession.py @@ -16,6 +16,9 @@ class DeleteSession(Method): accepts = [SessionAuth()] returns = Parameter(int, '1 if successful') + event_type = 'Delete' + object_type = 'Session' + def call(self, auth): assert auth.has_key('session') diff --git a/PLC/Methods/DeleteSite.py b/PLC/Methods/DeleteSite.py index d56d711..e84466e 100644 --- a/PLC/Methods/DeleteSite.py +++ b/PLC/Methods/DeleteSite.py @@ -27,6 +27,9 @@ class DeleteSite(Method): returns = Parameter(int, '1 if successful') + event_type = 'Delete' + object_type = 'Site' + def call(self, auth, site_id_or_login_base): # Get account information sites = Sites(self.api, [site_id_or_login_base]) @@ -35,5 +38,6 @@ class DeleteSite(Method): site = sites[0] site.delete() + self.object_ids = [site['site_id']] return 1 diff --git a/PLC/Methods/DeleteSlice.py b/PLC/Methods/DeleteSlice.py index 1607d9c..5c171e1 100644 --- a/PLC/Methods/DeleteSlice.py +++ b/PLC/Methods/DeleteSlice.py @@ -25,6 +25,9 @@ class DeleteSlice(Method): returns = Parameter(int, '1 if successful') + event_type = 'Delete' + object_type = 'Slice' + def call(self, auth, slice_id_or_name): slices = Slices(self.api, [slice_id_or_name]) if not slices: @@ -40,5 +43,6 @@ class DeleteSlice(Method): raise PLCPermissionDenied, "Specified slice not associated with any of your sites" slice.delete() + self.object_ids = [slice['slice_id']] return 1 diff --git a/PLC/Methods/DeleteSliceAttribute.py b/PLC/Methods/DeleteSliceAttribute.py index 7584f46..c84c622 100644 --- a/PLC/Methods/DeleteSliceAttribute.py +++ b/PLC/Methods/DeleteSliceAttribute.py @@ -28,6 +28,9 @@ class DeleteSliceAttribute(Method): returns = Parameter(int, '1 if successful') + event_type = 'Delete' + object_type = 'SliceAttribute' + def call(self, auth, slice_attribute_id): slice_attributes = SliceAttributes(self.api, [slice_attribute_id]) if not slice_attributes: @@ -51,8 +54,9 @@ class DeleteSliceAttribute(Method): if slice_attribute['min_role_id'] is not None and \ min(self.caller['role_ids']) > slice_attribute['min_role_id']: - raise PLCPermissionDenied, "Not allowed to delete the specified attribute" + raise PLCPermissioinDenied, "Not allowed to delete the specified attribute" slice_attribute.delete() + self.object_ids = [slice_attribute['slice_attribute_id']] return 1 diff --git a/PLC/Methods/DeleteSliceAttributeType.py b/PLC/Methods/DeleteSliceAttributeType.py index db7816a..37a7065 100644 --- a/PLC/Methods/DeleteSliceAttributeType.py +++ b/PLC/Methods/DeleteSliceAttributeType.py @@ -21,6 +21,9 @@ class DeleteSliceAttributeType(Method): returns = Parameter(int, '1 if successful') + event_type = 'Delete' + object_type = 'SliceAttributeType' + def call(self, auth, attribute_type_id_or_name): attribute_types = SliceAttributeTypes(self.api, [attribute_type_id_or_name]) if not attribute_types: @@ -28,5 +31,6 @@ class DeleteSliceAttributeType(Method): attribute_type = attribute_types[0] attribute_type.delete() + self.object_ids = [attribute_type['attribute_type_id']] return 1 diff --git a/PLC/Methods/DeleteSliceFromNodes.py b/PLC/Methods/DeleteSliceFromNodes.py index 912f3b1..71809b7 100644 --- a/PLC/Methods/DeleteSliceFromNodes.py +++ b/PLC/Methods/DeleteSliceFromNodes.py @@ -25,6 +25,9 @@ class DeleteSliceFromNodes(Method): returns = Parameter(int, '1 if successful') + event_type = 'DeleteFrom' + 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]) @@ -48,5 +51,7 @@ class DeleteSliceFromNodes(Method): for node in nodes: if slice['slice_id'] in node['slice_ids']: slice.remove_node(node) + + self.object_ids = [node['node_id'] for node in nodes] return 1 diff --git a/PLC/Methods/DeleteSliceInstantiation.py b/PLC/Methods/DeleteSliceInstantiation.py index 5c3c875..d6b4091 100644 --- a/PLC/Methods/DeleteSliceInstantiation.py +++ b/PLC/Methods/DeleteSliceInstantiation.py @@ -22,6 +22,9 @@ class DeleteSliceInstantiation(Method): returns = Parameter(int, '1 if successful') + event_type = 'Delete' + object_type = 'SliceInstantiation' + def call(self, auth, instantiation): slice_instantiations = SliceInstantiations(self.api, [instantiation]) if not slice_instantiations: -- 2.43.0