diff --git a/inventory_provider/routes/poller.py b/inventory_provider/routes/poller.py index 228ae0b7772f27f2dd4484a03af68984c81b6b6f..f606759e3d0bd09128270ba756c27946a8683b63 100644 --- a/inventory_provider/routes/poller.py +++ b/inventory_provider/routes/poller.py @@ -73,11 +73,8 @@ def _load_snmp_indexes(hostname=None): for doc in common.load_json_docs( config_params=current_app.config['INVENTORY_PROVIDER_CONFIG'], key_pattern=key_pattern): - router = doc['key'][len('snmp-interfaces:'):] - interfaces = dict( - [(e['name'], e['index']) for e in doc['value']]) - result[router] = interfaces + result[router] = {e['name']: e for e in doc['value']} return result @@ -147,6 +144,7 @@ def _load_interfaces(hostname): for ifc in juniper.list_interfaces(doc['value']): if not ifc['description']: continue + yield { 'router': router, 'name': ifc['name'], @@ -170,7 +168,11 @@ def _load_poller_interfaces(hostname=None): if not router_snmp or ifc['name'] not in router_snmp: # there's no way to poll this interface continue - ifc['snmp-index'] = router_snmp[ifc['name']] + ifc['snmp-index'] = router_snmp[ifc['name']]['index'] + # TODO: uncomment this when it won't break poller-admin-service + # not urgent ... it looks empirically like all logical-system + # interfaces are repeated for both communities + # ifc['snmp-community'] = router_snmp[ifc['name']]['community'] router_bundle = bundles.get(ifc['router'], None) if router_bundle: