From: Tony Mack Date: Fri, 20 Oct 2006 18:42:55 +0000 (+0000) Subject: - added class variables: event_type, object_type, object_ids (used by event logger) X-Git-Tag: pycurl-7_13_1~490 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=f8e0c71d96dce99eff25e5bb6bdf941468e897a2;p=plcapi.git - added class variables: event_type, object_type, object_ids (used by event logger) --- diff --git a/PLC/Methods/AddAddressType.py b/PLC/Methods/AddAddressType.py index d55aa4d9..075fca2b 100644 --- a/PLC/Methods/AddAddressType.py +++ b/PLC/Methods/AddAddressType.py @@ -25,11 +25,16 @@ class AddAddressType(Method): ] returns = Parameter(int, 'New address_type_id (> 0) if successful') + + event_type = 'Add' + object_type = 'AddressType' + object_ids = [] def call(self, auth, name, address_type_fields = {}): address_type_fields = dict(filter(can_update, address_type_fields.items())) address_type = AddressType(self.api, address_type_fields) address_type['name'] = name address_type.sync() - - return address_type['address_type_id'] + self.object_ids = [address_type['address_type_id']] + + return address_type['address_type_id'] diff --git a/PLC/Methods/AddAddressTypeToAddress.py b/PLC/Methods/AddAddressTypeToAddress.py index 64f532a2..1a20e0ed 100644 --- a/PLC/Methods/AddAddressTypeToAddress.py +++ b/PLC/Methods/AddAddressTypeToAddress.py @@ -25,8 +25,12 @@ class AddAddressTypeToAddress(Method): returns = Parameter(int, '1 if successful') + event_type = 'AddTo' + object_type = 'Address' + object_ids = [] + def call(self, auth, address_type_id_or_name, address_id): - address_types = AddressTypes(self.api, [address_type_id_or_name]).values() + address_types = AddressTypes(self.api, [address_type_id_or_name]).values() if not address_types: raise PLCInvalidArgument, "No such address type" address_type = address_types[0] @@ -41,5 +45,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']] return 1 diff --git a/PLC/Methods/AddBootState.py b/PLC/Methods/AddBootState.py index 2ecd90b0..ba39b66c 100644 --- a/PLC/Methods/AddBootState.py +++ b/PLC/Methods/AddBootState.py @@ -20,6 +20,10 @@ class AddBootState(Method): returns = Parameter(int, '1 if successful') + event_type = 'Add' + object_type = 'BootState' + object_ids = [] + def call(self, auth, name): boot_state = BootState(self.api) boot_state['boot_state'] = name diff --git a/PLC/Methods/AddKeyType.py b/PLC/Methods/AddKeyType.py index 86c2bc93..914323c3 100644 --- a/PLC/Methods/AddKeyType.py +++ b/PLC/Methods/AddKeyType.py @@ -20,6 +20,9 @@ class AddKeyType(Method): returns = Parameter(int, '1 if successful') + event_type = 'Add' + object_type = 'KeyType' + def call(self, auth, name): key_type = KeyType(self.api) key_type['key_type'] = name diff --git a/PLC/Methods/AddNetworkMethod.py b/PLC/Methods/AddNetworkMethod.py index c207e1d4..d243ae39 100644 --- a/PLC/Methods/AddNetworkMethod.py +++ b/PLC/Methods/AddNetworkMethod.py @@ -20,6 +20,9 @@ class AddNetworkMethod(Method): returns = Parameter(int, '1 if successful') + event_type = 'Add' + object_type = 'NetworkMethod' + def call(self, auth, name): network_method = NetworkMethod(self.api) network_method['method'] = name diff --git a/PLC/Methods/AddNetworkType.py b/PLC/Methods/AddNetworkType.py index eb2e7808..cd28d052 100644 --- a/PLC/Methods/AddNetworkType.py +++ b/PLC/Methods/AddNetworkType.py @@ -20,6 +20,9 @@ class AddNetworkType(Method): returns = Parameter(int, '1 if successful') + event_type = 'Add' + object_type = 'NetworkType' + def call(self, auth, name): network_type = NetworkType(self.api) network_type['type'] = name diff --git a/PLC/Methods/AddNode.py b/PLC/Methods/AddNode.py index 086f5e0d..a61fad6c 100644 --- a/PLC/Methods/AddNode.py +++ b/PLC/Methods/AddNode.py @@ -34,6 +34,10 @@ class AddNode(Method): returns = Parameter(int, 'New node_id (> 0) if successful') + event_type = 'Add' + object_type = 'Node' + object_ids = [] + def call(self, auth, site_id_or_login_base, hostname, node_fields = {}): node_fields = dict(filter(can_update, node_fields.items())) @@ -60,5 +64,6 @@ class AddNode(Method): node['hostname'] = hostname node['site_id'] = site['site_id'] node.sync() + self.object_ids = [node['node_id']] return node['node_id'] diff --git a/PLC/Methods/AddNodeGroup.py b/PLC/Methods/AddNodeGroup.py index fe16b811..75d4d912 100644 --- a/PLC/Methods/AddNodeGroup.py +++ b/PLC/Methods/AddNodeGroup.py @@ -27,10 +27,15 @@ class AddNodeGroup(Method): returns = Parameter(int, 'New nodegroup_id (> 0) if successful') + event_type = 'Add' + object_type = 'NodeGroup' + object_ids = [] + def call(self, auth, name, nodegroup_fields = {}): nodegroup_fields = dict(filter(can_update, nodegroup_fields.items())) nodegroup = NodeGroup(self.api, nodegroup_fields) nodegroup['name'] = name nodegroup.sync() + self.object_ids = [nodegroup['nodegroup_id']] return nodegroup['nodegroup_id'] diff --git a/PLC/Methods/AddNodeNetwork.py b/PLC/Methods/AddNodeNetwork.py index b8ddba66..16e3782d 100644 --- a/PLC/Methods/AddNodeNetwork.py +++ b/PLC/Methods/AddNodeNetwork.py @@ -39,6 +39,10 @@ class AddNodeNetwork(Method): returns = Parameter(int, 'New nodenetwork_id (> 0) if successful') + event_type = 'Add' + object_type = 'NodeNetwork' + object_ids = [] + def call(self, auth, node_id, method, type, nodenetwork_fields = {}): nodenetwork_fields = dict(filter(can_update, nodenetwork_fields.items())) @@ -63,5 +67,6 @@ class AddNodeNetwork(Method): nodenetwork['method'] = method nodenetwork['type'] = type nodenetwork.sync() + self.object_ids = [nodenetwork['nodenetwork_id']] return nodenetwork['nodenetwork_id'] diff --git a/PLC/Methods/AddNodeToNodeGroup.py b/PLC/Methods/AddNodeToNodeGroup.py index 04e92bee..c1e70d61 100644 --- a/PLC/Methods/AddNodeToNodeGroup.py +++ b/PLC/Methods/AddNodeToNodeGroup.py @@ -25,6 +25,10 @@ class AddNodeToNodeGroup(Method): returns = Parameter(int, '1 if successful') + event_type = 'AddTo' + object_type = 'NodeGroup' + object_ids = [] + def call(self, auth, nodegroup_id_or_name, node_id_or_hostname): # Get node info nodes = Nodes(self.api, [node_id_or_hostname]) @@ -42,5 +46,6 @@ class AddNodeToNodeGroup(Method): # add node to nodegroup if node['node_id'] not in nodegroup['node_ids']: nodegroup.add_node(node) + self.object_ids = [nodegroup['nodegroup_id']] return 1 diff --git a/PLC/Methods/AddNodeToPCU.py b/PLC/Methods/AddNodeToPCU.py index 6a4cd758..53789872 100644 --- a/PLC/Methods/AddNodeToPCU.py +++ b/PLC/Methods/AddNodeToPCU.py @@ -26,6 +26,9 @@ class AddNodeToPCU(Method): ] returns = Parameter(int, '1 if successful') + event_type = 'AddTo' + object_type = 'PCU' + object_ids = [] def call(self, auth, node_id_or_hostname, pcu_id, port): # Get node @@ -60,5 +63,6 @@ class AddNodeToPCU(Method): raise PLCInvalidArgument, "PCU port already in use" pcu.add_node(node, port) + self.object_ids = [pcu['pcu_id']] return 1 diff --git a/PLC/Methods/AddPCU.py b/PLC/Methods/AddPCU.py index 3dec3ef1..d311e378 100644 --- a/PLC/Methods/AddPCU.py +++ b/PLC/Methods/AddPCU.py @@ -34,6 +34,10 @@ class AddPCU(Method): ] returns = Parameter(int, 'New pcu_id (> 0) if successful') + + event_type = 'Add' + object_type = 'PCU' + object_ids = [] def call(self, auth, site_id_or_login_base, ip, pcu_fields = {}): pcu_fields = dict(filter(can_update, pcu_fields.items())) @@ -52,5 +56,6 @@ class AddPCU(Method): pcu['site_id'] = site['site_id'] pcu['ip'] = ip pcu.sync() + self.object_ids = [pcu['pcu_id']] return pcu['pcu_id'] diff --git a/PLC/Methods/AddPerson.py b/PLC/Methods/AddPerson.py index d80826bc..6393982b 100644 --- a/PLC/Methods/AddPerson.py +++ b/PLC/Methods/AddPerson.py @@ -31,6 +31,10 @@ class AddPerson(Method): returns = Parameter(int, 'New person_id (> 0) if successful') + event_type = 'Add' + object_type = 'Person' + object_ids = [] + def call(self, auth, first_name, last_name, person_fields = {}): person_fields = dict(filter(can_update, person_fields.items())) person = Person(self.api, person_fields) @@ -38,5 +42,6 @@ class AddPerson(Method): person['last_name'] = last_name person['enabled'] = False person.sync() + self.object_ids = [person['person']] return person['person_id'] diff --git a/PLC/Methods/AddPersonKey.py b/PLC/Methods/AddPersonKey.py index b4ba0d3d..edad2cbd 100644 --- a/PLC/Methods/AddPersonKey.py +++ b/PLC/Methods/AddPersonKey.py @@ -26,6 +26,10 @@ class AddPersonKey(Method): returns = Parameter(int, 'New key_id (> 0) if successful') + event_type = 'Add' + object_type = 'Key' + object_ids = [] + def call(self, auth, person_id_or_email, key_type, key_value): # Get account details persons = Persons(self.api, [person_id_or_email]).values() @@ -43,7 +47,7 @@ class AddPersonKey(Method): key['key_type'] = key_type key['key'] = key_value key.sync(commit = False) - person.add_key(key, commit = True) - + self.object_ids = [key['key_id']] + return key['key_id'] diff --git a/PLC/Methods/AddPersonToSite.py b/PLC/Methods/AddPersonToSite.py index 71d1d67f..e4719ab0 100644 --- a/PLC/Methods/AddPersonToSite.py +++ b/PLC/Methods/AddPersonToSite.py @@ -25,6 +25,9 @@ class AddPersonToSite(Method): ] returns = Parameter(int, '1 if successful') + event_type = 'AddTo' + object_type = 'Site' + object_ids = [] def call(self, auth, person_id_or_email, site_id_or_login_base): # Get account information @@ -43,5 +46,6 @@ class AddPersonToSite(Method): if site['site_id'] not in person['site_ids']: site.add_person(person) - + self.object_ids = [site['site_id']] + return 1 diff --git a/PLC/Methods/AddPersonToSlice.py b/PLC/Methods/AddPersonToSlice.py index 9948af2d..c60b5fd9 100644 --- a/PLC/Methods/AddPersonToSlice.py +++ b/PLC/Methods/AddPersonToSlice.py @@ -24,6 +24,9 @@ class AddPersonToSlice(Method): ] returns = Parameter(int, '1 if successful') + event_type = 'AddTo' + object_type = 'Slice' + object_ids = [] def call(self, auth, person_id_or_email, slice_id_or_name): # Get account information @@ -48,5 +51,6 @@ class AddPersonToSlice(Method): if slice['slice_id'] not in person['slice_ids']: slice.add_person(person) + self.object_ids = [slice['slice_id']] return 1 diff --git a/PLC/Methods/AddRole.py b/PLC/Methods/AddRole.py index 109374c9..3da92aab 100644 --- a/PLC/Methods/AddRole.py +++ b/PLC/Methods/AddRole.py @@ -21,10 +21,15 @@ class AddRole(Method): returns = Parameter(int, '1 if successful') + event_type = 'Add' + object_type = 'Role' + object_ids = [] + def call(self, auth, role_id, name): role = Role(self.api) role['role_id'] = role_id role['name'] = name role.sync(insert = True) + self.object_ids = [role['role_id']] return 1 diff --git a/PLC/Methods/AddRoleToPerson.py b/PLC/Methods/AddRoleToPerson.py index bfe68178..0d82dea9 100644 --- a/PLC/Methods/AddRoleToPerson.py +++ b/PLC/Methods/AddRoleToPerson.py @@ -27,6 +27,10 @@ class AddRoleToPerson(Method): returns = Parameter(int, '1 if successful') + event_type = 'AddTo' + object_type = 'Person' + object_ids = [] + def call(self, auth, role_id_or_name, person_id_or_email): # Get all roles roles = {} @@ -64,4 +68,6 @@ class AddRoleToPerson(Method): if role_id not in person['role_ids']: person.add_role(role_id) + self.object_ids = [person['person_id']] + return 1 diff --git a/PLC/Methods/AddSite.py b/PLC/Methods/AddSite.py index 320121a8..8f77d865 100644 --- a/PLC/Methods/AddSite.py +++ b/PLC/Methods/AddSite.py @@ -30,6 +30,10 @@ class AddSite(Method): returns = Parameter(int, 'New site_id (> 0) if successful') + event_type = 'Add' + object_type = 'Site' + object_ids = [] + def call(self, auth, name, abbreviated_name, login_base, site_fields = {}): site_fields = dict(filter(can_update, site_fields.items())) site = Site(self.api, site_fields) @@ -37,5 +41,6 @@ class AddSite(Method): site['abbreviated_name'] = abbreviated_name site['login_base'] = login_base site.sync() - - return site['site_id'] + self.object_ids = [site['site_id']] + + return site['site_id'] diff --git a/PLC/Methods/AddSiteAddress.py b/PLC/Methods/AddSiteAddress.py index cb6e706d..662250cf 100644 --- a/PLC/Methods/AddSiteAddress.py +++ b/PLC/Methods/AddSiteAddress.py @@ -32,6 +32,10 @@ class AddSiteAddress(Method): returns = Parameter(int, 'New address_id (> 0) if successful') + event_type = 'Add' + object_type = 'Address' + object_ids = [] + def call(self, auth, site_id_or_login_base, address_fields = {}): address_fields = dict(filter(can_update, address_fields.items())) @@ -48,5 +52,6 @@ class AddSiteAddress(Method): address = Address(self.api, address_fields) address['site_id'] = site['site_id'] address.sync() + self.object_ids = [address['address_id']] return address['address_id'] diff --git a/PLC/Methods/AddSlice.py b/PLC/Methods/AddSlice.py index 3c0e2048..58bce63a 100644 --- a/PLC/Methods/AddSlice.py +++ b/PLC/Methods/AddSlice.py @@ -39,6 +39,10 @@ class AddSlice(Method): returns = Parameter(int, 'New slice_id (> 0) if successful') + event_type = 'Add' + object_type = 'Slice' + object_ids = [] + def call(self, auth, name, slice_fields = {}): slice_fields = dict(filter(can_update, slice_fields.items())) @@ -70,5 +74,6 @@ class AddSlice(Method): slice['name'] = name slice['site_id'] = site['site_id'] slice.sync() + self.object_ids = [slice['slice_id']] return slice['slice_id'] diff --git a/PLC/Methods/AddSliceAttribute.py b/PLC/Methods/AddSliceAttribute.py index e221be8c..58fdac76 100644 --- a/PLC/Methods/AddSliceAttribute.py +++ b/PLC/Methods/AddSliceAttribute.py @@ -37,6 +37,10 @@ class AddSliceAttribute(Method): returns = Parameter(int, 'New slice_attribute_id (> 0) if successful') + event_type = 'Add' + object_type = 'SliceAttribute' + object_ids = [] + 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]).values() if not slices: @@ -78,5 +82,6 @@ class AddSliceAttribute(Method): slice_attribute['node_id'] = node['node_id'] slice_attribute.sync() + self.object_ids = [slice_attribute['slice_attribute_id']] return slice_attribute['slice_attribute_id'] diff --git a/PLC/Methods/AddSliceAttributeType.py b/PLC/Methods/AddSliceAttributeType.py index 413471e8..c1d3fcee 100644 --- a/PLC/Methods/AddSliceAttributeType.py +++ b/PLC/Methods/AddSliceAttributeType.py @@ -28,10 +28,15 @@ class AddSliceAttributeType(Method): returns = Parameter(int, 'New attribute_id (> 0) if successful') + event_type = 'Add' + object_type = 'SliceAttributeType' + object_ids = [] + def call(self, auth, name, attribute_type_fields = {}): attribute_type_fields = dict(filter(can_update, attribute_type_fields.items())) attribute_type = SliceAttributeType(self.api, attribute_type_fields) attribute_type['name'] = name attribute_type.sync() + self.object_ids = [attribute_type['attribute_type_id']] return attribute_type['attribute_type_id'] diff --git a/PLC/Methods/AddSliceToNodes.py b/PLC/Methods/AddSliceToNodes.py index 7e0a5d90..290dbc76 100644 --- a/PLC/Methods/AddSliceToNodes.py +++ b/PLC/Methods/AddSliceToNodes.py @@ -25,6 +25,10 @@ class AddSliceToNodes(Method): returns = Parameter(int, '1 if successful') + event_type = 'AddTo' + object_type = 'Node' + object_ids = [] + 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 +52,7 @@ class AddSliceToNodes(Method): for node in nodes: if slice['slice_id'] not in node['slice_ids']: slice.add_node(node) + + self.object_ids = [node['node_id'] for node in nodes] return 1