Skip to content
Snippets Groups Projects
Commit cdc9c97c authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Pre-merge code fixes and cleanup

parent 67c89954
No related branches found
No related tags found
2 merge requests!294Release TeraFlowSDN 4.0,!285Resolve: "(CNIT) New SBI Driver based on OpenROADM for ROADMs"
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment