From 6828d7dd46417ff5d727de41b2cab4a250d65c5d Mon Sep 17 00:00:00 2001
From: gifrerenom <lluis.gifre@cttc.es>
Date: Wed, 1 Mar 2023 18:32:45 +0000
Subject: [PATCH] Device component:

- IETF L2VPN Driver: removed force to show emulated devices
- Microwave: correcred parsing of existing services
- Openconfig: corrected gneration of endpoints; added missing retry decorators
---
 .../service/drivers/ietf_l2vpn/TfsDebugApiClient.py    |  2 +-
 src/device/service/drivers/microwave/Tools.py          | 10 ++++++++--
 .../service/drivers/openconfig/OpenConfigDriver.py     |  2 ++
 .../service/drivers/openconfig/templates/EndPoints.py  |  2 +-
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/device/service/drivers/ietf_l2vpn/TfsDebugApiClient.py b/src/device/service/drivers/ietf_l2vpn/TfsDebugApiClient.py
index f8c4e0d94..4bf40af03 100644
--- a/src/device/service/drivers/ietf_l2vpn/TfsDebugApiClient.py
+++ b/src/device/service/drivers/ietf_l2vpn/TfsDebugApiClient.py
@@ -66,7 +66,7 @@ class TfsDebugApiClient:
         for json_device in reply.json()['devices']:
             device_uuid : str = json_device['device_id']['device_uuid']['uuid']
             device_type : str = json_device['device_type']
-            if not device_type.startswith('emu-'): device_type = 'emu-' + device_type
+            #if not device_type.startswith('emu-'): device_type = 'emu-' + device_type
             device_status = json_device['device_operational_status']
             device_url = '/devices/device[{:s}]'.format(device_uuid)
             device_data = {
diff --git a/src/device/service/drivers/microwave/Tools.py b/src/device/service/drivers/microwave/Tools.py
index 6245ff0af..4490c0f63 100644
--- a/src/device/service/drivers/microwave/Tools.py
+++ b/src/device/service/drivers/microwave/Tools.py
@@ -119,8 +119,14 @@ def config_getter(
                             resource_value['node_id_dst'] = access_point['access-node-id']
                             resource_value['tp_id_dst']   = access_point['access-ltp-id']
 
-                if len(node_ids) > 0 and resource_value['node_id_src'] not in node_ids: continue
-                if len(node_ids) > 0 and resource_value['node_id_dst'] not in node_ids: continue
+                if len(node_ids) > 0:
+                    node_id_src = resource_value.get('node_id_src')
+                    if node_id_src is None: continue
+                    if node_id_src not in node_ids: continue
+
+                    node_id_dst = resource_value.get('node_id_dst')
+                    if node_id_dst is None: continue
+                    if node_id_dst not in node_ids: continue
 
                 result.append((resource_key, resource_value))
         except requests.exceptions.Timeout:
diff --git a/src/device/service/drivers/openconfig/OpenConfigDriver.py b/src/device/service/drivers/openconfig/OpenConfigDriver.py
index ac0352752..569a0400e 100644
--- a/src/device/service/drivers/openconfig/OpenConfigDriver.py
+++ b/src/device/service/drivers/openconfig/OpenConfigDriver.py
@@ -113,9 +113,11 @@ class NetconfSessionHandler:
                 config, target=target, default_operation=default_operation, test_option=test_option,
                 error_option=error_option, format=format)
 
+    @RETRY_DECORATOR
     def locked(self, target):
         return self.__manager.locked(target=target)
 
+    @RETRY_DECORATOR
     def commit(self, confirmed=False, timeout=None, persist=None, persist_id=None):
         return self.__manager.commit(confirmed=confirmed, timeout=timeout, persist=persist, persist_id=persist_id)
 
diff --git a/src/device/service/drivers/openconfig/templates/EndPoints.py b/src/device/service/drivers/openconfig/templates/EndPoints.py
index 02fda8f0e..f16f0ffcd 100644
--- a/src/device/service/drivers/openconfig/templates/EndPoints.py
+++ b/src/device/service/drivers/openconfig/templates/EndPoints.py
@@ -55,5 +55,5 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
         add_value_from_collection(endpoint, 'sample_types', sample_types)
 
         if len(endpoint) == 0: continue
-        response.append(('/endpoint[{:s}]'.format(endpoint['uuid']), endpoint))
+        response.append(('/endpoints/endpoint[{:s}]'.format(endpoint['uuid']), endpoint))
     return response
-- 
GitLab