Skip to content
Snippets Groups Projects

only build snmp indices once per endpoint request

Merged Sam Roberts requested to merge feature/DBOARD-743-snmp-fix into develop
1 unresolved thread
2 files
+ 5
4
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -67,6 +67,7 @@ import itertools
import json
import logging
import re
from functools import partial
from flask import Blueprint, Response, current_app, request, jsonify
@@ -1214,9 +1215,7 @@ def _get_services_internal(service_type=None):
num_threads=20):
yield doc['value']
def _add_snmp(s):
all_snmp_info = common.load_snmp_indexes(
current_app.config['INVENTORY_PROVIDER_CONFIG'], )
def _add_snmp(s, all_snmp_info):
snmp_interfaces = all_snmp_info.get(s['hostname'], {})
interface_info = snmp_interfaces.get(s['interface'], None)
if interface_info:
@@ -1272,7 +1271,8 @@ def _get_services_internal(service_type=None):
result = filter(_wanted_in_output, result)
result = map(_format_services, result)
if include_snmp:
result = map(_add_snmp, result)
all_snmp_info = common.load_snmp_indexes(current_app.config['INVENTORY_PROVIDER_CONFIG'])
result = map(partial(_add_snmp, all_snmp_info=all_snmp_info), result)
result = list(result)
if not result:
Loading