From b055fc3fca2cec9c57c4f9a6b0f6172cb8e495ab Mon Sep 17 00:00:00 2001
From: gifrerenom <lluis.gifre@cttc.es>
Date: Tue, 18 Mar 2025 16:27:34 +0000
Subject: [PATCH] Service component:

- Corrected ConnectionDeconfigure task to enable management of underlaying TFS controllers
- Enhanced DeleteService to identify if optical controller is present
---
 src/service/service/ServiceServiceServicerImpl.py |  2 +-
 .../tasks/Task_ConnectionDeconfigure.py           | 15 +++++++++------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/service/service/ServiceServiceServicerImpl.py b/src/service/service/ServiceServiceServicerImpl.py
index 9a9bd27df..3a376c014 100644
--- a/src/service/service/ServiceServiceServicerImpl.py
+++ b/src/service/service/ServiceServiceServicerImpl.py
@@ -367,7 +367,7 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
             context_client.RemoveService(request)
             return Empty()
 
-        if service.service_type == ServiceTypeEnum.SERVICETYPE_OPTICAL_CONNECTIVITY:
+        if is_deployed_optical() and service.service_type == ServiceTypeEnum.SERVICETYPE_OPTICAL_CONNECTIVITY:
             params = {
                 "src"     : None,
                 "dst"     : None,
diff --git a/src/service/service/task_scheduler/tasks/Task_ConnectionDeconfigure.py b/src/service/service/task_scheduler/tasks/Task_ConnectionDeconfigure.py
index cb1e91cc2..8528f8365 100644
--- a/src/service/service/task_scheduler/tasks/Task_ConnectionDeconfigure.py
+++ b/src/service/service/task_scheduler/tasks/Task_ConnectionDeconfigure.py
@@ -56,12 +56,15 @@ class Task_ConnectionDeconfigure(_Task):
         endpointids_to_delete = endpointids_to_raw(connection.path_hops_endpoint_ids)
 
         errors = list()
-        for _, (service_handler, connection_devices) in service_handlers.items():
-            _endpointids_to_delete = [
-                (device_uuid, endpoint_uuid, topology_uuid)
-                for device_uuid, endpoint_uuid, topology_uuid in endpointids_to_delete
-                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_delete = endpointids_to_delete
+            else:
+                _endpointids_to_delete = [
+                    (device_uuid, endpoint_uuid, topology_uuid)
+                    for device_uuid, endpoint_uuid, topology_uuid in endpointids_to_delete
+                    if device_uuid in connection_devices
+                ]
             results_deleteendpoint = service_handler.DeleteEndpoint(
                 _endpointids_to_delete, connection_uuid=connection_uuid
             )
-- 
GitLab