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

PathComp component:

- updated mappings from name to UUID in devices and endpoints
parent 1e645f9c
No related branches found
No related tags found
2 merge requests!54Release 2.0.0,!48Fixes for OFC'22 and ECOC'22 tests
...@@ -63,7 +63,9 @@ class KDisjointPathAlgorithm(_Algorithm): ...@@ -63,7 +63,9 @@ class KDisjointPathAlgorithm(_Algorithm):
if constraint.WhichOneof('constraint') == 'endpoint_location': if constraint.WhichOneof('constraint') == 'endpoint_location':
endpoint_id = constraint.endpoint_location.endpoint_id endpoint_id = constraint.endpoint_location.endpoint_id
device_uuid = endpoint_id.device_id.device_uuid.uuid device_uuid = endpoint_id.device_id.device_uuid.uuid
device_uuid = self.device_name_mapping.get(device_uuid, device_uuid)
endpoint_uuid = endpoint_id.endpoint_uuid.uuid endpoint_uuid = endpoint_id.endpoint_uuid.uuid
endpoint_uuid = self.endpoint_name_mapping.get((device_uuid, endpoint_uuid), endpoint_uuid)
location_kind = constraint.endpoint_location.location.WhichOneof('location') location_kind = constraint.endpoint_location.location.WhichOneof('location')
if location_kind != 'region': if location_kind != 'region':
MSG = 'Unsupported LocationType({:s}) in Constraint({:s})' MSG = 'Unsupported LocationType({:s}) in Constraint({:s})'
...@@ -74,7 +76,9 @@ class KDisjointPathAlgorithm(_Algorithm): ...@@ -74,7 +76,9 @@ class KDisjointPathAlgorithm(_Algorithm):
if constraint.WhichOneof('constraint') == 'endpoint_priority': if constraint.WhichOneof('constraint') == 'endpoint_priority':
endpoint_id = constraint.endpoint_priority.endpoint_id endpoint_id = constraint.endpoint_priority.endpoint_id
device_uuid = endpoint_id.device_id.device_uuid.uuid device_uuid = endpoint_id.device_id.device_uuid.uuid
device_uuid = self.device_name_mapping.get(device_uuid, device_uuid)
endpoint_uuid = endpoint_id.endpoint_uuid.uuid endpoint_uuid = endpoint_id.endpoint_uuid.uuid
endpoint_uuid = self.endpoint_name_mapping.get((device_uuid, endpoint_uuid), endpoint_uuid)
priority = constraint.endpoint_priority.priority priority = constraint.endpoint_priority.priority
endpoints.setdefault((device_uuid, endpoint_uuid), dict())['priority'] = priority endpoints.setdefault((device_uuid, endpoint_uuid), dict())['priority'] = priority
...@@ -116,8 +120,10 @@ class KDisjointPathAlgorithm(_Algorithm): ...@@ -116,8 +120,10 @@ class KDisjointPathAlgorithm(_Algorithm):
algorithm = KShortestPathAlgorithm(Algorithm_KShortestPath(k_inspection=0, k_return=1)) algorithm = KShortestPathAlgorithm(Algorithm_KShortestPath(k_inspection=0, k_return=1))
algorithm.sync_paths = True algorithm.sync_paths = True
algorithm.device_list = self.device_list algorithm.device_list = self.device_list
algorithm.device_name_mapping = self.device_name_mapping
algorithm.device_dict = self.device_dict algorithm.device_dict = self.device_dict
algorithm.endpoint_dict = self.endpoint_dict algorithm.endpoint_dict = self.endpoint_dict
algorithm.endpoint_name_mapping = self.endpoint_name_mapping
algorithm.link_list = self.link_list algorithm.link_list = self.link_list
algorithm.link_dict = self.link_dict algorithm.link_dict = self.link_dict
algorithm.endpoint_to_link_dict = self.endpoint_to_link_dict algorithm.endpoint_to_link_dict = self.endpoint_to_link_dict
...@@ -139,6 +145,7 @@ class KDisjointPathAlgorithm(_Algorithm): ...@@ -139,6 +145,7 @@ class KDisjointPathAlgorithm(_Algorithm):
_service.service_id.context_id.context_uuid.uuid = service_key[0] _service.service_id.context_id.context_uuid.uuid = service_key[0]
_service.service_id.service_uuid.uuid = service_key[1] _service.service_id.service_uuid.uuid = service_key[1]
_service.service_type = service_type _service.service_type = service_type
for constraint_type, constraint_value in constraints.items(): for constraint_type, constraint_value in constraints.items():
constraint = _service.service_constraints.add() constraint = _service.service_constraints.add()
constraint.custom.constraint_type = constraint_type constraint.custom.constraint_type = constraint_type
......
...@@ -40,7 +40,9 @@ class _Algorithm: ...@@ -40,7 +40,9 @@ class _Algorithm:
self.device_list : List[Dict] = list() self.device_list : List[Dict] = list()
self.device_dict : Dict[str, Tuple[Dict, Device]] = dict() self.device_dict : Dict[str, Tuple[Dict, Device]] = dict()
self.device_name_mapping : Dict[str, str] = dict()
self.endpoint_dict : Dict[str, Dict[str, Tuple[Dict, EndPointId]]] = dict() self.endpoint_dict : Dict[str, Dict[str, Tuple[Dict, EndPointId]]] = dict()
self.endpoint_name_mapping : Dict[Tuple[str, str], str] = dict()
self.link_list : List[Dict] = list() self.link_list : List[Dict] = list()
self.link_dict : Dict[str, Tuple[Dict, Link]] = dict() self.link_dict : Dict[str, Tuple[Dict, Link]] = dict()
self.endpoint_to_link_dict : Dict[Tuple[str, str], Tuple[Dict, Link]] = dict() self.endpoint_to_link_dict : Dict[Tuple[str, str], Tuple[Dict, Link]] = dict()
...@@ -56,12 +58,21 @@ class _Algorithm: ...@@ -56,12 +58,21 @@ class _Algorithm:
device_uuid = json_device['device_Id'] device_uuid = json_device['device_Id']
self.device_dict[device_uuid] = (json_device, grpc_device) self.device_dict[device_uuid] = (json_device, grpc_device)
_device_uuid = grpc_device.device_id.device_uuid.uuid
_device_name = grpc_device.name
self.device_name_mapping[_device_name] = _device_uuid
device_endpoint_dict : Dict[str, Tuple[Dict, EndPointId]] = dict() device_endpoint_dict : Dict[str, Tuple[Dict, EndPointId]] = dict()
for json_endpoint,grpc_endpoint in zip(json_device['device_endpoints'], grpc_device.device_endpoints): for json_endpoint,grpc_endpoint in zip(json_device['device_endpoints'], grpc_device.device_endpoints):
endpoint_uuid = json_endpoint['endpoint_id']['endpoint_uuid'] endpoint_uuid = json_endpoint['endpoint_id']['endpoint_uuid']
endpoint_tuple = (json_endpoint['endpoint_id'], grpc_endpoint.endpoint_id) endpoint_tuple = (json_endpoint['endpoint_id'], grpc_endpoint.endpoint_id)
device_endpoint_dict[endpoint_uuid] = endpoint_tuple device_endpoint_dict[endpoint_uuid] = endpoint_tuple
_endpoint_uuid = grpc_endpoint.endpoint_id.endpoint_uuid.uuid
_endpoint_name = grpc_endpoint.name
self.endpoint_name_mapping[(_device_uuid, _endpoint_name)] = _endpoint_uuid
self.endpoint_name_mapping[(_device_name, _endpoint_name)] = _endpoint_uuid
self.endpoint_dict[device_uuid] = device_endpoint_dict self.endpoint_dict[device_uuid] = device_endpoint_dict
def add_links(self, grpc_links : Union[List[Link], LinkList]) -> None: def add_links(self, grpc_links : Union[List[Link], LinkList]) -> None:
......
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