diff --git a/src/common/tools/descriptor/Loader.py b/src/common/tools/descriptor/Loader.py index 958536f26c3c63468f1af4a6d14130b6e12fd08f..fea8e24e412976b9aef17758142970f58b46f760 100644 --- a/src/common/tools/descriptor/Loader.py +++ b/src/common/tools/descriptor/Loader.py @@ -133,11 +133,11 @@ class DescriptorLoader: self.__topologies = self.__descriptors.get('topologies' , []) self.__devices = self.__descriptors.get('devices' , []) self.__links = self.__descriptors.get('links' , []) + self.__optical_links = self.__descriptors.get('optical_links',[]) 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', {}) self.__connections = self.__descriptors.get('connections', []) - self.__optical_links = self.__descriptors.get('optical_links',[]) if len(self.__ietf_slices) > 0: for slice_service in self.__ietf_slices["slice-service"]: @@ -249,6 +249,12 @@ class DescriptorLoader: @property def num_links(self) -> int: return len(self.__links) + @property + def optical_links(self) -> List[Dict]: return self.__optical_links + + @property + def num_optical_links(self) -> int: return len(self.__optical_links) + @property def services(self) -> Dict[str, List[Dict]]: _services = {} @@ -286,9 +292,6 @@ class DescriptorLoader: @property def num_connections(self) -> int: return len(self.__connections) - - @property - def optical_links(self) -> List[Dict]: return self.__optical_links def process(self) -> TypeResults: # Format CustomConfigRules in Devices, Services and Slices provided in JSON format @@ -314,14 +317,15 @@ class DescriptorLoader: controllers, network_devices = split_controllers_and_network_devices(self.__devices) self.__ctx_cli.connect() - self._process_descr('context', 'add', self.__ctx_cli.SetContext, Context, self.__contexts_add ) - self._process_descr('topology', 'add', self.__ctx_cli.SetTopology, Topology, self.__topologies_add) - self._process_descr('controller', 'add', self.__ctx_cli.SetDevice, Device, controllers ) - self._process_descr('device', 'add', self.__ctx_cli.SetDevice, Device, network_devices ) - self._process_descr('link', 'add', self.__ctx_cli.SetLink, Link, self.__links ) - 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_descr('context', 'add', self.__ctx_cli.SetContext, Context, self.__contexts_add ) + self._process_descr('topology', 'add', self.__ctx_cli.SetTopology, Topology, self.__topologies_add) + self._process_descr('controller', 'add', self.__ctx_cli.SetDevice, Device, controllers ) + self._process_descr('device', 'add', self.__ctx_cli.SetDevice, Device, network_devices ) + self._process_descr('link', 'add', self.__ctx_cli.SetLink, Link, self.__links ) + self._process_descr('link', 'add', self.__ctx_cli.SetOpticalLink, OpticalLink, self.__optical_links ) + 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 ) # 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. @@ -358,11 +362,11 @@ class DescriptorLoader: self._process_descr('device', 'add', self.__dev_cli.AddDevice, Device, network_devices_add ) self._process_descr('device', 'config', self.__dev_cli.ConfigureDevice, Device, self.__devices_config) self._process_descr('link', 'add', self.__ctx_cli.SetLink, Link, self.__links ) + self._process_descr('link', 'add', self.__ctx_cli.SetOpticalLink, OpticalLink, self.__optical_links ) self._process_descr('service', 'add', self.__svc_cli.CreateService, Service, self.__services_add ) self._process_descr('service', 'update', self.__svc_cli.UpdateService, Service, self.__services ) 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_descr('link', 'add', self.__ctx_cli.SetOpticalLink, OpticalLink, self.__optical_links ) # 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. @@ -420,6 +424,9 @@ class DescriptorLoader: response = self.__ctx_cli.ListLinks(Empty()) assert len(response.links) == self.num_links + response = self.__ctx_cli.GetOpticalLinkList(Empty()) + assert len(response.optical_links) == self.num_links + for context_uuid, num_services in self.num_services.items(): response = self.__ctx_cli.ListServices(ContextId(**json_context_id(context_uuid))) assert len(response.services) == num_services @@ -440,6 +447,9 @@ class DescriptorLoader: for service in service_list: self.__ctx_cli.RemoveService(ServiceId(**service['service_id'])) + for optical_link in self.optical_links: + self.__ctx_cli.DeleteOpticalLink(LinkId(**optical_link['link_id'])) + for link in self.links: self.__ctx_cli.RemoveLink(LinkId(**link['link_id'])) @@ -470,6 +480,9 @@ class DescriptorLoader: for service in service_list: self.__svc_cli.DeleteService(ServiceId(**service['service_id'])) + for optical_link in self.optical_links: + self.__ctx_cli.DeleteOpticalLink(LinkId(**optical_link['link_id'])) + for link in self.links: self.__ctx_cli.RemoveLink(LinkId(**link['link_id'])) @@ -524,3 +537,6 @@ def validate_empty_scenario(context_client : ContextClient) -> None: response = context_client.ListLinks(Empty()) assert len(response.links) == 0 + + response = context_client.GetOpticalLinkList(Empty()) + assert len(response.optical_links) == 0