From 7ccdba0ad8e4e5838f0dfbc524753aa86fca911a Mon Sep 17 00:00:00 2001
From: gifrerenom <lluis.gifre@cttc.es>
Date: Thu, 29 Jun 2023 13:58:01 +0000
Subject: [PATCH] PathComp component:

- Added logic to extrapolate underlyign connections for remote domains
---
 .../algorithms/tools/ComputeSubServices.py     | 18 ++++++++++++++++--
 .../service/algorithms/tools/ResourceGroups.py |  1 +
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py b/src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py
index 8ffdfaf3e..dedc6f9c6 100644
--- a/src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py
+++ b/src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py
@@ -49,7 +49,7 @@ import logging, queue, uuid
 from typing import Dict, List, Optional, Tuple
 from common.DeviceTypes import DeviceTypeEnum
 from common.proto.context_pb2 import Device, ServiceTypeEnum
-from .ResourceGroups import IGNORED_DEVICE_TYPES, get_resource_classification
+from .ResourceGroups import IGNORED_DEVICE_TYPES, REMOTEDOMAIN_DEVICE_TYPES, get_resource_classification
 from .ServiceTypes import get_service_type
 
 LOGGER = logging.getLogger(__name__)
@@ -81,7 +81,21 @@ def convert_explicit_path_hops_to_connections(
             LOGGER.debug('  ignored')
             continue
 
-        if prv_res_class[0] is None:
+        if res_class[1] in REMOTEDOMAIN_DEVICE_TYPES:
+            LOGGER.debug('  create and terminate underlying connection')
+
+            # create underlying connection
+            connection_uuid = str(uuid.uuid4())
+            prv_service_type = connection_stack.queue[-1][1]
+            service_type = get_service_type(res_class[1], prv_service_type)
+            connection_stack.put((connection_uuid, service_type, [path_hop], []))
+
+            # underlying connection ended
+            connection = connection_stack.get()
+            connections.append(connection)
+            connection_stack.queue[-1][3].append(connection[0])
+            #connection_stack.queue[-1][2].append(path_hop)
+        elif prv_res_class[0] is None:
             # path ingress
             LOGGER.debug('  path ingress')
             connection_stack.put((main_service_uuid, main_service_type, [path_hop], []))
diff --git a/src/pathcomp/frontend/service/algorithms/tools/ResourceGroups.py b/src/pathcomp/frontend/service/algorithms/tools/ResourceGroups.py
index 6f723009c..843c41803 100644
--- a/src/pathcomp/frontend/service/algorithms/tools/ResourceGroups.py
+++ b/src/pathcomp/frontend/service/algorithms/tools/ResourceGroups.py
@@ -53,6 +53,7 @@ DEVICE_TYPE_TO_DEEPNESS = {
 }
 
 IGNORED_DEVICE_TYPES = {DeviceTypeEnum.EMULATED_OPTICAL_SPLITTER}
+REMOTEDOMAIN_DEVICE_TYPES = {DeviceTypeEnum.NETWORK}
 
 def get_device_controller_uuid(
     device : Device
-- 
GitLab