From a2d4ba5bc33bac1fe3fc35e2a415a8262a543858 Mon Sep 17 00:00:00 2001
From: Lluis Gifre <lluis.gifre@cttc.es>
Date: Wed, 28 Sep 2022 15:14:23 +0000
Subject: [PATCH] Integration fix resolution:

Common:
- added slice to EventTools

OFC'22 tests:
- corrected OFC'22 delete service test to identify appropriate service to be deleted
- removed usage of events for testing

Compute:
- remove diversity constraint when not populated

Device:
- removed unused field in database and code polishing

Service:
- migrated L3NMEmulatedServiceHandler to the new API
- polishing of code
---
 src/common/tests/EventTools.py                |   4 +-
 .../ietf_l2vpn/L2VPN_SiteNetworkAccesses.py   |   4 +-
 src/device/service/database/EndPointModel.py  |   8 +-
 .../l2nm_emulated/ConfigRules.py              |   2 +-
 .../l3nm_emulated/ConfigRules.py              | 114 ++++++-
 .../l3nm_emulated/ConfigRulesOld.py           | 109 +++++++
 .../L3NMEmulatedServiceHandler.py             | 280 ++----------------
 .../ofc22/tests/test_functional_bootstrap.py  |  46 +--
 .../ofc22/tests/test_functional_cleanup.py    |  18 +-
 .../tests/test_functional_create_service.py   |  48 +--
 .../tests/test_functional_delete_service.py   |  50 ++--
 11 files changed, 329 insertions(+), 354 deletions(-)
 create mode 100644 src/service/service/service_handlers/l3nm_emulated/ConfigRulesOld.py

diff --git a/src/common/tests/EventTools.py b/src/common/tests/EventTools.py
index ceff4d60e..d0f828413 100644
--- a/src/common/tests/EventTools.py
+++ b/src/common/tests/EventTools.py
@@ -15,7 +15,7 @@
 import json, logging
 from typing import Dict, List, Tuple
 from common.proto.context_pb2 import (
-    ConnectionEvent, ContextEvent, DeviceEvent, EventTypeEnum, LinkEvent, ServiceEvent, TopologyEvent)
+    ConnectionEvent, ContextEvent, DeviceEvent, EventTypeEnum, LinkEvent, ServiceEvent, SliceEvent, TopologyEvent)
 from common.tools.grpc.Tools import grpc_message_to_json_string
 from context.client.EventsCollector import EventsCollector
 
@@ -32,6 +32,7 @@ CLASSNAME_CONTEXT_EVENT    = class_to_classname(ContextEvent)
 CLASSNAME_TOPOLOGY_EVENT   = class_to_classname(TopologyEvent)
 CLASSNAME_DEVICE_EVENT     = class_to_classname(DeviceEvent)
 CLASSNAME_LINK_EVENT       = class_to_classname(LinkEvent)
+CLASSNAME_SLICE_EVENT      = class_to_classname(SliceEvent)
 CLASSNAME_SERVICE_EVENT    = class_to_classname(ServiceEvent)
 CLASSNAME_CONNECTION_EVENT = class_to_classname(ConnectionEvent)
 
@@ -40,6 +41,7 @@ EVENT_CLASS_NAME__TO__ENTITY_ID_SELECTOR = {
     CLASSNAME_TOPOLOGY_EVENT  : lambda event: event.topology_id,
     CLASSNAME_DEVICE_EVENT    : lambda event: event.device_id,
     CLASSNAME_LINK_EVENT      : lambda event: event.link_id,
+    CLASSNAME_SLICE_EVENT     : lambda event: event.slice_id,
     CLASSNAME_SERVICE_EVENT   : lambda event: event.service_id,
     CLASSNAME_CONNECTION_EVENT: lambda event: event.connection_id,
 }
