From a7451ccee02cbc11c82716b6d5ad6d617828c573 Mon Sep 17 00:00:00 2001
From: Robert Latta <robert.latta@geant.org>
Date: Wed, 3 Apr 2019 14:44:11 +0100
Subject: [PATCH] Added job to get 'geant lambdas' from OpsDB

---
 inventory_provider/tasks/worker.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py
index 0083aee7..19c94dbd 100644
--- a/inventory_provider/tasks/worker.py
+++ b/inventory_provider/tasks/worker.py
@@ -200,6 +200,21 @@ def update_interface_statuses():
     logger.debug('<<< update_interface_statuses')
 
 
+@app.task
+def update_geant_lambdas():
+    logger = logging.getLogger(__name__)
+    logger.debug('>>> update_geant_lambdas')
+
+    r = get_redis(InventoryTask.config)
+    for key in r.scan_iter('opsdb:geant_lambdas:*'):
+        r.delete(key)
+    with db.connection(InventoryTask.config["ops-db"]) as cx:
+        for ld in opsdb.get_geant_lambdas(cx):
+            r.set('opsdb:geant_lambdas:%s' % ld['name'], json.dumps(ld))
+
+    logger.debug('<<< geant_lambdas')
+
+
 @app.task(base=InventoryTask, bind=True)
 def update_junosspace_device_list(self):
     logger = logging.getLogger(__name__)
@@ -457,6 +472,7 @@ def launch_refresh_cache_all(config):
     subtasks = [
         update_junosspace_device_list.s(),
         update_interfaces_to_services.s(),
+        update_geant_lambdas.s(),
         update_circuit_hierarchy.s()
     ]
 
-- 
GitLab