diff --git a/inventory_provider/routes/poller.py b/inventory_provider/routes/poller.py index 775c4e57dcf0e4ad968f3cc130f6e19704e786f1..69a826253590b0e95cca98f2d9018d5b2e9780eb 100644 --- a/inventory_provider/routes/poller.py +++ b/inventory_provider/routes/poller.py @@ -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: diff --git a/tox.ini b/tox.ini index 86a7ce2a3e4293a0f2b668507c7850acee255ae4..869caf127d265a85be95bca984c1df81a0a1983d 100644 --- a/tox.ini +++ b/tox.ini @@ -3,6 +3,7 @@ envlist = py36 [flake8] exclude = venv,.tox,build +max-line-length = 120 [testenv] passenv = TEST_OPSDB_HOSTNAME,TEST_OPSDB_DBNAME,TEST_OPSDB_USERNAME,TEST_OPSDB_PASSWORD