diff --git a/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_SiteNetworkAccesses.py b/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_SiteNetworkAccesses.py
index 83691ff9b..3cc823a2a 100644
--- a/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_SiteNetworkAccesses.py
+++ b/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_SiteNetworkAccesses.py
@@ -98,10 +98,8 @@ def process_site_network_access(context_client : ContextClient, site_id : str, s
     if circuit_id     is not None: field_updates['circuit_id'         ] = (circuit_id,     True)
     update_config_rule_custom(config_rules, endpoint_settings_key, field_updates)
 
-    field_updates = {}
     if len(diversity_constraints) > 0:
-        field_updates.update(diversity_constraints)
-    update_constraint_custom(constraints, 'diversity', field_updates)
+        update_constraint_custom(constraints, 'diversity', diversity_constraints)
 
     update_constraint_endpoint_location(constraints, endpoint_id, region=site_id)
     if access_priority is not None: update_constraint_endpoint_priority(constraints, endpoint_id, access_priority)
diff --git a/src/device/service/database/EndPointModel.py b/src/device/service/database/EndPointModel.py
index 84d0c9707..2c6d81798 100644
--- a/src/device/service/database/EndPointModel.py
+++ b/src/device/service/database/EndPointModel.py
@@ -34,7 +34,6 @@ class EndPointModel(Model):
     device_fk = ForeignKeyField(DeviceModel)
     endpoint_uuid = StringField(required=True, allow_empty=False)
     endpoint_type = StringField()
-    resource_key = StringField(required=True, allow_empty=False)
 
     def dump_id(self) -> Dict:
         device_id = DeviceModel(self.database, self.device_fk).dump_id()
@@ -74,13 +73,8 @@ def set_endpoint_monitors(database : Database, db_endpoint : EndPointModel, grpc
     for kpi_sample_type in grpc_endpoint_kpi_sample_types:
         orm_kpi_sample_type = grpc_to_enum__kpi_sample_type(kpi_sample_type)
         str_endpoint_kpi_sample_type_key = key_to_str([db_endpoint_pk, str(orm_kpi_sample_type.value)])
-        #db_endpoint_kpi_sample_type = EndPointMonitorModel(database, str_endpoint_kpi_sample_type_key)
-        #db_endpoint_kpi_sample_type.endpoint_fk = db_endpoint
-        #db_endpoint_kpi_sample_type.resource_key = '' # during initialization, allow empty value
-        #db_endpoint_kpi_sample_type.kpi_sample_type = orm_kpi_sample_type
-        #db_endpoint_kpi_sample_type.save()
         update_or_create_object(database, EndPointMonitorModel, str_endpoint_kpi_sample_type_key, {
             'endpoint_fk'    : db_endpoint,
-            #'resource_key'   : '', # during initialization, allow empty value
+            'resource_key'   : '', # during initialization, allow empty value
             'kpi_sample_type': orm_kpi_sample_type,
         })
diff --git a/src/service/service/service_handlers/l2nm_emulated/ConfigRules.py b/src/service/service/service_handlers/l2nm_emulated/ConfigRules.py
index d173f3f27..70f2ea093 100644
--- a/src/service/service/service_handlers/l2nm_emulated/ConfigRules.py
+++ b/src/service/service/service_handlers/l2nm_emulated/ConfigRules.py
@@ -20,7 +20,7 @@ def setup_config_rules(
     service_uuid : str, connection_uuid : str, device_uuid : str, endpoint_uuid : str,
     service_settings : TreeNode, endpoint_settings : TreeNode
 ) -> List[Dict]:
-    
+
     json_settings          : Dict = {} if service_settings  is None else service_settings.value
     json_endpoint_settings : Dict = {} if endpoint_settings is None else endpoint_settings.value
 
diff --git a/src/service/service/service_handlers/l3nm_emulated/ConfigRules.py b/src/service/service/service_handlers/l3nm_emulated/ConfigRules.py
index 7d95f72c9..3a5aff588 100644
--- a/src/service/service/service_handlers/l3nm_emulated/ConfigRules.py
+++ b/src/service/service/service_handlers/l3nm_emulated/ConfigRules.py
@@ -30,6 +30,7 @@ def setup_config_rules(
     network_subinterface_desc = '{:s}-NetSubIf'.format(service_uuid)
 
     mtu                 = json_settings.get('mtu',                 1450 )    # 1512
+    #address_families    = json_settings.get('address_families',    []   )    # ['IPV4']
     bgp_as              = json_settings.get('bgp_as',              0    )    # 65000
     bgp_route_target    = json_settings.get('bgp_route_target',    '0:0')    # 65000:333
 
@@ -134,4 +135,115 @@ def setup_config_rules(
         }),
     ]
 
-    return json_config_rules
\ No newline at end of file
+    return json_config_rules
+
+def teardown_config_rules(
+    service_uuid : str, connection_uuid : str, device_uuid : str, endpoint_uuid : str,
+    service_settings : TreeNode, endpoint_settings : TreeNode
+) -> List[Dict]:
+
+    json_settings          : Dict = {} if service_settings  is None else service_settings.value
+    json_endpoint_settings : Dict = {} if endpoint_settings is None else endpoint_settings.value
+
+    #mtu                 = json_settings.get('mtu',                 1450 )    # 1512
+    #address_families    = json_settings.get('address_families',    []   )    # ['IPV4']
+    #bgp_as              = json_settings.get('bgp_as',              0    )    # 65000
+    bgp_route_target    = json_settings.get('bgp_route_target',    '0:0')    # 65000:333
+
+    #router_id           = json_endpoint_settings.get('router_id',           '0.0.0.0')  # '10.95.0.10'
+    #route_distinguisher = json_endpoint_settings.get('route_distinguisher', '0:0'    )  # '60001:801'
+    sub_interface_index = json_endpoint_settings.get('sub_interface_index', 0        )  # 1
+    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_uuid, 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)
+    #network_subinterface_desc = '{:s}-NetSubIf'.format(service_uuid)
+
+    json_config_rules = [
+        json_config_rule_delete(
+            '/network_instance[{:s}]/interface[{:s}]'.format(network_instance_name, if_subif_name), {
+                'name': network_instance_name, 'id': if_subif_name,
+        }),
+        json_config_rule_delete(
+            '/interface[{:s}]/subinterface[{:d}]'.format(endpoint_uuid, sub_interface_index), {
+                'name': endpoint_uuid, 'index': sub_interface_index,
+        }),
+        json_config_rule_delete(
+            '/interface[{:s}]'.format(endpoint_uuid), {
+                'name': endpoint_uuid,
+        }),
+        json_config_rule_delete(
+            '/network_instance[{:s}]/table_connections[DIRECTLY_CONNECTED][BGP][IPV4]'.format(
+                network_instance_name), {
+                'name': network_instance_name, 'src_protocol': 'DIRECTLY_CONNECTED', 'dst_protocol': 'BGP',
+                'address_family': 'IPV4',
+        }),
+        json_config_rule_delete(
+            '/network_instance[{:s}]/table_connections[STATIC][BGP][IPV4]'.format(network_instance_name), {
+                'name': network_instance_name, 'src_protocol': 'STATIC', 'dst_protocol': 'BGP',
+                'address_family': 'IPV4',
+        }),
+        json_config_rule_delete(
+            '/network_instance[{:s}]/protocols[BGP]'.format(network_instance_name), {
+                'name': network_instance_name, 'identifier': 'BGP', 'protocol_name': 'BGP',
+        }),
+        json_config_rule_delete(
+            # pylint: disable=duplicate-string-formatting-argument
+            '/network_instance[{:s}]/inter_instance_policies[{:s}_import]'.format(
+                network_instance_name, network_instance_name), {
+            'name': network_instance_name,
+        }),
+        json_config_rule_delete(
+            '/routing_policy/policy_definition[{:s}_import]/statement[{:s}]'.format(
+                network_instance_name, '3'), {
+                'policy_name': '{:s}_import'.format(network_instance_name), 'statement_name': '3',
+        }),
+        json_config_rule_delete(
+            '/routing_policy/policy_definition[{:s}_import]'.format(network_instance_name), {
+                'policy_name': '{:s}_import'.format(network_instance_name),
+        }),
+        json_config_rule_delete(
+            '/routing_policy/bgp_defined_set[{:s}_rt_import][route-target:{:s}]'.format(
+                network_instance_name, bgp_route_target), {
+                'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name),
+                'ext_community_member'  : 'route-target:{:s}'.format(bgp_route_target),
+        }),
+        json_config_rule_delete(
+            '/routing_policy/bgp_defined_set[{:s}_rt_import]'.format(network_instance_name), {
+                'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name),
+        }),
+        json_config_rule_delete(
+            # pylint: disable=duplicate-string-formatting-argument
+            '/network_instance[{:s}]/inter_instance_policies[{:s}_export]'.format(
+                network_instance_name, network_instance_name), {
+                'name': network_instance_name,
+        }),
+        json_config_rule_delete(
+            '/routing_policy/policy_definition[{:s}_export]/statement[{:s}]'.format(
+                network_instance_name, '3'), {
+                'policy_name': '{:s}_export'.format(network_instance_name), 'statement_name': '3',
+        }),
+        json_config_rule_delete(
+            '/routing_policy/policy_definition[{:s}_export]'.format(network_instance_name), {
+                'policy_name': '{:s}_export'.format(network_instance_name),
+        }),
+        json_config_rule_delete(
+            '/routing_policy/bgp_defined_set[{:s}_rt_export][route-target:{:s}]'.format(
+                network_instance_name, bgp_route_target), {
+                'ext_community_set_name': '{:s}_rt_export'.format(network_instance_name),
+                'ext_community_member'  : 'route-target:{:s}'.format(bgp_route_target),
+        }),
+        json_config_rule_delete(
+            '/routing_policy/bgp_defined_set[{:s}_rt_export]'.format(network_instance_name), {
+                'ext_community_set_name': '{:s}_rt_export'.format(network_instance_name),
+        }),
+        json_config_rule_delete(
+            '/network_instance[{:s}]'.format(network_instance_name), {
+                'name': network_instance_name
+        }),
+    ]
+    return json_config_rules
diff --git a/src/service/service/service_handlers/l3nm_emulated/ConfigRulesOld.py b/src/service/service/service_handlers/l3nm_emulated/ConfigRulesOld.py
new file mode 100644
index 000000000..8b12049ba
--- /dev/null
+++ b/src/service/service/service_handlers/l3nm_emulated/ConfigRulesOld.py
@@ -0,0 +1,109 @@
+
+                # json_endpoint_settings : Dict = endpoint_settings.value
+                # #router_id           = json_endpoint_settings.get('router_id',           '0.0.0.0')  # '10.95.0.10'
+                # route_distinguisher = json_endpoint_settings.get('route_distinguisher', '0:0'    )  # '60001:801'
+                # sub_interface_index = json_endpoint_settings.get('sub_interface_index', 0        )  # 1
+                # 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_uuid, vlan_id)
+
+                # db_device : DeviceModel = get_object(self.__database, DeviceModel, device_uuid, raise_if_not_found=True)
+                # device = self.__task_executor.get_device(DeviceId(**json_device_id(device_uuid)))
+                # json_device = db_device.dump(include_config_rules=False, include_drivers=True, include_endpoints=True)
+                # json_device_config : Dict = json_device.setdefault('device_config', {})
+                # json_device_config_rules : List = json_device_config.setdefault('config_rules', [])
+                # json_device_config_rules.extend([
+                #     json_config_rule_set(
+                #         '/network_instance[{:s}]'.format(network_instance_name), {
+                #             'name': network_instance_name, 'description': network_interface_desc, 'type': 'L3VRF',
+                #             'route_distinguisher': route_distinguisher,
+                #             #'router_id': router_id, 'address_families': address_families,
+                #     }),
+                #     json_config_rule_set(
+                #         '/interface[{:s}]'.format(endpoint_uuid), {
+                #             'name': endpoint_uuid, 'description': network_interface_desc, 'mtu': mtu,
+                #     }),
+                #     json_config_rule_set(
+                #         '/interface[{:s}]/subinterface[{:d}]'.format(endpoint_uuid, sub_interface_index), {
+                #             'name': endpoint_uuid, 'index': sub_interface_index,
+                #             'description': network_subinterface_desc, 'vlan_id': vlan_id,
+                #             'address_ip': address_ip, 'address_prefix': address_prefix,
+                #     }),
+                #     json_config_rule_set(
+                #         '/network_instance[{:s}]/interface[{:s}]'.format(network_instance_name, if_subif_name), {
+                #             'name': network_instance_name, 'id': if_subif_name, 'interface': endpoint_uuid,
+                #             'subinterface': sub_interface_index,
+                #     }),
+                #     json_config_rule_set(
+                #         '/network_instance[{:s}]/protocols[BGP]'.format(network_instance_name), {
+                #             'name': network_instance_name, 'identifier': 'BGP', 'protocol_name': 'BGP', 'as': bgp_as,
+                #     }),
+                #     json_config_rule_set(
+                #         '/network_instance[{:s}]/table_connections[STATIC][BGP][IPV4]'.format(network_instance_name), {
+                #             'name': network_instance_name, 'src_protocol': 'STATIC', 'dst_protocol': 'BGP',
+                #             'address_family': 'IPV4', #'default_import_policy': 'REJECT_ROUTE',
+                #     }),
+                #     json_config_rule_set(
+                #         '/network_instance[{:s}]/table_connections[DIRECTLY_CONNECTED][BGP][IPV4]'.format(
+                #             network_instance_name), {
+                #             'name': network_instance_name, 'src_protocol': 'DIRECTLY_CONNECTED', 'dst_protocol': 'BGP',
+                #             'address_family': 'IPV4', #'default_import_policy': 'REJECT_ROUTE',
+                #     }),
+                #     json_config_rule_set(
+                #         '/routing_policy/bgp_defined_set[{:s}_rt_import]'.format(network_instance_name), {
+                #             'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name),
+                #     }),
+                #     json_config_rule_set(
+                #         '/routing_policy/bgp_defined_set[{:s}_rt_import][route-target:{:s}]'.format(
+                #             network_instance_name, bgp_route_target), {
+                #             'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name),
+                #             'ext_community_member'  : 'route-target:{:s}'.format(bgp_route_target),
+                #     }),
+                #     json_config_rule_set(
+                #         '/routing_policy/policy_definition[{:s}_import]'.format(network_instance_name), {
+                #             'policy_name': '{:s}_import'.format(network_instance_name),
+                #     }),
+                #     json_config_rule_set(
+                #         '/routing_policy/policy_definition[{:s}_import]/statement[{:s}]'.format(
+                #             network_instance_name, '3'), {
+                #             'policy_name': '{:s}_import'.format(network_instance_name), 'statement_name': '3',
+                #             'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name),
+                #             'match_set_options': 'ANY', 'policy_result': 'ACCEPT_ROUTE',
+                #     }),
+                #     json_config_rule_set(
+                #         # pylint: disable=duplicate-string-formatting-argument
+                #         '/network_instance[{:s}]/inter_instance_policies[{:s}_import]'.format(
+                #             network_instance_name, network_instance_name), {
+                #             'name': network_instance_name, 'import_policy': '{:s}_import'.format(network_instance_name),
+                #     }),
+                #     json_config_rule_set(
+                #         '/routing_policy/bgp_defined_set[{:s}_rt_export]'.format(network_instance_name), {
+                #             'ext_community_set_name': '{:s}_rt_export'.format(network_instance_name),
+                #     }),
+                #     json_config_rule_set(
+                #         '/routing_policy/bgp_defined_set[{:s}_rt_export][route-target:{:s}]'.format(
+                #             network_instance_name, bgp_route_target), {
+                #             'ext_community_set_name': '{:s}_rt_export'.format(network_instance_name),
+                #             'ext_community_member'  : 'route-target:{:s}'.format(bgp_route_target),
+                #     }),
+                #     json_config_rule_set(
+                #         '/routing_policy/policy_definition[{:s}_export]'.format(network_instance_name), {
+                #             'policy_name': '{:s}_export'.format(network_instance_name),
+                #     }),
+                #     json_config_rule_set(
+                #         '/routing_policy/policy_definition[{:s}_export]/statement[{:s}]'.format(
+                #             network_instance_name, '3'), {
+                #             'policy_name': '{:s}_export'.format(network_instance_name), 'statement_name': '3',
+                #             'ext_community_set_name': '{:s}_rt_export'.format(network_instance_name),
+                #             'match_set_options': 'ANY', 'policy_result': 'ACCEPT_ROUTE',
+                #     }),
+                #     json_config_rule_set(
+                #         # pylint: disable=duplicate-string-formatting-argument
+                #         '/network_instance[{:s}]/inter_instance_policies[{:s}_export]'.format(
+                #             network_instance_name, network_instance_name), {
+                #             'name': network_instance_name, 'export_policy': '{:s}_export'.format(network_instance_name),
+                #     }),
+                # ])
+                # self.__device_client.ConfigureDevice(Device(**json_device))
+                # results.append(True)
diff --git a/src/service/service/service_handlers/l3nm_emulated/L3NMEmulatedServiceHandler.py b/src/service/service/service_handlers/l3nm_emulated/L3NMEmulatedServiceHandler.py
index 1ddddc26e..27cfb46e0 100644
--- a/src/service/service/service_handlers/l3nm_emulated/L3NMEmulatedServiceHandler.py
+++ b/src/service/service/service_handlers/l3nm_emulated/L3NMEmulatedServiceHandler.py
@@ -13,20 +13,14 @@
 # limitations under the License.
 
 import anytree, json, logging
