Loading src/device/service/drivers/ietf_l3vpn/IetfL3VpnDriver.py +6 −34 Original line number Diff line number Diff line Loading @@ -172,41 +172,17 @@ class IetfL3VpnDriver(_Driver): results = [] if len(resources) == 0: return results with self.__lock: for resource in resources: resource_key, resource_value = resource if RE_IETF_L3VPN_OPERATION.match(resource_key): operation_type = json.loads(resource_value)['type'] results.append((resource_key, True)) break else: raise Exception('operation type not found in resources') for i, resource in enumerate(resources): str_resource_name = 'resource_key[#{:d}]'.format(i) LOGGER.info('resource = {:s}'.format(str(resource))) resource_key, resource_value = resource if not RE_IETF_L3VPN_DATA.match(resource_key): continue if not RE_IETF_L3VPN_DATA.match(resource_key): continue try: resource_value = json.loads(resource_value) service_uuid = resource_value['ietf-l3vpn-svc:l3vpn-svc'][ 'vpn-services' ]['vpn-service'][0]['vpn-id'] if operation_type == 'create': self.tac.create_connectivity_service(resource_value) elif operation_type == 'update': self.tac.update_connectivity_service(resource_value) elif operation_type == 'delete': self.tac.delete_connectivity_service(service_uuid) else: MSG = 'OperationType({:s}) not supported' raise Exception(MSG.format(str(operation_type))) results.append((resource_key, True)) except Exception as e: MSG = 'Unhandled error processing {:s}: resource_key({:s})' MSG = 'Unhandled error processing SET {:s}: resource_key({:s})' LOGGER.exception(MSG.format(str_resource_name, str(resource_key))) results.append((resource_key, e)) return results Loading @@ -216,17 +192,13 @@ class IetfL3VpnDriver(_Driver): self, resources : List[Tuple[str, Any]] ) -> List[Union[bool, Exception]]: results = [] if len(resources) == 0: return results if len(resources) == 0: return results with self.__lock: for i, resource in enumerate(resources): str_resource_name = 'resource_key[#{:d}]'.format(i) LOGGER.info('resource = {:s}'.format(str(resource))) resource_key, resource_value = resource if not RE_IETF_L3VPN_DATA.match(resource_key): continue if not RE_IETF_L3VPN_DATA.match(resource_key): continue try: resource_value = json.loads(resource_value) service_uuid = resource_value['ietf-l3vpn-svc:l3vpn-svc'][ Loading @@ -235,7 +207,7 @@ class IetfL3VpnDriver(_Driver): self.tac.delete_connectivity_service(service_uuid) results.append((resource_key, True)) except Exception as e: MSG = 'Unhandled error processing {:s}: resource_key({:s})' MSG = 'Unhandled error processing DELETE {:s}: resource_key({:s})' LOGGER.exception(MSG.format(str_resource_name, str(resource_key))) results.append((resource_key, e)) return results Loading Loading
src/device/service/drivers/ietf_l3vpn/IetfL3VpnDriver.py +6 −34 Original line number Diff line number Diff line Loading @@ -172,41 +172,17 @@ class IetfL3VpnDriver(_Driver): results = [] if len(resources) == 0: return results with self.__lock: for resource in resources: resource_key, resource_value = resource if RE_IETF_L3VPN_OPERATION.match(resource_key): operation_type = json.loads(resource_value)['type'] results.append((resource_key, True)) break else: raise Exception('operation type not found in resources') for i, resource in enumerate(resources): str_resource_name = 'resource_key[#{:d}]'.format(i) LOGGER.info('resource = {:s}'.format(str(resource))) resource_key, resource_value = resource if not RE_IETF_L3VPN_DATA.match(resource_key): continue if not RE_IETF_L3VPN_DATA.match(resource_key): continue try: resource_value = json.loads(resource_value) service_uuid = resource_value['ietf-l3vpn-svc:l3vpn-svc'][ 'vpn-services' ]['vpn-service'][0]['vpn-id'] if operation_type == 'create': self.tac.create_connectivity_service(resource_value) elif operation_type == 'update': self.tac.update_connectivity_service(resource_value) elif operation_type == 'delete': self.tac.delete_connectivity_service(service_uuid) else: MSG = 'OperationType({:s}) not supported' raise Exception(MSG.format(str(operation_type))) results.append((resource_key, True)) except Exception as e: MSG = 'Unhandled error processing {:s}: resource_key({:s})' MSG = 'Unhandled error processing SET {:s}: resource_key({:s})' LOGGER.exception(MSG.format(str_resource_name, str(resource_key))) results.append((resource_key, e)) return results Loading @@ -216,17 +192,13 @@ class IetfL3VpnDriver(_Driver): self, resources : List[Tuple[str, Any]] ) -> List[Union[bool, Exception]]: results = [] if len(resources) == 0: return results if len(resources) == 0: return results with self.__lock: for i, resource in enumerate(resources): str_resource_name = 'resource_key[#{:d}]'.format(i) LOGGER.info('resource = {:s}'.format(str(resource))) resource_key, resource_value = resource if not RE_IETF_L3VPN_DATA.match(resource_key): continue if not RE_IETF_L3VPN_DATA.match(resource_key): continue try: resource_value = json.loads(resource_value) service_uuid = resource_value['ietf-l3vpn-svc:l3vpn-svc'][ Loading @@ -235,7 +207,7 @@ class IetfL3VpnDriver(_Driver): self.tac.delete_connectivity_service(service_uuid) results.append((resource_key, True)) except Exception as e: MSG = 'Unhandled error processing {:s}: resource_key({:s})' MSG = 'Unhandled error processing DELETE {:s}: resource_key({:s})' LOGGER.exception(MSG.format(str_resource_name, str(resource_key))) results.append((resource_key, e)) return results Loading