diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index 075660cbecc731b4e5cda344d437a9ebaa7c01e2..1830053b8a54223e955028718d742c5c73bb8477 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -305,6 +305,21 @@ def refresh_interface_address_lookups(hostname, netconf): juniper.interface_addresses(netconf)) +def refresh_juniper_interface_list(hostname, netconf): + logger = logging.getLogger(__name__) + logger.debug( + 'removing cached netconf-interfaces for %r' % hostname) + + r = get_redis(InventoryTask.config) + for k in r.keys('netconf-interfaces:%s:*' % hostname): + r.delete(k) + + for ifc in juniper.list_interfaces(netconf): + r.set( + 'netconf-interfaces:%s:%s' % (hostname, ifc['name']), + json.dumps(ifc)) + + @app.task(base=InventoryTask, bind=True) def reload_router_config(self, hostname): logger = logging.getLogger(__name__) @@ -359,6 +374,7 @@ def reload_router_config(self, hostname): refresh_ix_public_peers(hostname, netconf_doc) refresh_vpn_rr_peers(hostname, netconf_doc) refresh_interface_address_lookups(hostname, netconf_doc) + refresh_juniper_interface_list(hostname, netconf_doc) clear_cached_classifier_responses(hostname) # load snmp indexes