-from typing import Any, Dict, List, Optional, Tuple, Union
-from common.orm.HighLevel import get_object
-from common.proto.context_pb2 import ConfigActionEnum, ConfigRule, Device, DeviceId, Service
+from typing import Any, List, Optional, Tuple, Union
+from common.proto.context_pb2 import ConfigActionEnum, ConfigRule, DeviceId, Service
 from common.tools.object_factory.Device import json_device_id
-from common.tools.object_factory.ConfigRule import json_config_rule_delete, json_config_rule_set
 from common.type_checkers.Checkers import chk_length, chk_type
-from service.service.database.ConfigModel import ORM_ConfigActionEnum
-from service.service.database.ContextModel import ContextModel
-from service.service.database.DeviceModel import DeviceModel
-from service.service.task_scheduler.TaskExecutor import TaskExecutor
 from service.service.service_handler_api._ServiceHandler import _ServiceHandler
 from service.service.service_handler_api.AnyTreeTools import TreeNode, delete_subnode, get_subnode, set_subnode_value
-
-from .ConfigRules import setup_config_rules
+from service.service.task_scheduler.TaskExecutor import TaskExecutor
+from .ConfigRules import setup_config_rules, teardown_config_rules
 
 LOGGER = logging.getLogger(__name__)
 
@@ -39,7 +33,6 @@ class L3NMEmulatedServiceHandler(_ServiceHandler):
         self.__resolver = anytree.Resolver(pathattr='name')
         self.__config = TreeNode('.')
         for config_rule in service.service_config.config_rules:
