Loading src/device/service/drivers/ietf_l2vpn/IetfL2VpnDriver.py +63 −46 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. import logging, threading import json, logging, threading from typing import Any, Iterator, List, Optional, Tuple, Union from common.method_wrappers.Decorator import MetricsPool, metered_subclass_method from common.tools.object_factory.Device import json_device_id Loading @@ -20,7 +20,7 @@ from common.tools.object_factory.EndPoint import json_endpoint_id from common.type_checkers.Checkers import chk_string, chk_type from device.service.driver_api._Driver import _Driver, RESOURCE_ENDPOINTS, RESOURCE_SERVICES from device.service.drivers.ietf_l2vpn.TfsDebugApiClient import TfsDebugApiClient from .Tools import connection_point, find_key, wim_mapping from .Tools import connection_point, wim_mapping from .WimconnectorIETFL2VPN import WimconnectorIETFL2VPN LOGGER = logging.getLogger(__name__) Loading Loading @@ -121,26 +121,40 @@ class IetfL2VpnDriver(_Driver): self.wim.check_credentials() for resource in resources: LOGGER.info('resource = {:s}'.format(str(resource))) service_uuid = find_key(resource, 'uuid') resource_key,resource_value = resource try: resource_value = json.loads(resource_value) service_uuid = resource_value['uuid'] if service_exists(self.wim, service_uuid): exc = NotImplementedError('IETF L2VPN Service Update is still not supported') results.append((resource[0], exc)) continue src_device_uuid = find_key(resource, 'src_device_uuid') src_endpoint_uuid = find_key(resource, 'src_endpoint_uuid') dst_device_uuid = find_key(resource, 'dst_device_uuid') dst_endpoint_uuid = find_key(resource, 'dst_endpoint_uuid') encap_type = find_key(resource, 'encapsulation_type') vlan_id = find_key(resource, 'vlan_id') src_endpoint_id = json_endpoint_id(json_device_id(src_device_uuid), src_endpoint_uuid) src_device_endpoint = resource_value['src'] src_device = src_device_endpoint['device'] #src_device_uuid = src_device['uuid'] src_device_name = src_device['name'] src_endpoint = src_device_endpoint['endpoint'] #src_endpoint_uuid = src_endpoint['uuid'] src_endpoint_name = src_endpoint['name'] dst_device_endpoint = resource_value['dst'] dst_device = dst_device_endpoint['device'] #dst_device_uuid = dst_device['uuid'] dst_device_name = dst_device['name'] dst_endpoint = dst_device_endpoint['endpoint'] #dst_endpoint_uuid = dst_endpoint['uuid'] dst_endpoint_name = dst_endpoint['name'] encap_type = resource_value['encapsulation_type'] vlan_id = resource_value['vlan_id'] src_endpoint_id = json_endpoint_id(json_device_id(src_device_name), src_endpoint_name) src_service_endpoint_id, src_mapping = wim_mapping('1', src_endpoint_id) self.wim.mappings[src_service_endpoint_id] = src_mapping dst_endpoint_id = json_endpoint_id(json_device_id(dst_device_uuid), dst_endpoint_uuid) dst_endpoint_id = json_endpoint_id(json_device_id(dst_device_name), dst_endpoint_name) dst_service_endpoint_id, dst_mapping = wim_mapping('2', dst_endpoint_id) self.wim.mappings[dst_service_endpoint_id] = dst_mapping Loading @@ -153,6 +167,9 @@ class IetfL2VpnDriver(_Driver): LOGGER.info('[SetConfig] CREATE result={:s}'.format(str(result))) results.extend(process_connectivity_service('SetConfig', None)) except Exception as e: # pylint: disable=broad-except LOGGER.exception('Unhandled error processing resource_key({:s})'.format(str(resource_key))) results.append((resource_key, e)) return results @metered_subclass_method(METRICS_POOL) Loading @@ -163,18 +180,18 @@ class IetfL2VpnDriver(_Driver): self.wim.check_credentials() for resource in resources: LOGGER.info('resource = {:s}'.format(str(resource))) service_uuid = find_key(resource, 'uuid') resource_key,resource_value = resource try: resource_value = json.loads(resource_value) service_uuid = resource_value['uuid'] conn_info = {} if service_exists(self.wim, service_uuid): self.wim.delete_connectivity_service(service_uuid) result = self.wim.get_connectivity_service_status( service_uuid, conn_info=conn_info) if service_exists(result): self.wim.delete_connectivity_service( service_uuid, conn_info=conn_info) else: result = False results.extend(process_connectivity_service('DeleteConfig', None)) except Exception as e: # pylint: disable=broad-except LOGGER.exception('Unhandled error processing resource_key({:s})'.format(str(resource_key))) results.append((resource_key, e)) return results @metered_subclass_method(METRICS_POOL) Loading Loading
src/device/service/drivers/ietf_l2vpn/IetfL2VpnDriver.py +63 −46 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. import logging, threading import json, logging, threading from typing import Any, Iterator, List, Optional, Tuple, Union from common.method_wrappers.Decorator import MetricsPool, metered_subclass_method from common.tools.object_factory.Device import json_device_id Loading @@ -20,7 +20,7 @@ from common.tools.object_factory.EndPoint import json_endpoint_id from common.type_checkers.Checkers import chk_string, chk_type from device.service.driver_api._Driver import _Driver, RESOURCE_ENDPOINTS, RESOURCE_SERVICES from device.service.drivers.ietf_l2vpn.TfsDebugApiClient import TfsDebugApiClient from .Tools import connection_point, find_key, wim_mapping from .Tools import connection_point, wim_mapping from .WimconnectorIETFL2VPN import WimconnectorIETFL2VPN LOGGER = logging.getLogger(__name__) Loading Loading @@ -121,26 +121,40 @@ class IetfL2VpnDriver(_Driver): self.wim.check_credentials() for resource in resources: LOGGER.info('resource = {:s}'.format(str(resource))) service_uuid = find_key(resource, 'uuid') resource_key,resource_value = resource try: resource_value = json.loads(resource_value) service_uuid = resource_value['uuid'] if service_exists(self.wim, service_uuid): exc = NotImplementedError('IETF L2VPN Service Update is still not supported') results.append((resource[0], exc)) continue src_device_uuid = find_key(resource, 'src_device_uuid') src_endpoint_uuid = find_key(resource, 'src_endpoint_uuid') dst_device_uuid = find_key(resource, 'dst_device_uuid') dst_endpoint_uuid = find_key(resource, 'dst_endpoint_uuid') encap_type = find_key(resource, 'encapsulation_type') vlan_id = find_key(resource, 'vlan_id') src_endpoint_id = json_endpoint_id(json_device_id(src_device_uuid), src_endpoint_uuid) src_device_endpoint = resource_value['src'] src_device = src_device_endpoint['device'] #src_device_uuid = src_device['uuid'] src_device_name = src_device['name'] src_endpoint = src_device_endpoint['endpoint'] #src_endpoint_uuid = src_endpoint['uuid'] src_endpoint_name = src_endpoint['name'] dst_device_endpoint = resource_value['dst'] dst_device = dst_device_endpoint['device'] #dst_device_uuid = dst_device['uuid'] dst_device_name = dst_device['name'] dst_endpoint = dst_device_endpoint['endpoint'] #dst_endpoint_uuid = dst_endpoint['uuid'] dst_endpoint_name = dst_endpoint['name'] encap_type = resource_value['encapsulation_type'] vlan_id = resource_value['vlan_id'] src_endpoint_id = json_endpoint_id(json_device_id(src_device_name), src_endpoint_name) src_service_endpoint_id, src_mapping = wim_mapping('1', src_endpoint_id) self.wim.mappings[src_service_endpoint_id] = src_mapping dst_endpoint_id = json_endpoint_id(json_device_id(dst_device_uuid), dst_endpoint_uuid) dst_endpoint_id = json_endpoint_id(json_device_id(dst_device_name), dst_endpoint_name) dst_service_endpoint_id, dst_mapping = wim_mapping('2', dst_endpoint_id) self.wim.mappings[dst_service_endpoint_id] = dst_mapping Loading @@ -153,6 +167,9 @@ class IetfL2VpnDriver(_Driver): LOGGER.info('[SetConfig] CREATE result={:s}'.format(str(result))) results.extend(process_connectivity_service('SetConfig', None)) except Exception as e: # pylint: disable=broad-except LOGGER.exception('Unhandled error processing resource_key({:s})'.format(str(resource_key))) results.append((resource_key, e)) return results @metered_subclass_method(METRICS_POOL) Loading @@ -163,18 +180,18 @@ class IetfL2VpnDriver(_Driver): self.wim.check_credentials() for resource in resources: LOGGER.info('resource = {:s}'.format(str(resource))) service_uuid = find_key(resource, 'uuid') resource_key,resource_value = resource try: resource_value = json.loads(resource_value) service_uuid = resource_value['uuid'] conn_info = {} if service_exists(self.wim, service_uuid): self.wim.delete_connectivity_service(service_uuid) result = self.wim.get_connectivity_service_status( service_uuid, conn_info=conn_info) if service_exists(result): self.wim.delete_connectivity_service( service_uuid, conn_info=conn_info) else: result = False results.extend(process_connectivity_service('DeleteConfig', None)) except Exception as e: # pylint: disable=broad-except LOGGER.exception('Unhandled error processing resource_key({:s})'.format(str(resource_key))) results.append((resource_key, e)) return results @metered_subclass_method(METRICS_POOL) Loading