diff --git a/inventory_provider/snmp.py b/inventory_provider/snmp.py index 89758f12b4f93c4bb26be2cf9e752fd08f0dccdc..2bbbf1d43bfc5f5a87925fe336ec7bf18493e533 100644 --- a/inventory_provider/snmp.py +++ b/inventory_provider/snmp.py @@ -253,7 +253,7 @@ def get_peer_state_info_juniper(hostname, community, logical_systems): hostname, community, logical_systems, _get_peer_state_info_juniper) -def get_peer_state_info_nokia(hostname, community): +def get_peer_state_info_nokia(hostname, walk_community, poll_community): """ return peering info @@ -261,11 +261,13 @@ def get_peer_state_info_nokia(hostname, community): {remote: str, oid: str, community: str} :param hostname: - :param community: + :param walk_community: community string used when querying the router for peerings + :param poll_community: community string added to the peer info for classification, + which is then used in dashboard for active state checking :return: generator yielding dicts """ oid_prefix = f'.{NOKIA_BGP_PEER_STATE}.' - for ifc in walk(hostname, community, NOKIA_BGP_PEER_STATE): + for ifc in walk(hostname, walk_community, NOKIA_BGP_PEER_STATE): oid = ifc['oid'] rest = oid[len(oid_prefix):] splits = rest.split('.') @@ -294,5 +296,5 @@ def get_peer_state_info_nokia(hostname, community): yield { 'remote': peer_address.exploded, 'oid': oid, - 'community': community + 'community': poll_community } diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index bd482a24620f3c036cf12242a97a3ddb51cf2217..4923f3f70d9faf87617fcf570e7f8d059216d797 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -627,7 +627,8 @@ def _reload_router_config_nokia( def snmp_refresh_peerings_nokia(hostname, communities, update_callback=lambda S: None): get_peerings_func = functools.partial( snmp.get_peer_state_info_nokia, - community=communities['dashboard'], + walk_community=communities['inventory-provider'], + poll_community=communities['dashboard'], ) snmp_refresh_peerings( get_peerings_func, hostname, 'nokia', update_callback=update_callback diff --git a/test/conftest.py b/test/conftest.py index ee51ec46e9e5740d28e08481c9de8d1186b89a90..a2661d07f88827dde121551793e23b2eba961872 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -332,7 +332,7 @@ def mocked_worker_module( keys = filter(_wanted, cached_test_data.keys()) return [json.loads(cached_test_data[k]) for k in keys] - def _mocked_snmp_peerings_nokia(hostname, community): + def _mocked_snmp_peerings_nokia(hostname, walk_community, poll_community): def _wanted(s): return re.match(r'^snmp-peerings:hosts:nokia\d.*', s) diff --git a/test/per_router/test_celery_worker.py b/test/per_router/test_celery_worker.py index f60e875d1909f983440ac4b4b67d9500cf5ffc3c..450db076e72aa7b0cbb57b21b9fe2a73856f361a 100644 --- a/test/per_router/test_celery_worker.py +++ b/test/per_router/test_celery_worker.py @@ -81,7 +81,7 @@ def test_snmp_refresh_peerings_nokia(mocked_worker_module, nokia_router): for k in list(_ifc_keys()): del backend_db()[k] - communities = {'dashboard': 'fake-community'} + communities = {'dashboard': 'fake-community', 'inventory-provider': 'fake-community'} worker.snmp_refresh_peerings_nokia(nokia_router, communities) assert list(_ifc_keys()) diff --git a/test/per_router/test_snmp_handling.py b/test/per_router/test_snmp_handling.py index b813448ea8b5a502925fb30590147274b3cb6850..215982b63dd081abbf128ba906af7e1c7dec2e80 100644 --- a/test/per_router/test_snmp_handling.py +++ b/test/per_router/test_snmp_handling.py @@ -118,6 +118,6 @@ def test_peer_info_nokia(mocker): with open(os.path.join(TEST_DATA_DIRNAME, "snmp-peer-info-nokia.json")) as f: test_data = json.load(f) mocker.patch('inventory_provider.snmp.walk', lambda *args: test_data) - res = list(snmp.get_peer_state_info_nokia('ignored', 'ignored')) + res = list(snmp.get_peer_state_info_nokia('ignored', 'ignored', 'ignored')) jsonschema.validate(res, PEERING_RESULT_SCHEMA) assert len(res) == len(test_data)