-
             action = config_rule.action
             if config_rule.WhichOneof('config_rule') != 'custom': continue
             resource_key = config_rule.custom.resource_key
@@ -53,298 +46,65 @@ class L3NMEmulatedServiceHandler(_ServiceHandler):
             elif action == ConfigActionEnum.CONFIGACTION_DELETE:
                 delete_subnode(self.__resolver, self.__config, resource_key)
 
-            # if config_rule.action == ORM_ConfigActionEnum.SET:
-            #     try:
-            #         resource_value = json.loads(config_rule.resource_value)
-            #     except: # pylint: disable=bare-except
-            #         pass
-            #     set_subnode_value(self.__resolver, self.__config, config_rule.resource_key, config_rule.resource_value)
-            # elif config_rule.action == ORM_ConfigActionEnum.DELETE:
-            #     delete_subnode(self.__resolver, self.__config, config_rule.resource_key)
-
     def SetEndpoint(
         self, endpoints : List[Tuple[str, str, Optional[str]]], connection_uuid : Optional[str] = None
     ) -> List[Union[bool, Exception]]:
         chk_type('endpoints', endpoints, list)
         if len(endpoints) == 0: return []
 
-        service_uuid              = self.__service.service_id.service_uuid.uuid
-        # service_short_uuid        = service_uuid.split('-')[-1]
-        # network_instance_name     = '{:s}-NetInst'.format(service_short_uuid)
-        # network_interface_desc    = '{:s}-NetIf'.format(service_uuid)
-        # network_subinterface_desc = '{:s}-NetSubIf'.format(service_uuid)
-
+        service_uuid = self.__service.service_id.service_uuid.uuid
         settings : TreeNode = get_subnode(self.__resolver, self.__config, '/settings', None)
-        if settings is None: raise Exception('Unable to retrieve service settings')
-        json_settings : Dict = settings.value
-        # mtu                 = json_settings.get('mtu',                 1450 )    # 1512
-        #address_families    = json_settings.get('address_families',    []   )    # ['IPV4']
-        # bgp_as              = json_settings.get('bgp_as',              0    )    # 65000
-        # bgp_route_target    = json_settings.get('bgp_route_target',    '0:0')    # 65000:333
 
         results = []
         for endpoint in endpoints:
             try:
                 chk_type('endpoint', endpoint, (tuple, list))
                 chk_length('endpoint', endpoint, min_length=2, max_length=3)
-                if len(endpoint) == 2:
-                    device_uuid, endpoint_uuid = endpoint
-                else:
-                    device_uuid, endpoint_uuid, _ = endpoint # ignore topology_uuid by now
+                device_uuid, endpoint_uuid = endpoint[0:2] # ignore topology_uuid by now
 
                 endpoint_settings_uri = '/device[{:s}]/endpoint[{:s}]/settings'.format(device_uuid, endpoint_uuid)
-                # `endpoint_settings` is None
                 endpoint_settings : TreeNode = get_subnode(self.__resolver, self.__config, endpoint_settings_uri, None)
-                if endpoint_settings is None:
-                    raise Exception('Unable to retrieve service settings for endpoint({:s})'.format(
-                        str(endpoint_settings_uri)))
-                
-                # new code starts here
+
                 json_config_rules = setup_config_rules(
                     service_uuid, connection_uuid, device_uuid, endpoint_uuid, settings, endpoint_settings)
-                
+
                 device = self.__task_executor.get_device(DeviceId(**json_device_id(device_uuid)))
                 for json_config_rule in json_config_rules:
                     device.device_config.config_rules.append(ConfigRule(**json_config_rule))
                 self.__task_executor.configure_device(device)
                 results.append(True)
-                # new code stops here
-
-                # json_endpoint_settings : Dict = endpoint_settings.value
-                # #router_id           = json_endpoint_settings.get('router_id',           '0.0.0.0')  # '10.95.0.10'
-                # route_distinguisher = json_endpoint_settings.get('route_distinguisher', '0:0'    )  # '60001:801'
-                # sub_interface_index = json_endpoint_settings.get('sub_interface_index', 0        )  # 1
-                # 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_uuid, vlan_id)
-
-                # db_device : DeviceModel = get_object(self.__database, DeviceModel, device_uuid, raise_if_not_found=True)
-                # device = self.__task_executor.get_device(DeviceId(**json_device_id(device_uuid)))
-                # json_device = db_device.dump(include_config_rules=False, include_drivers=True, include_endpoints=True)
-                # json_device_config : Dict = json_device.setdefault('device_config', {})
-                # json_device_config_rules : List = json_device_config.setdefault('config_rules', [])
-                # json_device_config_rules.extend([
-                #     json_config_rule_set(
-                #         '/network_instance[{:s}]'.format(network_instance_name), {
-                #             'name': network_instance_name, 'description': network_interface_desc, 'type': 'L3VRF',
-                #             'route_distinguisher': route_distinguisher,
-                #             #'router_id': router_id, 'address_families': address_families,
-                #     }),
-                #     json_config_rule_set(
-                #         '/interface[{:s}]'.format(endpoint_uuid), {
-                #             'name': endpoint_uuid, 'description': network_interface_desc, 'mtu': mtu,
-                #     }),
-                #     json_config_rule_set(
-                #         '/interface[{:s}]/subinterface[{:d}]'.format(endpoint_uuid, sub_interface_index), {
-                #             'name': endpoint_uuid, 'index': sub_interface_index,
-                #             'description': network_subinterface_desc, 'vlan_id': vlan_id,
-                #             'address_ip': address_ip, 'address_prefix': address_prefix,
-                #     }),
-                #     json_config_rule_set(
-                #         '/network_instance[{:s}]/interface[{:s}]'.format(network_instance_name, if_subif_name), {
-                #             'name': network_instance_name, 'id': if_subif_name, 'interface': endpoint_uuid,
-                #             'subinterface': sub_interface_index,
-                #     }),
-                #     json_config_rule_set(
-                #         '/network_instance[{:s}]/protocols[BGP]'.format(network_instance_name), {
-                #             'name': network_instance_name, 'identifier': 'BGP', 'protocol_name': 'BGP', 'as': bgp_as,
-                #     }),
-                #     json_config_rule_set(
-                #         '/network_instance[{:s}]/table_connections[STATIC][BGP][IPV4]'.format(network_instance_name), {
-                #             'name': network_instance_name, 'src_protocol': 'STATIC', 'dst_protocol': 'BGP',
-                #             'address_family': 'IPV4', #'default_import_policy': 'REJECT_ROUTE',
-                #     }),
-                #     json_config_rule_set(
-                #         '/network_instance[{:s}]/table_connections[DIRECTLY_CONNECTED][BGP][IPV4]'.format(
-                #             network_instance_name), {
-                #             'name': network_instance_name, 'src_protocol': 'DIRECTLY_CONNECTED', 'dst_protocol': 'BGP',
-                #             'address_family': 'IPV4', #'default_import_policy': 'REJECT_ROUTE',
-                #     }),
-                #     json_config_rule_set(
-                #         '/routing_policy/bgp_defined_set[{:s}_rt_import]'.format(network_instance_name), {
-                #             'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name),
-                #     }),
-                #     json_config_rule_set(
-                #         '/routing_policy/bgp_defined_set[{:s}_rt_import][route-target:{:s}]'.format(
-                #             network_instance_name, bgp_route_target), {
-                #             'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name),
-                #             'ext_community_member'  : 'route-target:{:s}'.format(bgp_route_target),
-                #     }),
-                #     json_config_rule_set(
-                #         '/routing_policy/policy_definition[{:s}_import]'.format(network_instance_name), {
-                #             'policy_name': '{:s}_import'.format(network_instance_name),
-                #     }),
-                #     json_config_rule_set(
-                #         '/routing_policy/policy_definition[{:s}_import]/statement[{:s}]'.format(
-                #             network_instance_name, '3'), {
-                #             'policy_name': '{:s}_import'.format(network_instance_name), 'statement_name': '3',
-                #             'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name),
-                #             'match_set_options': 'ANY', 'policy_result': 'ACCEPT_ROUTE',
-                #     }),
-                #     json_config_rule_set(
-                #         # pylint: disable=duplicate-string-formatting-argument
-                #         '/network_instance[{:s}]/inter_instance_policies[{:s}_import]'.format(
-                #             network_instance_name, network_instance_name), {
-                #             'name': network_instance_name, 'import_policy': '{:s}_import'.format(network_instance_name),
-                #     }),
-                #     json_config_rule_set(
-                #         '/routing_policy/bgp_defined_set[{:s}_rt_export]'.format(network_instance_name), {
-                #             'ext_community_set_name': '{:s}_rt_export'.format(network_instance_name),
-                #     }),
-                #     json_config_rule_set(
-                #         '/routing_policy/bgp_defined_set[{:s}_rt_export][route-target:{:s}]'.format(
-                #             network_instance_name, bgp_route_target), {
-                #             'ext_community_set_name': '{:s}_rt_export'.format(network_instance_name),
-                #             'ext_community_member'  : 'route-target:{:s}'.format(bgp_route_target),
-                #     }),
-                #     json_config_rule_set(
-                #         '/routing_policy/policy_definition[{:s}_export]'.format(network_instance_name), {
-                #             'policy_name': '{:s}_export'.format(network_instance_name),
-                #     }),
-                #     json_config_rule_set(
-                #         '/routing_policy/policy_definition[{:s}_export]/statement[{:s}]'.format(
-                #             network_instance_name, '3'), {
-                #             'policy_name': '{:s}_export'.format(network_instance_name), 'statement_name': '3',
-                #             'ext_community_set_name': '{:s}_rt_export'.format(network_instance_name),
-                #             'match_set_options': 'ANY', 'policy_result': 'ACCEPT_ROUTE',
-                #     }),
-                #     json_config_rule_set(
-                #         # pylint: disable=duplicate-string-formatting-argument
-                #         '/network_instance[{:s}]/inter_instance_policies[{:s}_export]'.format(
-                #             network_instance_name, network_instance_name), {
-                #             'name': network_instance_name, 'export_policy': '{:s}_export'.format(network_instance_name),
-                #     }),
-                # ])
-                # self.__device_client.ConfigureDevice(Device(**json_device))
-                # results.append(True)
             except Exception as e: # pylint: disable=broad-except
                 LOGGER.exception('Unable to SetEndpoint({:s})'.format(str(endpoint)))
                 results.append(e)
 
         return results
 
