From 633defb031dee80e9f9a8e4cb3e17fbdad793053 Mon Sep 17 00:00:00 2001
From: gifrerenom <lluis.gifre@cttc.es>
Date: Wed, 6 Sep 2023 17:32:14 +0000
Subject: [PATCH] Context component:

- Corrected parsing of topologydevicemodel relations in Device
---
 src/context/service/database/Device.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/context/service/database/Device.py b/src/context/service/database/Device.py
index 9897aa0af..df57791ad 100644
--- a/src/context/service/database/Device.py
+++ b/src/context/service/database/Device.py
@@ -185,6 +185,7 @@ def device_set(db_engine : Engine, messagebroker : MessageBroker, request : Devi
             endpoint_updates = session.execute(stmt).fetchall()
             updated_endpoints = any([(updated_at > created_at) for created_at,updated_at in endpoint_updates])
 
+        device_topology_ids = []
         if not updated or len(related_topologies) > 1:
             # Only update topology-device relations when device is created (not updated) or when endpoints are
             # modified (len(related_topologies) > 1).
@@ -204,8 +205,6 @@ def device_set(db_engine : Engine, messagebroker : MessageBroker, request : Devi
                 device_topologies : List[TopologyModel] = query.all()
                 device_topology_ids = [obj.dump_id() for obj in device_topologies]
                 LOGGER.warning('device_topology_ids={:s}'.format(str(device_topology_ids)))
-            else:
-                device_topology_ids = []
 
         changed_config_rules = upsert_config_rules(session, config_rules, device_uuid=device_uuid)
 
-- 
GitLab