From 3aea4dc02e1c68ad17f051f279788e20dcf2b29f Mon Sep 17 00:00:00 2001
From: hajipour <shajipour@cttc.es>
Date: Mon, 16 Dec 2024 19:36:34 +0100
Subject: [PATCH] feat: IETF_SLICE and NCE types added to context proto and
 python Enum types. - l3nm_emulated ConfigRules.py changed to match string
 vlan values.

---
 proto/context.proto                            |  3 +++
 src/common/DeviceTypes.py                      |  3 +++
 src/common/tools/descriptor/Tools.py           |  2 ++
 .../database/models/enums/DeviceDriver.py      |  3 +++
 src/device/service/drivers/__init__.py         | 18 ++++++++++++++++++
 .../service/algorithms/tools/ResourceGroups.py |  3 +++
 .../service/algorithms/tools/ServiceTypes.py   |  1 +
 .../service_handler_api/FilterFields.py        |  3 +++
 .../service/service_handlers/__init__.py       | 14 ++++++++++++++
 .../l3nm_emulated/ConfigRules.py               |  8 ++++----
 10 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/proto/context.proto b/proto/context.proto
index 9f06d32ee..c275621a4 100644
--- a/proto/context.proto
+++ b/proto/context.proto
@@ -223,6 +223,9 @@ enum DeviceDriverEnum {
   DEVICEDRIVER_IETF_ACTN = 10;
   DEVICEDRIVER_OC = 11;
   DEVICEDRIVER_QKD = 12;
+  DEVICEDRIVER_IETF_L3VPN = 13;
+  DEVICEDRIVER_IETF_SLICE = 14;
+  DEVICEDRIVER_NCE = 15;
 }
 
 enum DeviceOperationalStatusEnum {
diff --git a/src/common/DeviceTypes.py b/src/common/DeviceTypes.py
index eb315352b..30bbd0b15 100644
--- a/src/common/DeviceTypes.py
+++ b/src/common/DeviceTypes.py
@@ -52,3 +52,6 @@ class DeviceTypeEnum(Enum):
 
     # ETSI TeraFlowSDN controller
     TERAFLOWSDN_CONTROLLER          = 'teraflowsdn'
+    IETF_SLICE = 'ietf-slice'
+
+    NCE = 'nce'
\ No newline at end of file
diff --git a/src/common/tools/descriptor/Tools.py b/src/common/tools/descriptor/Tools.py
index c8807cef0..2ecd38ae1 100644
--- a/src/common/tools/descriptor/Tools.py
+++ b/src/common/tools/descriptor/Tools.py
@@ -115,6 +115,8 @@ CONTROLLER_DEVICE_TYPES = {
     DeviceTypeEnum.MICROWAVE_RADIO_SYSTEM.value,
     DeviceTypeEnum.OPEN_LINE_SYSTEM.value,
     DeviceTypeEnum.TERAFLOWSDN_CONTROLLER.value,
+    DeviceTypeEnum.IETF_SLICE.value,
+    DeviceTypeEnum.NCE.value,
 }
 
 def split_controllers_and_network_devices(devices : List[Dict]) -> Tuple[List[Dict], List[Dict]]:
diff --git a/src/context/service/database/models/enums/DeviceDriver.py b/src/context/service/database/models/enums/DeviceDriver.py
index 5342f788a..fe0d83fb1 100644
--- a/src/context/service/database/models/enums/DeviceDriver.py
+++ b/src/context/service/database/models/enums/DeviceDriver.py
@@ -33,6 +33,9 @@ class ORM_DeviceDriverEnum(enum.Enum):
     GNMI_OPENCONFIG       = DeviceDriverEnum.DEVICEDRIVER_GNMI_OPENCONFIG
     OPTICAL_TFS           = DeviceDriverEnum.DEVICEDRIVER_OPTICAL_TFS
     IETF_ACTN             = DeviceDriverEnum.DEVICEDRIVER_IETF_ACTN
+    IETF_L3VPN            = DeviceDriverEnum.DEVICEDRIVER_IETF_L3VPN
+    NCE                   = DeviceDriverEnum.DEVICEDRIVER_NCE
+    IETF_SLICE            = DeviceDriverEnum.DEVICEDRIVER_IETF_SLICE
     OC                    = DeviceDriverEnum.DEVICEDRIVER_OC
     QKD                   = DeviceDriverEnum.DEVICEDRIVER_QKD
 
diff --git a/src/device/service/drivers/__init__.py b/src/device/service/drivers/__init__.py
index b99ee50ca..bfadaafdd 100644
--- a/src/device/service/drivers/__init__.py
+++ b/src/device/service/drivers/__init__.py
@@ -90,6 +90,24 @@ DRIVERS.append(
         }
     ]))
 