-    def DeleteEndpoint(self, endpoints : List[Tuple[str, str, Optional[str]]]) -> List[Union[bool, Exception]]:
+    def DeleteEndpoint(
+        self, endpoints : List[Tuple[str, str, Optional[str]]], connection_uuid : Optional[str] = None
+    ) -> List[Union[bool, Exception]]:
         chk_type('endpoints', endpoints, list)
         if len(endpoints) == 0: return []
 
-        service_uuid              = self.__service.service_id.service_uuid.uuid
-        service_short_uuid        = service_uuid.split('-')[-1]
-        network_instance_name     = '{:s}-NetInst'.format(service_short_uuid)
-
+        service_uuid = self.__service.service_id.service_uuid.uuid
         settings : TreeNode = get_subnode(self.__resolver, self.__config, '/settings', None)
-        if settings is None: raise Exception('Unable to retrieve service settings')
-        json_settings : Dict = settings.value
-        bgp_route_target    = json_settings.get('bgp_route_target',    '0:0')    # 65000:333
 
         results = []
         for endpoint in endpoints:
             try:
                 chk_type('endpoint', endpoint, (tuple, list))
                 chk_length('endpoint', endpoint, min_length=2, max_length=3)
-                if len(endpoint) == 2:
-                    device_uuid, endpoint_uuid = endpoint
-                else:
-                    device_uuid, endpoint_uuid, _ = endpoint # ignore topology_uuid by now
+                device_uuid, endpoint_uuid = endpoint[0:2] # ignore topology_uuid by now
 
                 endpoint_settings_uri = '/device[{:s}]/endpoint[{:s}]/settings'.format(device_uuid, endpoint_uuid)
                 endpoint_settings : TreeNode = get_subnode(self.__resolver, self.__config, endpoint_settings_uri, None)
-                if endpoint_settings is None:
-                    raise Exception('Unable to retrieve service settings for endpoint({:s})'.format(
-                        str(endpoint_settings_uri)))
-                json_endpoint_settings : Dict = endpoint_settings.value
-                sub_interface_index = json_endpoint_settings.get('sub_interface_index', 0        )  # 1
-                vlan_id             = json_endpoint_settings.get('vlan_id',             1        )  # 400
-                if_subif_name       = '{:s}.{:d}'.format(endpoint_uuid, vlan_id)
 
