diff --git a/src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py b/src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py index 728bb58c8a8f09df4a26a792d204a9e9753481e3..053e6d542788e5231e48ee17fde88d31c186a86b 100644 --- a/src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py +++ b/src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py @@ -63,11 +63,11 @@ class ConnectionEntry: path_hops : List[Dict] = field(default_factory=list) dependencies : List[str] = field(default_factory=list) - def __post_init__(self) -> None: - if self.uuid != '': - return - composed_string = '-'.join(f'{path_hop["device"]}/{path_hop["ingress_ep"]}/{path_hop["egress_ep"]}' for path_hop in self.path_hops) - self.sub_service_uuid = get_uuid_from_string(composed_string) + def calculate_subservice_uuid(self, main_service_uuid: str) -> None: + composed_string = main_service_uuid + '-'.join( + f'{path_hop["device"]}/{path_hop["ingress_ep"]}/{path_hop["egress_ep"]}' for path_hop in self.path_hops + ) + self.uuid = get_uuid_from_string(composed_string) def convert_explicit_path_hops_to_connections( path_hops : List[Dict], device_dict : Dict[str, Tuple[Dict, Device]], @@ -103,6 +103,7 @@ def convert_explicit_path_hops_to_connections( prv_service_type = connection_stack.queue[-1].service_type service_type = get_service_type(res_class[1], prv_service_type) connection_entry = ConnectionEntry(service_type=service_type, path_hops=[path_hop]) + connection_entry.calculate_subservice_uuid(main_service_uuid) connection_stack.put(connection_entry) # underlying connection ended @@ -116,6 +117,7 @@ def convert_explicit_path_hops_to_connections( prv_service_type = connection_stack.queue[-1].service_type service_type = get_service_type(res_class[1], prv_service_type) connection_entry = ConnectionEntry(service_type=service_type, path_hops=[path_hop]) + connection_entry.calculate_subservice_uuid(main_service_uuid) connection_stack.put(connection_entry) elif prv_res_class[2] is not None and res_class[2] is None: # leaving domain of a device controller, terminate underlying connection @@ -139,6 +141,7 @@ def convert_explicit_path_hops_to_connections( prv_service_type = connection_stack.queue[-1].service_type service_type = get_service_type(res_class[1], prv_service_type) connection_entry = ConnectionEntry(service_type=service_type, path_hops=[path_hop]) + connection_entry.calculate_subservice_uuid (main_service_uuid) connection_stack.put(connection_entry) elif prv_res_class[0] is None: # path ingress @@ -151,6 +154,7 @@ def convert_explicit_path_hops_to_connections( prv_service_type = connection_stack.queue[-1].service_type service_type = get_service_type(res_class[1], prv_service_type) connection_entry = ConnectionEntry(service_type=service_type, path_hops=[path_hop]) + connection_entry.calculate_subservice_uuid(main_service_uuid) connection_stack.put(connection_entry) elif prv_res_class[0] == res_class[0]: # same resource group kind @@ -169,6 +173,7 @@ def convert_explicit_path_hops_to_connections( prv_service_type = connection_stack.queue[-1].service_type service_type = get_service_type(res_class[1], prv_service_type) connection_entry = ConnectionEntry(service_type=service_type, path_hops=[path_hop]) + connection_entry.calculate_subservice_uuid(main_service_uuid) connection_stack.put(connection_entry) elif prv_res_class[0] < res_class[0]: # underlying connection ended