From 222c46e1bcd32660eefd2aeaf68e1b9e61788b21 Mon Sep 17 00:00:00 2001
From: gifrerenom <lluis.gifre@cttc.es>
Date: Tue, 30 Jan 2024 12:00:23 +0000
Subject: [PATCH] PathComp component - Frontend:

- Added IP SDN Ctrl as a packet device in sub-service composer and resource groups
- Added logic to separate connections managed by intermediate SDN controllers
---
 .../algorithms/tools/ComputeSubServices.py    | 30 +++++++++++++++++++
 .../algorithms/tools/ResourceGroups.py        |  3 ++
 .../service/algorithms/tools/ServiceTypes.py  |  1 +
 3 files changed, 34 insertions(+)

diff --git a/src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py b/src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py
index 06b24031b..86a91d00a 100644
--- a/src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py
+++ b/src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py
@@ -95,6 +95,36 @@ def convert_explicit_path_hops_to_connections(
             connections.append(connection)
             connection_stack.queue[-1][3].append(connection[0])
             #connection_stack.queue[-1][2].append(path_hop)
+        elif prv_res_class[2] is None and res_class[2] is not None:
+            # entering domain of a device controller, create underlying connection
+            LOGGER.debug('  entering domain of a device controller, create underlying connection')
+            sub_service_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((sub_service_uuid, service_type, [path_hop], []))
+        elif prv_res_class[2] is not None and res_class[2] is None:
+            # leaving domain of a device controller, terminate underlying connection
+            LOGGER.debug('  leaving domain of a device controller, terminate underlying connection')
+            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[2] is not None and res_class[2] is not None:
+            if prv_res_class[2] == res_class[2]:
+                # stay in domain of a device controller, connection continues
+                LOGGER.debug('  stay in domain of a device controller, connection continues')
+                connection_stack.queue[-1][2].append(path_hop)
+            else:
+                # switching to different device controller, chain connections
+                LOGGER.debug('  switching to different device controller, chain connections')
+                connection = connection_stack.get()
+                connections.append(connection)
+                connection_stack.queue[-1][3].append(connection[0])
+
+                sub_service_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((sub_service_uuid, service_type, [path_hop], []))
         elif prv_res_class[0] is None:
             # path ingress
             LOGGER.debug('  path ingress')
diff --git a/src/pathcomp/frontend/service/algorithms/tools/ResourceGroups.py b/src/pathcomp/frontend/service/algorithms/tools/ResourceGroups.py
index 843c41803..7b5221c88 100644
--- a/src/pathcomp/frontend/service/algorithms/tools/ResourceGroups.py
+++ b/src/pathcomp/frontend/service/algorithms/tools/ResourceGroups.py
@@ -24,6 +24,9 @@ DEVICE_TYPE_TO_DEEPNESS = {
     DeviceTypeEnum.DATACENTER.value                      : 90,
 
     DeviceTypeEnum.TERAFLOWSDN_CONTROLLER.value          : 80,
+    DeviceTypeEnum.EMULATED_IP_SDN_CONTROLLER.value      : 80,
+    DeviceTypeEnum.IP_SDN_CONTROLLER.value               : 80,
+
     DeviceTypeEnum.EMULATED_PACKET_ROUTER.value          : 70,
     DeviceTypeEnum.PACKET_ROUTER.value                   : 70,
 
diff --git a/src/pathcomp/frontend/service/algorithms/tools/ServiceTypes.py b/src/pathcomp/frontend/service/algorithms/tools/ServiceTypes.py
index 73a741ae5..094baa1a6 100644
--- a/src/pathcomp/frontend/service/algorithms/tools/ServiceTypes.py
+++ b/src/pathcomp/frontend/service/algorithms/tools/ServiceTypes.py
@@ -22,6 +22,7 @@ NETWORK_DEVICE_TYPES = {
 
 PACKET_DEVICE_TYPES = {
     DeviceTypeEnum.TERAFLOWSDN_CONTROLLER,
+    DeviceTypeEnum.IP_SDN_CONTROLLER, DeviceTypeEnum.EMULATED_IP_SDN_CONTROLLER,
     DeviceTypeEnum.PACKET_ROUTER, DeviceTypeEnum.EMULATED_PACKET_ROUTER,
     DeviceTypeEnum.PACKET_SWITCH, DeviceTypeEnum.EMULATED_PACKET_SWITCH,
 }
-- 
GitLab