-                db_device : DeviceModel = get_object(self.__database, DeviceModel, device_uuid, raise_if_not_found=True)
-                json_device = db_device.dump(include_config_rules=False, include_drivers=True, include_endpoints=True)
-                json_device_config : Dict = json_device.setdefault('device_config', {})
-                json_device_config_rules : List = json_device_config.setdefault('config_rules', [])
-                json_device_config_rules.extend([
-                    json_config_rule_delete(
-                        '/network_instance[{:s}]/interface[{:s}]'.format(network_instance_name, if_subif_name), {
-                            'name': network_instance_name, 'id': if_subif_name,
-                    }),
-                    json_config_rule_delete(
-                        '/interface[{:s}]/subinterface[{:d}]'.format(endpoint_uuid, sub_interface_index), {
-                            'name': endpoint_uuid, 'index': sub_interface_index,
-                    }),
-                    json_config_rule_delete(
-                        '/interface[{:s}]'.format(endpoint_uuid), {
-                            'name': endpoint_uuid,
-                    }),
-                    json_config_rule_delete(
-                        '/network_instance[{:s}]/table_connections[DIRECTLY_CONNECTED][BGP][IPV4]'.format(
-                            network_instance_name), {
-                            'name': network_instance_name, 'src_protocol': 'DIRECTLY_CONNECTED', 'dst_protocol': 'BGP',
-                            'address_family': 'IPV4',
-                    }),
-                    json_config_rule_delete(
-                        '/network_instance[{:s}]/table_connections[STATIC][BGP][IPV4]'.format(network_instance_name), {
-                            'name': network_instance_name, 'src_protocol': 'STATIC', 'dst_protocol': 'BGP',
-                            'address_family': 'IPV4',
-                    }),
-                    json_config_rule_delete(
-                        '/network_instance[{:s}]/protocols[BGP]'.format(network_instance_name), {
-                            'name': network_instance_name, 'identifier': 'BGP', 'protocol_name': 'BGP',
-                    }),
-                    json_config_rule_delete(
-                        # pylint: disable=duplicate-string-formatting-argument
-                        '/network_instance[{:s}]/inter_instance_policies[{:s}_import]'.format(
-                            network_instance_name, network_instance_name), {
-                        'name': network_instance_name,
-                    }),
-                    json_config_rule_delete(
-                        '/routing_policy/policy_definition[{:s}_import]/statement[{:s}]'.format(
-                            network_instance_name, '3'), {
-                            'policy_name': '{:s}_import'.format(network_instance_name), 'statement_name': '3',
-                    }),
-                    json_config_rule_delete(
-                        '/routing_policy/policy_definition[{:s}_import]'.format(network_instance_name), {
-                            'policy_name': '{:s}_import'.format(network_instance_name),
-                    }),
-                    json_config_rule_delete(
-                        '/routing_policy/bgp_defined_set[{:s}_rt_import][route-target:{:s}]'.format(
-                            network_instance_name, bgp_route_target), {
-                            'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name),
-                            'ext_community_member'  : 'route-target:{:s}'.format(bgp_route_target),
-                    }),
-                    json_config_rule_delete(
-                        '/routing_policy/bgp_defined_set[{:s}_rt_import]'.format(network_instance_name), {
-                            'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name),
-                    }),
-                    json_config_rule_delete(
-                        # pylint: disable=duplicate-string-formatting-argument
-                        '/network_instance[{:s}]/inter_instance_policies[{:s}_export]'.format(
-                            network_instance_name, network_instance_name), {
-                            'name': network_instance_name,
-                    }),
-                    json_config_rule_delete(
-                        '/routing_policy/policy_definition[{:s}_export]/statement[{:s}]'.format(
-                            network_instance_name, '3'), {
-                            'policy_name': '{:s}_export'.format(network_instance_name), 'statement_name': '3',
-                    }),
-                    json_config_rule_delete(
-                        '/routing_policy/policy_definition[{:s}_export]'.format(network_instance_name), {
-                            'policy_name': '{:s}_export'.format(network_instance_name),
-                    }),
-                    json_config_rule_delete(
-                        '/routing_policy/bgp_defined_set[{:s}_rt_export][route-target:{:s}]'.format(
-                            network_instance_name, bgp_route_target), {
-                            'ext_community_set_name': '{:s}_rt_export'.format(network_instance_name),
-                            'ext_community_member'  : 'route-target:{:s}'.format(bgp_route_target),
-                    }),
-                    json_config_rule_delete(
-                        '/routing_policy/bgp_defined_set[{:s}_rt_export]'.format(network_instance_name), {
-                            'ext_community_set_name': '{:s}_rt_export'.format(network_instance_name),
-                    }),
-                    json_config_rule_delete(
-                        '/network_instance[{:s}]'.format(network_instance_name), {
-                            'name': network_instance_name
-                    }),
-                ])
-                self.__device_client.ConfigureDevice(Device(**json_device))
+                json_config_rules = teardown_config_rules(
+                    service_uuid, connection_uuid, device_uuid, endpoint_uuid, settings, endpoint_settings)
+
+                device = self.__task_executor.get_device(DeviceId(**json_device_id(device_uuid)))
+                for json_config_rule in json_config_rules:
+                    device.device_config.config_rules.append(ConfigRule(**json_config_rule))
+                self.__task_executor.configure_device(device)
                 results.append(True)
             except Exception as e: # pylint: disable=broad-except
                 LOGGER.exception('Unable to DeleteEndpoint({:s})'.format(str(endpoint)))
diff --git a/src/tests/ofc22/tests/test_functional_bootstrap.py b/src/tests/ofc22/tests/test_functional_bootstrap.py
index 56231512d..3ea9393c5 100644
--- a/src/tests/ofc22/tests/test_functional_bootstrap.py
+++ b/src/tests/ofc22/tests/test_functional_bootstrap.py
@@ -59,10 +59,10 @@ def test_scenario_empty(context_client : ContextClient):  # pylint: disable=rede
 def test_prepare_scenario(context_client : ContextClient):  # pylint: disable=redefined-outer-name
 
     # ----- Start the EventsCollector ----------------------------------------------------------------------------------
-    events_collector = EventsCollector(context_client)
-    events_collector.start()
+    #events_collector = EventsCollector(context_client)
+    #events_collector.start()
 
-    expected_events = []
+    #expected_events = []
 
     # ----- Create Contexts and Topologies -----------------------------------------------------------------------------
     for context in CONTEXTS:
@@ -70,7 +70,7 @@ def test_prepare_scenario(context_client : ContextClient):  # pylint: disable=re
         LOGGER.info('Adding Context {:s}'.format(context_uuid))
         response = context_client.SetContext(Context(**context))
         assert response.context_uuid.uuid == context_uuid
-        expected_events.append(('ContextEvent', EVENT_CREATE, json_context_id(context_uuid)))
+        #expected_events.append(('ContextEvent', EVENT_CREATE, json_context_id(context_uuid)))
 
     for topology in TOPOLOGIES:
         context_uuid = topology['topology_id']['context_id']['context_uuid']['uuid']
@@ -80,13 +80,13 @@ def test_prepare_scenario(context_client : ContextClient):  # pylint: disable=re
         assert response.context_id.context_uuid.uuid == context_uuid
         assert response.topology_uuid.uuid == topology_uuid
         context_id = json_context_id(context_uuid)
-        expected_events.append(('TopologyEvent', EVENT_CREATE, json_topology_id(topology_uuid, context_id=context_id)))
+        #expected_events.append(('TopologyEvent', EVENT_CREATE, json_topology_id(topology_uuid, context_id=context_id)))
 
     # ----- Validate Collected Events ----------------------------------------------------------------------------------
-    check_events(events_collector, expected_events)
+    #check_events(events_collector, expected_events)
 
     # ----- Stop the EventsCollector -----------------------------------------------------------------------------------
-    events_collector.stop()
+    #events_collector.stop()
 
 
 def test_scenario_ready(context_client : ContextClient):  # pylint: disable=redefined-outer-name
@@ -111,10 +111,10 @@ def test_devices_bootstraping(
     context_client : ContextClient, device_client : DeviceClient):  # pylint: disable=redefined-outer-name
 
     # ----- Start the EventsCollector ----------------------------------------------------------------------------------
-    events_collector = EventsCollector(context_client, log_events_received=True)
-    events_collector.start()
+    #events_collector = EventsCollector(context_client, log_events_received=True)
+    #events_collector.start()
 
-    expected_events = []
+    #expected_events = []
 
     # ----- Create Devices and Validate Collected Events ---------------------------------------------------------------
     for device, connect_rules in DEVICES:
