diff --git a/inventory_provider/config.py b/inventory_provider/config.py index 917f98cdf63b72a46a4d648011a2c09508e939be..676debfcfde1c50d12a3fbdde0513140d82b5e35 100644 --- a/inventory_provider/config.py +++ b/inventory_provider/config.py @@ -1,5 +1,4 @@ import json -import logging import re import jsonschema diff --git a/inventory_provider/juniper.py b/inventory_provider/juniper.py index d13bc1c4663e408f5550be11db2ebf3efe4b4dcb..8dca8768b1e0ec76a1fc9968a5fa5ef85eddc70e 100644 --- a/inventory_provider/juniper.py +++ b/inventory_provider/juniper.py @@ -146,6 +146,7 @@ JUNOSSPACE_DEVICES_SCHEMA = """<?xml version="1.1" encoding="UTF-8" ?> </xs:schema> """ # noqa: E501 + def _rpc(hostname, ssh): dev = Device( host=hostname, @@ -264,6 +265,7 @@ def list_bgp_routes(netconf_config): # return _loads(output[1]) if output[1] else {} # + def load_routers_from_junosspace(config): """ query junosspace for configured devices diff --git a/inventory_provider/routes/classifier.py b/inventory_provider/routes/classifier.py index 72d83a08bda95f940739b6a06845b706d3967455..43c8b35a4fd931aa48b6bdedb73aded5c601bf0e 100644 --- a/inventory_provider/routes/classifier.py +++ b/inventory_provider/routes/classifier.py @@ -1,5 +1,4 @@ import json -import re from flask import Blueprint, Response, current_app, jsonify @@ -50,11 +49,11 @@ def get_trap_metadata(source_equipment, interface): if result: result = result.decode('utf-8') else: - # todo - Change this to a call to the yet-to-be-created one source of all - # relevant information - # This could be different calls dependant on vendor, in which case we may - # need to check the trap type, or it could be a case of a key check for - # each possible data source + # TODO: Change this to a call to the yet-to-be-created one source of + # call relevant information + # This could be different calls dependant on vendor, in which case + # we may need to check the trap type, or it could be a case of a key + # check for each possible data source interface_info = r.get( 'opsdb:interface_services:%s:%s' % (source_equipment, interface)) @@ -67,8 +66,8 @@ def get_trap_metadata(source_equipment, interface): interface_info = json.loads(interface_info.decode('utf-8')) - # todo - refactor once structure of new source is decided, currently this - # is just a list of services + # TODO: refactor once structure of new source is decided, + # currently this is just a list of services vendor = interface_info[0]['manufacturer'] hostname = interface_info[0]['equipment'] # TODO: don't copy unecessary data into response (let client do this) @@ -83,4 +82,3 @@ def get_trap_metadata(source_equipment, interface): r.set(cache_key, result.encode('utf-8')) return Response(result, mimetype="application/json") - diff --git a/inventory_provider/routes/jobs.py b/inventory_provider/routes/jobs.py index 2e7bda42163535826991db85c621df76e36df1fb..fe01ef8678b35125a49c4fb4e323706fce968352 100644 --- a/inventory_provider/routes/jobs.py +++ b/inventory_provider/routes/jobs.py @@ -1,9 +1,10 @@ import logging -from flask import Blueprint, Response, current_app +from flask import Blueprint, Response from inventory_provider.tasks.app import app from inventory_provider.constants import TASK_LOGGER_NAME + routes = Blueprint("inventory-data-job-routes", __name__) diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index 82fdebeb98859535198efea0baf4b9e5ee3068f2..9992365b70eec6975a492327e6208949c38daf8f 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -269,7 +269,7 @@ def refresh_cache_all(): task_logger = logging.getLogger(constants.TASK_LOGGER_NAME) task_logger.debug('starting update_junosspace_device_list,' - 'update_inventory_system_cache') + 'update_inventory_system_cache') g = group([ update_junosspace_device_list.s(), update_inventory_system_cache.s() @@ -300,4 +300,3 @@ def refresh_cache_all(): args=[hostname, '0pBiFbD']) return "OK" - diff --git a/test/conftest.py b/test/conftest.py index 40c6a518d05884a0c5a627007e3e03e45171f0a6..304333c6f3455efc045678c5b5598d59b2d3c797 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -165,4 +165,3 @@ def mocked_redis(mocker): mocker.patch( 'inventory_provider.routes.common.redis.StrictRedis', MockedRedis) - diff --git a/test/data/update_junosspace_devices.py b/test/data/update_junosspace_devices.py index be38c3c273231c0321eacb900a3a65f09dadfb8b..5043998191076693887206342eadbe8bf1acc58f 100644 --- a/test/data/update_junosspace_devices.py +++ b/test/data/update_junosspace_devices.py @@ -24,7 +24,7 @@ def _load_devices_xml(api_url, username, password): r = requests.get( api_url + 'device-management/devices', auth=HTTPBasicAuth(username, password), - # config={'verbose': sys.stderr}) + # config={'verbose': sys.stderr}) verify=False, ) assert r.status_code == 200 diff --git a/test/per_router/conftest.py b/test/per_router/conftest.py index 0aea1c12de0a35ec7b2ef3ce6e5e1bac43e35a7c..03646f222e8289c61411e2752b59233ca5d5c756 100644 --- a/test/per_router/conftest.py +++ b/test/per_router/conftest.py @@ -1,8 +1,9 @@ import glob import os import re + from lxml import etree -from inventory_provider import config + import inventory_provider TEST_DATA_DIRNAME = os.path.realpath(os.path.join( diff --git a/test/test_junosspace_io.py b/test/test_junosspace_io.py index 49d40c7bc2add6fe455a29ac43e927ac1d196129..6c37c3597ebc4d8ab3a5eb83dd6e7ffb8e8c9824 100644 --- a/test/test_junosspace_io.py +++ b/test/test_junosspace_io.py @@ -21,7 +21,8 @@ def test_junosspace_devices_parsing(data_config): with open(TEST_DATA_FILENAME) as f: responses.add( method=responses.GET, - url = data_config['junosspace']['api'] + '/device-management/devices', + url=data_config['junosspace']['api'] + + '/device-management/devices', body=f.read()) routers = juniper.load_routers_from_junosspace(data_config['junosspace'])