From 9f1b13b1cd7a40fab36332ef6a3b5837aa61c563 Mon Sep 17 00:00:00 2001
From: hajipour <shajipour@cttc.es>
Date: Mon, 17 Mar 2025 18:33:40 +0100
Subject: [PATCH] debug: main service uuid added to the prefix of the hash
 function of the subservices, __post_init__ changed to a method tha is called
 in the code

---
 .../algorithms/tools/ComputeSubServices.py        | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py b/src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py
index 728bb58c8..053e6d542 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
-- 
GitLab