From 9bdb274f59e90419a9c35171c2e2e4522eccdaa1 Mon Sep 17 00:00:00 2001
From: Erik Reid <erik.reid@geant.org>
Date: Thu, 4 Mar 2021 13:58:51 +0100
Subject: [PATCH] don't return logical-system with interface

---
 inventory_provider/routes/poller.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/inventory_provider/routes/poller.py b/inventory_provider/routes/poller.py
index 228ae0b7..f606759e 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:
-- 
GitLab