+from .ietf_slice.driver import IetfSliceDriver # pylint: disable=wrong-import-position
+DRIVERS.append(
+    (IetfSliceDriver, [
+        {
+            FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.IETF_SLICE,
+            FilterFieldEnum.DRIVER: DeviceDriverEnum.DEVICEDRIVER_IETF_SLICE,
+        }
+    ]))
+
+from .nce.driver import NCEDriver # pylint: disable=wrong-import-position
+DRIVERS.append(
+    (NCEDriver, [
+        {
+            FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.NCE,
+            FilterFieldEnum.DRIVER: DeviceDriverEnum.DEVICEDRIVER_NCE,
+        }
+    ]))
+
 if LOAD_ALL_DEVICE_DRIVERS:
     from .openconfig.OpenConfigDriver import OpenConfigDriver # pylint: disable=wrong-import-position
     DRIVERS.append(
diff --git a/src/pathcomp/frontend/service/algorithms/tools/ResourceGroups.py b/src/pathcomp/frontend/service/algorithms/tools/ResourceGroups.py
index 42635bf4a..eebdfc25e 100644
--- a/src/pathcomp/frontend/service/algorithms/tools/ResourceGroups.py
+++ b/src/pathcomp/frontend/service/algorithms/tools/ResourceGroups.py
@@ -26,6 +26,9 @@ DEVICE_TYPE_TO_DEEPNESS = {
     DeviceTypeEnum.TERAFLOWSDN_CONTROLLER.value          : 80,
     DeviceTypeEnum.EMULATED_IP_SDN_CONTROLLER.value      : 80,
     DeviceTypeEnum.IP_SDN_CONTROLLER.value               : 80,
+    DeviceTypeEnum.IETF_SLICE.value                      : 80,
+    DeviceTypeEnum.NCE.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 8230092c2..ae567d9d6 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.IETF_SLICE, DeviceTypeEnum.NCE,
     DeviceTypeEnum.IP_SDN_CONTROLLER, DeviceTypeEnum.EMULATED_IP_SDN_CONTROLLER,
     DeviceTypeEnum.PACKET_ROUTER, DeviceTypeEnum.EMULATED_PACKET_ROUTER,
     DeviceTypeEnum.PACKET_SWITCH, DeviceTypeEnum.EMULATED_PACKET_SWITCH,
diff --git a/src/service/service/service_handler_api/FilterFields.py b/src/service/service/service_handler_api/FilterFields.py
index 78f084605..585bad6b0 100644
--- a/src/service/service/service_handler_api/FilterFields.py
+++ b/src/service/service/service_handler_api/FilterFields.py
@@ -42,6 +42,9 @@ DEVICE_DRIVER_VALUES = {
     DeviceDriverEnum.DEVICEDRIVER_GNMI_OPENCONFIG,
     DeviceDriverEnum.DEVICEDRIVER_OPTICAL_TFS,
     DeviceDriverEnum.DEVICEDRIVER_IETF_ACTN,
+    DeviceDriverEnum.DEVICEDRIVER_NCE,
+    DeviceDriverEnum.DEVICEDRIVER_IETF_SLICE,
+    DeviceDriverEnum.DEVICEDRIVER_IETF_L3VPN,
     DeviceDriverEnum.DEVICEDRIVER_OC,
     DeviceDriverEnum.DEVICEDRIVER_QKD,
 }
diff --git a/src/service/service/service_handlers/__init__.py b/src/service/service/service_handlers/__init__.py
index f93cf011f..3d1ae9041 100644
--- a/src/service/service/service_handlers/__init__.py
+++ b/src/service/service/service_handlers/__init__.py
@@ -21,6 +21,8 @@ from .l3nm_emulated.L3NMEmulatedServiceHandler import L3NMEmulatedServiceHandler
 from .l3nm_openconfig.L3NMOpenConfigServiceHandler import L3NMOpenConfigServiceHandler
 from .l3nm_gnmi_openconfig.L3NMGnmiOpenConfigServiceHandler import L3NMGnmiOpenConfigServiceHandler
 from .l3nm_ietf_actn.L3NMIetfActnServiceHandler import L3NMIetfActnServiceHandler
+from .l3nm_nce.L3NMNCEServiceHandler import L3NMNCEServiceHandler
+from .l3slice_ietfslice.L3SliceIETFSliceServiceHandler import L3NMSliceIETFSliceServiceHandler
 from .microwave.MicrowaveServiceHandler import MicrowaveServiceHandler
 from .p4.p4_service_handler import P4ServiceHandler
 from .tapi_tapi.TapiServiceHandler import TapiServiceHandler
@@ -66,6 +68,18 @@ SERVICE_HANDLERS = [
             FilterFieldEnum.DEVICE_DRIVER : DeviceDriverEnum.DEVICEDRIVER_IETF_ACTN,
         }
     ]),
