diff --git a/src/pathcomp/frontend/service/algorithms/KDisjointPathAlgorithm.py b/src/pathcomp/frontend/service/algorithms/KDisjointPathAlgorithm.py index 76b49bc8bd4a5ded840ccad13f0941d05070d344..6a80fe698d04aa1e74ef501e6ca97b3d80bb5ad0 100644 --- a/src/pathcomp/frontend/service/algorithms/KDisjointPathAlgorithm.py +++ b/src/pathcomp/frontend/service/algorithms/KDisjointPathAlgorithm.py @@ -63,7 +63,9 @@ class KDisjointPathAlgorithm(_Algorithm): if constraint.WhichOneof('constraint') == 'endpoint_location': endpoint_id = constraint.endpoint_location.endpoint_id 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 = self.endpoint_name_mapping.get((device_uuid, endpoint_uuid), endpoint_uuid) location_kind = constraint.endpoint_location.location.WhichOneof('location') if location_kind != 'region': MSG = 'Unsupported LocationType({:s}) in Constraint({:s})' @@ -74,7 +76,9 @@ class KDisjointPathAlgorithm(_Algorithm): if constraint.WhichOneof('constraint') == 'endpoint_priority': endpoint_id = constraint.endpoint_priority.endpoint_id 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 = self.endpoint_name_mapping.get((device_uuid, endpoint_uuid), endpoint_uuid) priority = constraint.endpoint_priority.priority endpoints.setdefault((device_uuid, endpoint_uuid), dict())['priority'] = priority @@ -116,8 +120,10 @@ class KDisjointPathAlgorithm(_Algorithm): algorithm = KShortestPathAlgorithm(Algorithm_KShortestPath(k_inspection=0, k_return=1)) algorithm.sync_paths = True algorithm.device_list = self.device_list + algorithm.device_name_mapping = self.device_name_mapping algorithm.device_dict = self.device_dict algorithm.endpoint_dict = self.endpoint_dict + algorithm.endpoint_name_mapping = self.endpoint_name_mapping algorithm.link_list = self.link_list algorithm.link_dict = self.link_dict algorithm.endpoint_to_link_dict = self.endpoint_to_link_dict @@ -139,6 +145,7 @@ class KDisjointPathAlgorithm(_Algorithm): _service.service_id.context_id.context_uuid.uuid = service_key[0] _service.service_id.service_uuid.uuid = service_key[1] _service.service_type = service_type + for constraint_type, constraint_value in constraints.items(): constraint = _service.service_constraints.add() constraint.custom.constraint_type = constraint_type diff --git a/src/pathcomp/frontend/service/algorithms/_Algorithm.py b/src/pathcomp/frontend/service/algorithms/_Algorithm.py index bf19ed3e10affd707b5032428efce154e05d4169..c4c8efcd7dce4524764ca8fd251f0d9bf2b99d10 100644 --- a/src/pathcomp/frontend/service/algorithms/_Algorithm.py +++ b/src/pathcomp/frontend/service/algorithms/_Algorithm.py @@ -40,7 +40,9 @@ class _Algorithm: self.device_list : List[Dict] = list() 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_name_mapping : Dict[Tuple[str, str], str] = dict() self.link_list : List[Dict] = list() self.link_dict : Dict[str, Tuple[Dict, Link]] = dict() self.endpoint_to_link_dict : Dict[Tuple[str, str], Tuple[Dict, Link]] = dict() @@ -56,12 +58,21 @@ class _Algorithm: device_uuid = json_device['device_Id'] 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() for json_endpoint,grpc_endpoint in zip(json_device['device_endpoints'], grpc_device.device_endpoints): endpoint_uuid = json_endpoint['endpoint_id']['endpoint_uuid'] endpoint_tuple = (json_endpoint['endpoint_id'], grpc_endpoint.endpoint_id) 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 def add_links(self, grpc_links : Union[List[Link], LinkList]) -> None: