From 63d89bfef56d249332c0be41da3455803617e8ea Mon Sep 17 00:00:00 2001 From: Erik Reid <erik.reid@geant.org> Date: Tue, 5 Feb 2019 11:40:39 +0100 Subject: [PATCH] pep8 --- inventory_provider/config.py | 1 - inventory_provider/juniper.py | 2 ++ inventory_provider/routes/classifier.py | 16 +++++++--------- inventory_provider/routes/jobs.py | 3 ++- inventory_provider/tasks/worker.py | 3 +-- test/conftest.py | 1 - test/data/update_junosspace_devices.py | 2 +- test/per_router/conftest.py | 3 ++- test/test_junosspace_io.py | 3 ++- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/inventory_provider/config.py b/inventory_provider/config.py index 917f98cd..676debfc 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 d13bc1c4..8dca8768 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 72d83a08..43c8b35a 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 2e7bda42..fe01ef86 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 82fdebeb..9992365b 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 40c6a518..304333c6 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 be38c3c2..50439981 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 0aea1c12..03646f22 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 49d40c7b..6c37c359 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']) -- GitLab