diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index ef7f351e11e2d67f994dd016b4c769a374597365..ceeb53f08f57b85b7d8bfa3b27b9415353c10077 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -117,6 +117,21 @@ def update_interfaces_to_services(self): logger.debug('<<< update_interfaces_to_services') +@app.task(base=InventoryTask, bind=True) +def update_lg_routers(self): + logger.debug('>>> update_lg_routers') + + r = get_next_redis(InventoryTask.config) + for k in r.scan_iter('opsdb:lg:*'): + r.delete(k) + + with db.connection(InventoryTask.config["ops-db"]) as cx: + for r in opsdb.lookup_lg_routers(cx): + r.set(f'opsdb:lg:{r["name"]}', json.dumps(r)) + + logger.debug('<<< update_lg_routers') + + @app.task(base=InventoryTask, bind=True) def update_equipment_locations(self): logger.debug('>>> update_equipment_locations') @@ -489,6 +504,7 @@ def launch_refresh_cache_all(config): # juniper netconf & snmp data subtasks = [ update_equipment_locations.apply_async(), + update_lg_routers.apply_async() ] for hostname in _derive_router_hostnames(config): logger.debug('queueing router refresh jobs for %r' % hostname)