Commit cdc9c97c authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Pre-merge code fixes and cleanup

parent 67c89954
Loading
Loading
Loading
Loading
+29 −13
Original line number Diff line number Diff line
@@ -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 = {}
@@ -287,9 +293,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
        self.__devices  = [format_device_custom_config_rules (device ) for device  in self.__devices ]
@@ -319,6 +322,7 @@ class DescriptorLoader:
        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   )
@@ -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