Loading src/device/service/driver_api/ImportTopologyEnum.py 0 → 100644 +37 −0 Original line number Diff line number Diff line # Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from enum import Enum from typing import Dict class ImportTopologyEnum(Enum): # While importing underlying resources, the driver just imports endpoints and exposes them directly. DISABLED = 'disabled' # While importing underlying resources, the driver just imports imports sub-devices but not links # connecting them. The endpoints are exposed in virtual nodes representing the sub-devices. # (a remotely-controlled transport domain might exist between nodes) DEVICES = 'devices' # While importing underlying resources, the driver just imports imports sub-devices and links # connecting them. The endpoints are exposed in virtual nodes representing the sub-devices. # (enables to define constrained connectivity between the sub-devices) TOPOLOGY = 'topology' def get_import_topology(settings : Dict, default : ImportTopologyEnum = ImportTopologyEnum.DISABLED): str_import_topology = settings.get('import_topology') if str_import_topology is None: return default import_topology = ImportTopologyEnum._value2member_map_.get(str_import_topology) # pylint: disable=no-member if import_topology is None: raise Exception('Unexpected setting value') return import_topology src/device/service/drivers/xr/XrDriver.py +55 −40 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ from common.DeviceTypes import DeviceTypeEnum from common.method_wrappers.Decorator import MetricsPool, metered_subclass_method from common.proto.context_pb2 import DeviceDriverEnum, DeviceOperationalStatusEnum from common.type_checkers.Checkers import chk_type from device.service.driver_api.ImportTopologyEnum import ImportTopologyEnum, get_import_topology from device.service.driver_api._Driver import _Driver from .cm.cm_connection import CmConnection, ConsistencyMode from .cm import tf Loading @@ -48,6 +49,14 @@ class XrDriver(_Driver): username = settings.get("username", "xr-user-1") password = settings.get("password", "xr-user-1") # Options are: # disabled --> just import endpoints as usual # devices --> imports sub-devices but not links connecting them. # (a remotely-controlled transport domain might exist between them) # topology --> imports sub-devices and links connecting them. # (not supported by XR driver) self.__import_topology = get_import_topology(settings, default=ImportTopologyEnum.DISABLED) # Options are: # asynchronous --> operation considered complete when IPM responds with suitable status code, # including "accepted", that only means request is semantically good and queued. Loading Loading @@ -100,8 +109,12 @@ class XrDriver(_Driver): constellation = self.__cm_connection.get_constellation_by_hub_name(self.__hub_module_name) if constellation: self.__constellation = constellation #return [(f"/endpoints/endpoint[{ifname}]", {'uuid': ifname, 'type': 'optical', 'sample_types': {}}) for ifname in constellation.ifnames()] if self.__import_topology == ImportTopologyEnum.DISABLED: return [ (f"/endpoints/endpoint[{ifname}]", {'uuid': ifname, 'type': 'optical', 'sample_types': {}}) for ifname in constellation.ifnames() ] elif self.__import_topology == ImportTopologyEnum.DEVICES: devices : Set[str] = set() pluggables : Set[str] = set() devices_and_endpoints = [] Loading Loading @@ -144,6 +157,8 @@ class XrDriver(_Driver): devices_and_endpoints.append((endpoint_url, endpoint_data)) return devices_and_endpoints else: raise Exception('Unsupported import_topology mode: {:s}'.format(str(self.__import_topology))) else: return [] Loading Loading
src/device/service/driver_api/ImportTopologyEnum.py 0 → 100644 +37 −0 Original line number Diff line number Diff line # Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from enum import Enum from typing import Dict class ImportTopologyEnum(Enum): # While importing underlying resources, the driver just imports endpoints and exposes them directly. DISABLED = 'disabled' # While importing underlying resources, the driver just imports imports sub-devices but not links # connecting them. The endpoints are exposed in virtual nodes representing the sub-devices. # (a remotely-controlled transport domain might exist between nodes) DEVICES = 'devices' # While importing underlying resources, the driver just imports imports sub-devices and links # connecting them. The endpoints are exposed in virtual nodes representing the sub-devices. # (enables to define constrained connectivity between the sub-devices) TOPOLOGY = 'topology' def get_import_topology(settings : Dict, default : ImportTopologyEnum = ImportTopologyEnum.DISABLED): str_import_topology = settings.get('import_topology') if str_import_topology is None: return default import_topology = ImportTopologyEnum._value2member_map_.get(str_import_topology) # pylint: disable=no-member if import_topology is None: raise Exception('Unexpected setting value') return import_topology
src/device/service/drivers/xr/XrDriver.py +55 −40 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ from common.DeviceTypes import DeviceTypeEnum from common.method_wrappers.Decorator import MetricsPool, metered_subclass_method from common.proto.context_pb2 import DeviceDriverEnum, DeviceOperationalStatusEnum from common.type_checkers.Checkers import chk_type from device.service.driver_api.ImportTopologyEnum import ImportTopologyEnum, get_import_topology from device.service.driver_api._Driver import _Driver from .cm.cm_connection import CmConnection, ConsistencyMode from .cm import tf Loading @@ -48,6 +49,14 @@ class XrDriver(_Driver): username = settings.get("username", "xr-user-1") password = settings.get("password", "xr-user-1") # Options are: # disabled --> just import endpoints as usual # devices --> imports sub-devices but not links connecting them. # (a remotely-controlled transport domain might exist between them) # topology --> imports sub-devices and links connecting them. # (not supported by XR driver) self.__import_topology = get_import_topology(settings, default=ImportTopologyEnum.DISABLED) # Options are: # asynchronous --> operation considered complete when IPM responds with suitable status code, # including "accepted", that only means request is semantically good and queued. Loading Loading @@ -100,8 +109,12 @@ class XrDriver(_Driver): constellation = self.__cm_connection.get_constellation_by_hub_name(self.__hub_module_name) if constellation: self.__constellation = constellation #return [(f"/endpoints/endpoint[{ifname}]", {'uuid': ifname, 'type': 'optical', 'sample_types': {}}) for ifname in constellation.ifnames()] if self.__import_topology == ImportTopologyEnum.DISABLED: return [ (f"/endpoints/endpoint[{ifname}]", {'uuid': ifname, 'type': 'optical', 'sample_types': {}}) for ifname in constellation.ifnames() ] elif self.__import_topology == ImportTopologyEnum.DEVICES: devices : Set[str] = set() pluggables : Set[str] = set() devices_and_endpoints = [] Loading Loading @@ -144,6 +157,8 @@ class XrDriver(_Driver): devices_and_endpoints.append((endpoint_url, endpoint_data)) return devices_and_endpoints else: raise Exception('Unsupported import_topology mode: {:s}'.format(str(self.__import_topology))) else: return [] Loading