diff --git a/inventory_provider/routes/poller.py b/inventory_provider/routes/poller.py index 46d4c3a1be73cf23b5408047fb28c02a17334943..3e38b32efca96623c5e8cb6f12e810f28332b2b4 100644 --- a/inventory_provider/routes/poller.py +++ b/inventory_provider/routes/poller.py @@ -227,6 +227,7 @@ ERROR_REPORT_INTERFACE_LIST_SCHEMA = { 'type': 'array', 'items': {'$ref': '#/definitions/interface'} } + INTERFACE_SPEED_LIST_SCHEMA = { '$schema': 'https://json-schema.org/draft-07/schema#', @@ -902,11 +903,9 @@ def interfaces(hostname=None): def load_error_report_interfaces( - config, hostname=None, no_lab=False, use_next_redis=False + config, hostname=None, use_next_redis=False ): - interfaces = _load_interfaces( - config, hostname, no_lab=no_lab, use_next_redis=use_next_redis - ) + interfaces = _load_interfaces(config, hostname, use_next_redis=use_next_redis) def filter_interface(interface: dict): return all( @@ -921,14 +920,14 @@ def load_error_report_interfaces( ) ) - def transform_interface(interfac: dict): + def transform_interface(interface: dict): return { - "router": interfac["router"], - "name": interfac["name"], - "description": interfac["description"], + "router": interface["router"], + "name": interface["name"], + "description": interface["description"], # TODO: This is a complete hack until we have a proper way to determine # router vendor - "vendor": "nokia" if interfac["router"].startswith("rt0") else "juniper" + "vendor": "nokia" if interface["router"].startswith("rt0") else "juniper" } return sorted( @@ -952,14 +951,10 @@ def error_report_interfaces(hostname=None): The response is a list of information for all interfaces that should be included in the neteng error report - plus additional vendor information (is it a juniper or nokia - router?) + and includes vendor information (either juniper or nokia) .. asjson:: - inventory_provider.routes.poller.INTERFACE_LIST_SCHEMA - - :meth:`inventory_provider.routes.poller._get_services` - is where dashboard mappings is handled. + inventory_provider.routes.poller.ERROR_REPORT_INTERFACE_LIST_SCHEMA :param hostname: optional, if present should be a router hostname :return: diff --git a/test/test_worker.py b/test/test_worker.py index b775c6ece6889ac0ea46001f070d3cf3e5c6be2c..066393e45c61e4c0025c830d0a8557148c468bab 100644 --- a/test/test_worker.py +++ b/test/test_worker.py @@ -1037,14 +1037,8 @@ def test_populate_error_report_interfaces_cache(mocker, data_config, mocked_redi all = r.get("classifier-cache:error-report-interfaces:all").decode("utf-8") assert json.loads(all) == exp_router_a_interfaces + exp_nokia_router_interfaces - router_a = ( - r.get("classifier-cache:error-report-interfaces:router_a.geant.net") - .decode("utf-8") - ) + router_a = r.get("classifier-cache:error-report-interfaces:router_a.geant.net") assert json.loads(router_a) == exp_router_a_interfaces - nokia_router = ( - r.get("classifier-cache:error-report-interfaces:rt0.geant.net") - .decode("utf-8") - ) + nokia_router = r.get("classifier-cache:error-report-interfaces:rt0.geant.net") assert json.loads(nokia_router) == exp_nokia_router_interfaces