Loading src/common/tools/descriptor/Loader.py +74 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,11 @@ from common.tools.object_factory.Context import json_context_id from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from logical_resources.client.Logicalresourceclient import LogicalResourceClient from common.proto.spineleaf_pb2 import SetDeviceRoleRequest from common.tools.object_factory.Context import json_context_id from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from spine_leaf.client.SpineLeafClient import SpineLeafClient from service.client.ServiceClient import ServiceClient from slice.client.SliceClient import SliceClient from vnt_manager.client.VNTManagerClient import VNTManagerClient Loading @@ -71,6 +76,7 @@ ENTITY_TO_TEXT = { 'device' : ('Device', 'Devices' ), 'link' : ('Link', 'Links' ), 'logical_resource': ('Logical Resource', 'Logical Resources'), 'spine_leaf': ('Spine Leaf', 'Spine Leafs'), 'service' : ('Service', 'Services' ), 'slice' : ('Slice', 'Slices' ), 'connection': ('Connection', 'Connections'), Loading Loading @@ -117,6 +123,7 @@ class DescriptorLoader: num_workers : int = 1, context_client : Optional[ContextClient] = None, device_client : Optional[DeviceClient] = None, logical_resources_client : Optional[LogicalResourceClient] = None, spine_leaf_client : Optional[SpineLeafClient] = None, service_client : Optional[ServiceClient] = None, slice_client : Optional[SliceClient] = None, vntm_client : Optional[VNTManagerClient] = None ) -> None: Loading @@ -141,6 +148,7 @@ class DescriptorLoader: self.__links = self.__descriptors.get('links' , []) self.__optical_links = self.__descriptors.get('optical_links',[]) self.__logical_resources = self.__descriptors.get('logical_resources', []) self.__spine_leaf = self.__descriptors.get('spine-leaf', []) self.__services = self.__descriptors.get('services' , []) self.__slices = self.__descriptors.get('slices' , []) self.__ietf_slices = self.__descriptors.get('ietf-network-slice-service:network-slice-services', {}) Loading Loading @@ -200,6 +208,7 @@ class DescriptorLoader: self.__ctx_cli = ContextClient() if context_client is None else context_client self.__dev_cli = DeviceClient() if device_client is None else device_client self.__lrs_cli = LogicalResourceClient() if logical_resources_client is None else logical_resources_client self.__spl_cli = SpineLeafClient() if spine_leaf_client is None else spine_leaf_client self.__svc_cli = ServiceClient() if service_client is None else service_client self.__slc_cli = SliceClient() if slice_client is None else slice_client self.__vnt_cli = VNTManagerClient() if vntm_client is None else vntm_client Loading Loading @@ -343,6 +352,7 @@ class DescriptorLoader: self._process_descr('service', 'add', self.__ctx_cli.SetService, Service, self.__services ) self._process_descr('slice', 'add', self.__ctx_cli.SetSlice, Slice, self.__slices ) self._process_descr('connection', 'add', self.__ctx_cli.SetConnection, Connection, self.__connections ) self._process_spine_leaf() # By default the Context component automatically assigns devices and links to topologies based on their # endpoints, and assigns topologies, services, and slices to contexts based on their identifiers. Loading Loading @@ -401,6 +411,8 @@ class DescriptorLoader: self._process_descr('slice', 'add', self.__slc_cli.CreateSlice, Slice, self.__slices_add ) self._process_descr('slice', 'update', self.__slc_cli.UpdateSlice, Slice, self.__slices ) self._process_spine_leaf() # By default the Context component automatically assigns devices and links to topologies based on their # endpoints, and assigns topologies, services, and slices to contexts based on their identifiers. Loading @@ -417,6 +429,7 @@ class DescriptorLoader: #self.__dev_cli.close() #self.__ctx_cli.close() def _logical_resource_request(self, resource_type: str, allocation: Dict) -> Any: device_uuid = str(allocation.get('device_uuid', '')) endpoint_uuid = str(allocation.get('endpoint_uuid', allocation.get('interface', ''))) Loading Loading @@ -485,6 +498,67 @@ class DescriptorLoader: self.__results.append(('logical_resource', 'add', num_ok, error_list)) def _resolve_device_uuid(self, device_identifier: str, device_map: Optional[Dict[str, str]] = None) -> Optional[str]: if not device_identifier: return None if device_map is None: device_map = {} response = self.__ctx_cli.ListDevices(Empty()) for device in response.devices: if device.HasField('device_id') and device.device_id.HasField('device_uuid'): device_uuid = device.device_id.device_uuid.uuid if device_uuid: device_map[device_uuid] = device_uuid if device.name: device_map[device.name] = device_uuid return device_map.get(device_identifier) def _process_spine_leaf(self) -> None: if len(self.__spine_leaf) == 0: return num_ok, error_list = 0, [] device_map: Dict[str, str] = {} response = self.__ctx_cli.ListDevices(Empty()) for device in response.devices: if device.HasField('device_id') and device.device_id.HasField('device_uuid'): device_uuid = device.device_id.device_uuid.uuid if device_uuid: device_map[device_uuid] = device_uuid if device.name: device_map[device.name] = device_uuid role_to_method = { 'DEVICEROLE_SPINE': self.__spl_cli.SetDeviceAsSpine, 'DEVICEROLE_LEAF': self.__spl_cli.SetDeviceAsLeaf, 'DEVICEROLE_GATEWAY': self.__spl_cli.SetDeviceAsGateway, } for fabric in self.__spine_leaf: fabric_id = str(fabric.get('fabric_id', '')) settings = fabric.get('settings', {}) if settings: LOGGER.info('SpineLeaf settings received for fabric %s: %s', fabric_id, settings) device_roles = fabric.get('device_roles', {}) for device_identifier, device_role in device_roles.items(): device_uuid = self._resolve_device_uuid(str(device_identifier), device_map) if not device_uuid: error_list.append(f'{fabric_id}/{device_identifier}: device not found') continue method = role_to_method.get(str(device_role)) if method is None: error_list.append(f'{fabric_id}/{device_identifier}: unsupported role {device_role}') continue try: method(SetDeviceRoleRequest(device_uuid=device_uuid, fabric_id=fabric_id)) num_ok += 1 except Exception as e: # pylint: disable=broad-except error_list.append(f'{fabric_id}/{device_identifier}: {str(e)}') self.__results.append(('spine_leaf', 'config', num_ok, error_list)) @staticmethod def worker(grpc_method, grpc_class, entity) -> Any: return grpc_method(grpc_class(**entity)) Loading src/webui/Dockerfile +2 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,8 @@ COPY --chown=webui:webui src/qkd_app/__init__.py qkd_app/__init__.py COPY --chown=webui:webui src/qkd_app/client/. qkd_app/client/ COPY --chown=webui:webui src/logical_resources/__init__.py logical_resources/__init__.py COPY --chown=webui:webui src/logical_resources/client/. logical_resources/client/ COPY --chown=webui:webui src/spine_leaf/__init__.py spine_leaf/__init__.py COPY --chown=webui:webui src/spine_leaf/client/. spine_leaf/client/ COPY --chown=webui:webui src/bgpls_speaker/__init__.py bgpls_speaker/__init__.py COPY --chown=webui:webui src/bgpls_speaker/client/. bgpls_speaker/client/ COPY --chown=webui:webui src/vnt_manager/__init__.py vnt_manager/__init__.py Loading Loading
src/common/tools/descriptor/Loader.py +74 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,11 @@ from common.tools.object_factory.Context import json_context_id from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from logical_resources.client.Logicalresourceclient import LogicalResourceClient from common.proto.spineleaf_pb2 import SetDeviceRoleRequest from common.tools.object_factory.Context import json_context_id from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from spine_leaf.client.SpineLeafClient import SpineLeafClient from service.client.ServiceClient import ServiceClient from slice.client.SliceClient import SliceClient from vnt_manager.client.VNTManagerClient import VNTManagerClient Loading @@ -71,6 +76,7 @@ ENTITY_TO_TEXT = { 'device' : ('Device', 'Devices' ), 'link' : ('Link', 'Links' ), 'logical_resource': ('Logical Resource', 'Logical Resources'), 'spine_leaf': ('Spine Leaf', 'Spine Leafs'), 'service' : ('Service', 'Services' ), 'slice' : ('Slice', 'Slices' ), 'connection': ('Connection', 'Connections'), Loading Loading @@ -117,6 +123,7 @@ class DescriptorLoader: num_workers : int = 1, context_client : Optional[ContextClient] = None, device_client : Optional[DeviceClient] = None, logical_resources_client : Optional[LogicalResourceClient] = None, spine_leaf_client : Optional[SpineLeafClient] = None, service_client : Optional[ServiceClient] = None, slice_client : Optional[SliceClient] = None, vntm_client : Optional[VNTManagerClient] = None ) -> None: Loading @@ -141,6 +148,7 @@ class DescriptorLoader: self.__links = self.__descriptors.get('links' , []) self.__optical_links = self.__descriptors.get('optical_links',[]) self.__logical_resources = self.__descriptors.get('logical_resources', []) self.__spine_leaf = self.__descriptors.get('spine-leaf', []) self.__services = self.__descriptors.get('services' , []) self.__slices = self.__descriptors.get('slices' , []) self.__ietf_slices = self.__descriptors.get('ietf-network-slice-service:network-slice-services', {}) Loading Loading @@ -200,6 +208,7 @@ class DescriptorLoader: self.__ctx_cli = ContextClient() if context_client is None else context_client self.__dev_cli = DeviceClient() if device_client is None else device_client self.__lrs_cli = LogicalResourceClient() if logical_resources_client is None else logical_resources_client self.__spl_cli = SpineLeafClient() if spine_leaf_client is None else spine_leaf_client self.__svc_cli = ServiceClient() if service_client is None else service_client self.__slc_cli = SliceClient() if slice_client is None else slice_client self.__vnt_cli = VNTManagerClient() if vntm_client is None else vntm_client Loading Loading @@ -343,6 +352,7 @@ class DescriptorLoader: self._process_descr('service', 'add', self.__ctx_cli.SetService, Service, self.__services ) self._process_descr('slice', 'add', self.__ctx_cli.SetSlice, Slice, self.__slices ) self._process_descr('connection', 'add', self.__ctx_cli.SetConnection, Connection, self.__connections ) self._process_spine_leaf() # By default the Context component automatically assigns devices and links to topologies based on their # endpoints, and assigns topologies, services, and slices to contexts based on their identifiers. Loading Loading @@ -401,6 +411,8 @@ class DescriptorLoader: self._process_descr('slice', 'add', self.__slc_cli.CreateSlice, Slice, self.__slices_add ) self._process_descr('slice', 'update', self.__slc_cli.UpdateSlice, Slice, self.__slices ) self._process_spine_leaf() # By default the Context component automatically assigns devices and links to topologies based on their # endpoints, and assigns topologies, services, and slices to contexts based on their identifiers. Loading @@ -417,6 +429,7 @@ class DescriptorLoader: #self.__dev_cli.close() #self.__ctx_cli.close() def _logical_resource_request(self, resource_type: str, allocation: Dict) -> Any: device_uuid = str(allocation.get('device_uuid', '')) endpoint_uuid = str(allocation.get('endpoint_uuid', allocation.get('interface', ''))) Loading Loading @@ -485,6 +498,67 @@ class DescriptorLoader: self.__results.append(('logical_resource', 'add', num_ok, error_list)) def _resolve_device_uuid(self, device_identifier: str, device_map: Optional[Dict[str, str]] = None) -> Optional[str]: if not device_identifier: return None if device_map is None: device_map = {} response = self.__ctx_cli.ListDevices(Empty()) for device in response.devices: if device.HasField('device_id') and device.device_id.HasField('device_uuid'): device_uuid = device.device_id.device_uuid.uuid if device_uuid: device_map[device_uuid] = device_uuid if device.name: device_map[device.name] = device_uuid return device_map.get(device_identifier) def _process_spine_leaf(self) -> None: if len(self.__spine_leaf) == 0: return num_ok, error_list = 0, [] device_map: Dict[str, str] = {} response = self.__ctx_cli.ListDevices(Empty()) for device in response.devices: if device.HasField('device_id') and device.device_id.HasField('device_uuid'): device_uuid = device.device_id.device_uuid.uuid if device_uuid: device_map[device_uuid] = device_uuid if device.name: device_map[device.name] = device_uuid role_to_method = { 'DEVICEROLE_SPINE': self.__spl_cli.SetDeviceAsSpine, 'DEVICEROLE_LEAF': self.__spl_cli.SetDeviceAsLeaf, 'DEVICEROLE_GATEWAY': self.__spl_cli.SetDeviceAsGateway, } for fabric in self.__spine_leaf: fabric_id = str(fabric.get('fabric_id', '')) settings = fabric.get('settings', {}) if settings: LOGGER.info('SpineLeaf settings received for fabric %s: %s', fabric_id, settings) device_roles = fabric.get('device_roles', {}) for device_identifier, device_role in device_roles.items(): device_uuid = self._resolve_device_uuid(str(device_identifier), device_map) if not device_uuid: error_list.append(f'{fabric_id}/{device_identifier}: device not found') continue method = role_to_method.get(str(device_role)) if method is None: error_list.append(f'{fabric_id}/{device_identifier}: unsupported role {device_role}') continue try: method(SetDeviceRoleRequest(device_uuid=device_uuid, fabric_id=fabric_id)) num_ok += 1 except Exception as e: # pylint: disable=broad-except error_list.append(f'{fabric_id}/{device_identifier}: {str(e)}') self.__results.append(('spine_leaf', 'config', num_ok, error_list)) @staticmethod def worker(grpc_method, grpc_class, entity) -> Any: return grpc_method(grpc_class(**entity)) Loading
src/webui/Dockerfile +2 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,8 @@ COPY --chown=webui:webui src/qkd_app/__init__.py qkd_app/__init__.py COPY --chown=webui:webui src/qkd_app/client/. qkd_app/client/ COPY --chown=webui:webui src/logical_resources/__init__.py logical_resources/__init__.py COPY --chown=webui:webui src/logical_resources/client/. logical_resources/client/ COPY --chown=webui:webui src/spine_leaf/__init__.py spine_leaf/__init__.py COPY --chown=webui:webui src/spine_leaf/client/. spine_leaf/client/ COPY --chown=webui:webui src/bgpls_speaker/__init__.py bgpls_speaker/__init__.py COPY --chown=webui:webui src/bgpls_speaker/client/. bgpls_speaker/client/ COPY --chown=webui:webui src/vnt_manager/__init__.py vnt_manager/__init__.py Loading