From a377af3d7a34c46e729d7edd5dab35f419c96385 Mon Sep 17 00:00:00 2001
From: gifrerenom <lluis.gifre@cttc.es>
Date: Mon, 17 Mar 2025 19:21:20 +0000
Subject: [PATCH] Service component:

- Added translation of UUID to name for optical connection endpoint devices
- Extended Task_ConnectionConfigure to delegate on remote TeraFlowSDN controllers when needed
---
 src/service/service/ServiceServiceServicerImpl.py | 12 ++++++++++--
 .../tasks/Task_ConnectionConfigure.py             | 15 +++++++++------
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/service/service/ServiceServiceServicerImpl.py b/src/service/service/ServiceServiceServicerImpl.py
index b6f8a7faf..9a9bd27df 100644
--- a/src/service/service/ServiceServiceServicerImpl.py
+++ b/src/service/service/ServiceServiceServicerImpl.py
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 import grpc, json, logging, random, uuid
-from typing import Optional
+from typing import Dict, Optional
 from common.method_wrappers.Decorator import MetricsPool, safe_and_metered_rpc_method
 from common.method_wrappers.ServiceExceptions import (
     AlreadyExistsException, InvalidArgumentException, NotFoundException, NotImplementedException,
@@ -265,10 +265,18 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
             devices = topology_details.devices
             context_uuid_x = topology_details.topology_id.context_id.context_uuid.uuid
             topology_uuid_x = topology_details.topology_id.topology_uuid.uuid
+
+            device_names : Dict[str, str] = dict()
+            for device in devices:
+                device_uuid = device.device_id.device_uuid.uuid
+                device_names[device_uuid] = device.name
+
             devs = []
             ports = []
             for endpoint_id in service.service_endpoint_ids:
-                devs.append(endpoint_id.device_id.device_uuid.uuid)
+                endpoint_device_uuid = endpoint_id.device_id.device_uuid.uuid
+                endpoint_device_name = device_names[endpoint_device_uuid]
+                devs.append(endpoint_device_name)
                 ports.append(endpoint_id.endpoint_uuid.uuid)
             src = devs[0]
             dst = devs[1]
diff --git a/src/service/service/task_scheduler/tasks/Task_ConnectionConfigure.py b/src/service/service/task_scheduler/tasks/Task_ConnectionConfigure.py
index fac991432..d98daf280 100644
--- a/src/service/service/task_scheduler/tasks/Task_ConnectionConfigure.py
+++ b/src/service/service/task_scheduler/tasks/Task_ConnectionConfigure.py
@@ -56,12 +56,15 @@ class Task_ConnectionConfigure(_Task):
         endpointids_to_set = endpointids_to_raw(connection.path_hops_endpoint_ids)
 
         errors = list()
-        for _, (service_handler, connection_devices) in service_handlers.items():
-            _endpointids_to_set = [
-                (device_uuid, endpoint_uuid, topology_uuid)
-                for device_uuid, endpoint_uuid, topology_uuid in endpointids_to_set
-                if device_uuid in connection_devices
-            ]
+        for device_type, (service_handler, connection_devices) in service_handlers.items():
+            if device_type == DeviceTypeEnum.TERAFLOWSDN_CONTROLLER:
+                _endpointids_to_set = endpointids_to_set
+            else:
+                _endpointids_to_set = [
+                    (device_uuid, endpoint_uuid, topology_uuid)
+                    for device_uuid, endpoint_uuid, topology_uuid in endpointids_to_set
+                    if device_uuid in connection_devices
+                ]
             results_setendpoint = service_handler.SetEndpoint(
                 _endpointids_to_set, connection_uuid=connection_uuid
             )
-- 
GitLab