@@ -126,11 +126,11 @@ def test_devices_bootstraping(
         response = device_client.AddDevice(Device(**device_with_connect_rules))
         assert response.device_uuid.uuid == device_uuid
 
-        expected_events.extend([
-            # Device creation, update for automation to start the device
-            ('DeviceEvent', EVENT_CREATE, json_device_id(device_uuid)),
-            #('DeviceEvent', EVENT_UPDATE, json_device_id(device_uuid)),
-        ])
+        #expected_events.extend([
+        #    # Device creation, update for automation to start the device
+        #    ('DeviceEvent', EVENT_CREATE, json_device_id(device_uuid)),
+        #    #('DeviceEvent', EVENT_UPDATE, json_device_id(device_uuid)),
+        #])
 
         #response = context_client.GetDevice(response)
         #for endpoint in response.device_endpoints:
@@ -139,10 +139,10 @@ def test_devices_bootstraping(
         #        expected_events.append(('DeviceEvent', EVENT_UPDATE, json_device_id(device_uuid)))
 
     # ----- Validate Collected Events ----------------------------------------------------------------------------------
-    check_events(events_collector, expected_events)
+    #check_events(events_collector, expected_events)
 
     # ----- Stop the EventsCollector -----------------------------------------------------------------------------------
-    events_collector.stop()
+    #events_collector.stop()
 
 
 def test_devices_bootstrapped(context_client : ContextClient):  # pylint: disable=redefined-outer-name
@@ -166,10 +166,10 @@ def test_devices_bootstrapped(context_client : ContextClient):  # pylint: disabl
 def test_links_creation(context_client : ContextClient):  # pylint: disable=redefined-outer-name
 
     # ----- Start the EventsCollector ----------------------------------------------------------------------------------
-    events_collector = EventsCollector(context_client)
-    events_collector.start()
+    #events_collector = EventsCollector(context_client)
+    #events_collector.start()
 
-    expected_events = []
+    #expected_events = []
 
     # ----- Create Links and Validate Collected Events -----------------------------------------------------------------
     for link in LINKS:
@@ -177,13 +177,13 @@ def test_links_creation(context_client : ContextClient):  # pylint: disable=rede
         LOGGER.info('Adding Link {:s}'.format(link_uuid))
         response = context_client.SetLink(Link(**link))
         assert response.link_uuid.uuid == link_uuid
-        expected_events.append(('LinkEvent', EVENT_CREATE, json_link_id(link_uuid)))
+        #expected_events.append(('LinkEvent', EVENT_CREATE, json_link_id(link_uuid)))
 
     # ----- Validate Collected Events ----------------------------------------------------------------------------------
-    check_events(events_collector, expected_events)
+    #check_events(events_collector, expected_events)
 
     # ----- Stop the EventsCollector -----------------------------------------------------------------------------------
-    events_collector.stop()
+    #events_collector.stop()
 
 
 def test_links_created(context_client : ContextClient):  # pylint: disable=redefined-outer-name
diff --git a/src/tests/ofc22/tests/test_functional_cleanup.py b/src/tests/ofc22/tests/test_functional_cleanup.py
index 6c3a79dfd..60bb86b50 100644
--- a/src/tests/ofc22/tests/test_functional_cleanup.py
+++ b/src/tests/ofc22/tests/test_functional_cleanup.py
@@ -65,10 +65,10 @@ def test_scenario_cleanup(
     context_client : ContextClient, device_client : DeviceClient):  # pylint: disable=redefined-outer-name
 
     # ----- Start the EventsCollector ----------------------------------------------------------------------------------
-    events_collector = EventsCollector(context_client)
-    events_collector.start()
+    #events_collector = EventsCollector(context_client)
+    #events_collector.start()
 
-    expected_events = []
+    #expected_events = []
 
     # ----- Delete Links and Validate Collected Events -----------------------------------------------------------------
     for link in LINKS:
@@ -76,7 +76,7 @@ def test_scenario_cleanup(
         link_uuid = link_id['link_uuid']['uuid']
         LOGGER.info('Deleting Link {:s}'.format(link_uuid))
         context_client.RemoveLink(LinkId(**link_id))
-        expected_events.append(('LinkEvent', EVENT_REMOVE, json_link_id(link_uuid)))
+        #expected_events.append(('LinkEvent', EVENT_REMOVE, json_link_id(link_uuid)))
 
     # ----- Delete Devices and Validate Collected Events ---------------------------------------------------------------
     for device, _ in DEVICES:
@@ -84,7 +84,7 @@ def test_scenario_cleanup(
         device_uuid = device_id['device_uuid']['uuid']
         LOGGER.info('Deleting Device {:s}'.format(device_uuid))
         device_client.DeleteDevice(DeviceId(**device_id))
-        expected_events.append(('DeviceEvent', EVENT_REMOVE, json_device_id(device_uuid)))
+        #expected_events.append(('DeviceEvent', EVENT_REMOVE, json_device_id(device_uuid)))
 
     # ----- Delete Topologies and Validate Collected Events ------------------------------------------------------------
     for topology in TOPOLOGIES:
@@ -94,7 +94,7 @@ def test_scenario_cleanup(
         LOGGER.info('Deleting Topology {:s}/{:s}'.format(context_uuid, topology_uuid))
         context_client.RemoveTopology(TopologyId(**topology_id))
         context_id = json_context_id(context_uuid)
-        expected_events.append(('TopologyEvent', EVENT_REMOVE, json_topology_id(topology_uuid, context_id=context_id)))
+        #expected_events.append(('TopologyEvent', EVENT_REMOVE, json_topology_id(topology_uuid, context_id=context_id)))
 
     # ----- Delete Contexts and Validate Collected Events --------------------------------------------------------------
     for context in CONTEXTS:
@@ -102,13 +102,13 @@ def test_scenario_cleanup(
         context_uuid = context_id['context_uuid']['uuid']
         LOGGER.info('Deleting Context {:s}'.format(context_uuid))
         context_client.RemoveContext(ContextId(**context_id))
-        expected_events.append(('ContextEvent', EVENT_REMOVE, json_context_id(context_uuid)))
+        #expected_events.append(('ContextEvent', EVENT_REMOVE, json_context_id(context_uuid)))
 
     # ----- Validate Collected Events ----------------------------------------------------------------------------------
-    check_events(events_collector, expected_events)
+    #check_events(events_collector, expected_events)
 
     # ----- Stop the EventsCollector -----------------------------------------------------------------------------------
-    events_collector.stop()
+    #events_collector.stop()
 
 
 def test_scenario_empty_again(context_client : ContextClient):  # pylint: disable=redefined-outer-name
diff --git a/src/tests/ofc22/tests/test_functional_create_service.py b/src/tests/ofc22/tests/test_functional_create_service.py
index a76cc444e..1f5b80cbf 100644
--- a/src/tests/ofc22/tests/test_functional_create_service.py
+++ b/src/tests/ofc22/tests/test_functional_create_service.py
@@ -69,8 +69,8 @@ def test_scenario_is_correct(context_client : ContextClient):  # pylint: disable
 
 def test_service_creation(context_client : ContextClient, osm_wim : MockOSM): # pylint: disable=redefined-outer-name
     # ----- Start the EventsCollector ----------------------------------------------------------------------------------
-    events_collector = EventsCollector(context_client, log_events_received=True)
-    events_collector.start()
+    #events_collector = EventsCollector(context_client, log_events_received=True)
+    #events_collector.start()
 
     # ----- Create Service ---------------------------------------------------------------------------------------------
     service_uuid = osm_wim.create_connectivity_service(WIM_SERVICE_TYPE, WIM_SERVICE_CONNECTION_POINTS)
@@ -78,30 +78,30 @@ def test_service_creation(context_client : ContextClient, osm_wim : MockOSM): #
 
     # ----- Validate collected events ----------------------------------------------------------------------------------
 
-    packet_connection_uuid = '{:s}:{:s}'.format(service_uuid, DEVTYPE_EMU_PR)
-    optical_connection_uuid = '{:s}:optical:{:s}'.format(service_uuid, DEVTYPE_EMU_OLS)
-    optical_service_uuid = '{:s}:optical'.format(service_uuid)
-
-    expected_events = [
-        # Create packet service and add first endpoint
-        ('ServiceEvent',    EVENT_CREATE, json_service_id(service_uuid, context_id=CONTEXT_ID)),
-        ('ServiceEvent',    EVENT_UPDATE, json_service_id(service_uuid, context_id=CONTEXT_ID)),
-
-        # Configure OLS controller, create optical service, create optical connection
-        ('DeviceEvent',     EVENT_UPDATE, json_device_id(DEVICE_O1_UUID)),
-        ('ServiceEvent',    EVENT_CREATE, json_service_id(optical_service_uuid, context_id=CONTEXT_ID)),
-        ('ConnectionEvent', EVENT_CREATE, json_connection_id(optical_connection_uuid)),
-
-        # Configure endpoint packet devices, add second endpoint to service, create connection
-        ('DeviceEvent',     EVENT_UPDATE, json_device_id(DEVICE_R1_UUID)),
-        ('DeviceEvent',     EVENT_UPDATE, json_device_id(DEVICE_R3_UUID)),
-        ('ServiceEvent',    EVENT_UPDATE, json_service_id(service_uuid, context_id=CONTEXT_ID)),
-        ('ConnectionEvent', EVENT_CREATE, json_connection_id(packet_connection_uuid)),
-    ]
-    check_events(events_collector, expected_events)
+    #packet_connection_uuid = '{:s}:{:s}'.format(service_uuid, DEVTYPE_EMU_PR)
+    #optical_connection_uuid = '{:s}:optical:{:s}'.format(service_uuid, DEVTYPE_EMU_OLS)
+    #optical_service_uuid = '{:s}:optical'.format(service_uuid)
+
+    #expected_events = [
+    #    # Create packet service and add first endpoint
+    #    ('ServiceEvent',    EVENT_CREATE, json_service_id(service_uuid, context_id=CONTEXT_ID)),
+    #    ('ServiceEvent',    EVENT_UPDATE, json_service_id(service_uuid, context_id=CONTEXT_ID)),
+    #
+    #    # Configure OLS controller, create optical service, create optical connection
+    #    ('DeviceEvent',     EVENT_UPDATE, json_device_id(DEVICE_O1_UUID)),
+    #    ('ServiceEvent',    EVENT_CREATE, json_service_id(optical_service_uuid, context_id=CONTEXT_ID)),
+    #    ('ConnectionEvent', EVENT_CREATE, json_connection_id(optical_connection_uuid)),
+    #
+    #    # Configure endpoint packet devices, add second endpoint to service, create connection
+    #    ('DeviceEvent',     EVENT_UPDATE, json_device_id(DEVICE_R1_UUID)),
+    #    ('DeviceEvent',     EVENT_UPDATE, json_device_id(DEVICE_R3_UUID)),
+    #    ('ServiceEvent',    EVENT_UPDATE, json_service_id(service_uuid, context_id=CONTEXT_ID)),
+    #    ('ConnectionEvent', EVENT_CREATE, json_connection_id(packet_connection_uuid)),
+    #]
+    #check_events(events_collector, expected_events)
 
     # ----- Stop the EventsCollector -----------------------------------------------------------------------------------
-    events_collector.stop()
+    #events_collector.stop()
 
 
 def test_scenario_service_created(context_client : ContextClient):  # pylint: disable=redefined-outer-name
diff --git a/src/tests/ofc22/tests/test_functional_delete_service.py b/src/tests/ofc22/tests/test_functional_delete_service.py
index fed2300c6..f0cc916cf 100644
--- a/src/tests/ofc22/tests/test_functional_delete_service.py
+++ b/src/tests/ofc22/tests/test_functional_delete_service.py
@@ -23,7 +23,7 @@ from common.tools.grpc.Tools import grpc_message_to_json_string
 from compute.tests.mock_osm.MockOSM import MockOSM
 from context.client.ContextClient import ContextClient
 from context.client.EventsCollector import EventsCollector
-from common.proto.context_pb2 import ContextId, Empty
+from common.proto.context_pb2 import ContextId, Empty, ServiceTypeEnum
 from .Objects import (
     CONTEXT_ID, CONTEXTS, DEVICE_O1_UUID, DEVICE_R1_UUID, DEVICE_R3_UUID, DEVICES, LINKS, TOPOLOGIES, WIM_MAPPING,
     WIM_PASSWORD, WIM_USERNAME)
@@ -77,43 +77,43 @@ def test_scenario_is_correct(context_client : ContextClient):  # pylint: disable
 
 def test_service_removal(context_client : ContextClient, osm_wim : MockOSM): # pylint: disable=redefined-outer-name
     # ----- Start the EventsCollector ----------------------------------------------------------------------------------
-    events_collector = EventsCollector(context_client, log_events_received=True)
-    events_collector.start()
+    #events_collector = EventsCollector(context_client, log_events_received=True)
+    #events_collector.start()
 
     # ----- Delete Service ---------------------------------------------------------------------------------------------
-    response = context_client.ListServiceIds(ContextId(**CONTEXT_ID))
-    LOGGER.info('Services[{:d}] = {:s}'.format(len(response.service_ids), grpc_message_to_json_string(response)))
-    assert len(response.service_ids) == 2 # L3NM + TAPI
+    response = context_client.ListServices(ContextId(**CONTEXT_ID))
+    LOGGER.info('Services[{:d}] = {:s}'.format(len(response.services), grpc_message_to_json_string(response)))
+    assert len(response.services) == 2 # L3NM + TAPI
     service_uuids = set()
-    for service_id in response.service_ids:
-        service_uuid = service_id.service_uuid.uuid
-        if service_uuid.endswith(':optical'): continue
+    for service in response.services:
+        if service.service_type != ServiceTypeEnum.SERVICETYPE_L3NM: continue
+        service_uuid = service.service_id.service_uuid.uuid
         service_uuids.add(service_uuid)
         osm_wim.conn_info[service_uuid] = {}
 
-    assert len(service_uuids) == 1  # assume a single service has been created
+    assert len(service_uuids) == 1  # assume a single L3NM service has been created
     service_uuid = set(service_uuids).pop()
 
     osm_wim.delete_connectivity_service(service_uuid)
 
     # ----- Validate collected events ----------------------------------------------------------------------------------
-    packet_connection_uuid = '{:s}:{:s}'.format(service_uuid, DEVTYPE_EMU_PR)
-    optical_connection_uuid = '{:s}:optical:{:s}'.format(service_uuid, DEVTYPE_EMU_OLS)
-    optical_service_uuid = '{:s}:optical'.format(service_uuid)
-
-    expected_events = [
-        ('ConnectionEvent', EVENT_REMOVE, json_connection_id(packet_connection_uuid)),
-        ('DeviceEvent',     EVENT_UPDATE, json_device_id(DEVICE_R1_UUID)),
-        ('DeviceEvent',     EVENT_UPDATE, json_device_id(DEVICE_R3_UUID)),
-        ('ServiceEvent',    EVENT_REMOVE, json_service_id(service_uuid, context_id=CONTEXT_ID)),
-        ('ConnectionEvent', EVENT_REMOVE, json_connection_id(optical_connection_uuid)),
-        ('DeviceEvent',     EVENT_UPDATE, json_device_id(DEVICE_O1_UUID)),
-        ('ServiceEvent',    EVENT_REMOVE, json_service_id(optical_service_uuid, context_id=CONTEXT_ID)),
-    ]
-    check_events(events_collector, expected_events)
+    #packet_connection_uuid = '{:s}:{:s}'.format(service_uuid, DEVTYPE_EMU_PR)
+    #optical_connection_uuid = '{:s}:optical:{:s}'.format(service_uuid, DEVTYPE_EMU_OLS)
+    #optical_service_uuid = '{:s}:optical'.format(service_uuid)
+
+    #expected_events = [
+    #    ('ConnectionEvent', EVENT_REMOVE, json_connection_id(packet_connection_uuid)),
+    #    ('DeviceEvent',     EVENT_UPDATE, json_device_id(DEVICE_R1_UUID)),
+    #    ('DeviceEvent',     EVENT_UPDATE, json_device_id(DEVICE_R3_UUID)),
+    #    ('ServiceEvent',    EVENT_REMOVE, json_service_id(service_uuid, context_id=CONTEXT_ID)),
+    #    ('ConnectionEvent', EVENT_REMOVE, json_connection_id(optical_connection_uuid)),
+    #    ('DeviceEvent',     EVENT_UPDATE, json_device_id(DEVICE_O1_UUID)),
+    #    ('ServiceEvent',    EVENT_REMOVE, json_service_id(optical_service_uuid, context_id=CONTEXT_ID)),
+    #]
+    #check_events(events_collector, expected_events)
 
     # ----- Stop the EventsCollector -----------------------------------------------------------------------------------
-    events_collector.stop()
+    #events_collector.stop()
 
 
 def test_services_removed(context_client : ContextClient):  # pylint: disable=redefined-outer-name
-- 
GitLab