+    (L3NMNCEServiceHandler, [
+        {
+            FilterFieldEnum.SERVICE_TYPE  : ServiceTypeEnum.SERVICETYPE_L3NM,
+            FilterFieldEnum.DEVICE_DRIVER : DeviceDriverEnum.DEVICEDRIVER_NCE,
+        }
+    ]),
+    (L3NMSliceIETFSliceServiceHandler, [
+        {
+            FilterFieldEnum.SERVICE_TYPE  : ServiceTypeEnum.SERVICETYPE_L3NM,
+            FilterFieldEnum.DEVICE_DRIVER : DeviceDriverEnum.DEVICEDRIVER_IETF_SLICE,
+        }
+    ]),
     (TapiServiceHandler, [
         {
             FilterFieldEnum.SERVICE_TYPE  : ServiceTypeEnum.SERVICETYPE_TAPI_CONNECTIVITY_SERVICE,
diff --git a/src/service/service/service_handlers/l3nm_emulated/ConfigRules.py b/src/service/service/service_handlers/l3nm_emulated/ConfigRules.py
index 1d6764619..f1b02eab5 100644
--- a/src/service/service/service_handlers/l3nm_emulated/ConfigRules.py
+++ b/src/service/service/service_handlers/l3nm_emulated/ConfigRules.py
@@ -43,7 +43,7 @@ def setup_config_rules(
     vlan_id             = json_endpoint_settings.get('vlan_id',             1        )  # 400
     address_ip          = json_endpoint_settings.get('address_ip',          '0.0.0.0')  # '2.2.2.1'
     address_prefix      = json_endpoint_settings.get('address_prefix',      24       )  # 30
-    if_subif_name       = '{:s}.{:d}'.format(endpoint_name, vlan_id)
+    if_subif_name       = '{:s}.{:s}'.format(endpoint_name, str(vlan_id))
 
     json_config_rules = [
         json_config_rule_set(
@@ -57,7 +57,7 @@ def setup_config_rules(
                 'name': endpoint_name, 'description': network_interface_desc, 'mtu': mtu,
         }),
         json_config_rule_set(
-            '/interface[{:s}]/subinterface[{:d}]'.format(endpoint_name, sub_interface_index), {
+            '/interface[{:s}]/subinterface[{:s}]'.format(endpoint_name, str(sub_interface_index)), {
                 'name': endpoint_name, 'index': sub_interface_index,
                 'description': network_subinterface_desc, 'vlan_id': vlan_id,
                 'address_ip': address_ip, 'address_prefix': address_prefix,
@@ -163,7 +163,7 @@ def teardown_config_rules(
     #address_ip          = json_endpoint_settings.get('address_ip',          '0.0.0.0')  # '2.2.2.1'
     #address_prefix      = json_endpoint_settings.get('address_prefix',      24       )  # 30
 
-    if_subif_name             = '{:s}.{:d}'.format(endpoint_name, vlan_id)
+    if_subif_name             = '{:s}.{:s}'.format(endpoint_name, str(vlan_id))
     service_short_uuid        = service_uuid.split('-')[-1]
     network_instance_name     = '{:s}-NetInst'.format(service_short_uuid)
     #network_interface_desc    = '{:s}-NetIf'.format(service_uuid)
@@ -175,7 +175,7 @@ def teardown_config_rules(
                 'name': network_instance_name, 'id': if_subif_name,
         }),
         json_config_rule_delete(
-            '/interface[{:s}]/subinterface[{:d}]'.format(endpoint_name, sub_interface_index), {
+            '/interface[{:s}]/subinterface[{:s}]'.format(endpoint_name, str(sub_interface_index)), {
                 'name': endpoint_name, 'index': sub_interface_index,
         }),
         json_config_rule_delete(
-- 
GitLab