diff --git a/Changelog.md b/Changelog.md index 07d8f319c6a4b8cc1196452f234a776be8804115..b6cd2534d833a6842d0aad571a8a8a7bd5b3e63b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. +## [0.80] - 2022-02-16 +- POL1-487: Adjusted filtering for COPERNICUS dashboard (no longer overrides customer names) + ## [0.79] - 2022-02-14 - Reduced logged message length - POL1-487: Added new filtering for COPERNICUS dashboard diff --git a/inventory_provider/routes/classifier.py b/inventory_provider/routes/classifier.py index bc5ffed3e78cb15dbcef5e7cb29af95e5793c569..18e1553fb2920326c1b4253d64a5bc1a2b95252a 100644 --- a/inventory_provider/routes/classifier.py +++ b/inventory_provider/routes/classifier.py @@ -156,7 +156,8 @@ def get_interface_services_and_loc(ims_source_equipment, ims_interface, redis): 'project', 'pop_name', 'pop_abbreviation', 'equipment', 'card_id', 'port', 'logical_unit', 'other_end_pop_name', 'other_end_pop_abbreviation', 'other_end_equipment', - 'other_end_card_id', 'other_end_port', 'other_end_logical_unit' + 'other_end_card_id', 'other_end_port', 'other_end_logical_unit', + 'sid' } keys_to_remove = set(_s.keys()) - keys for k in keys_to_remove: diff --git a/inventory_provider/routes/classifier_schema.py b/inventory_provider/routes/classifier_schema.py index 7e0cb0f3f836108ca2f6f1386884f24782f96dba..9c8b0ffe9bbc4a1541d6b008db2c76a9af7a758d 100644 --- a/inventory_provider/routes/classifier_schema.py +++ b/inventory_provider/routes/classifier_schema.py @@ -52,7 +52,8 @@ _common_schema_definitions = { "enum": ["circuit", "service"] }, "service_type": {"type": "string"}, - "project": {"type": "string"} + "project": {"type": "string"}, + "sid": {"type": "string"} }, "additionalProperties": False }, @@ -179,6 +180,7 @@ _juniper_link_response_schema_definitions = { "type": "object", "properties": { "id": {"type": "integer"}, + "sid": {"type": "string"}, "name": {"type": "string"}, "status": { "type": "string", @@ -251,7 +253,8 @@ _juniper_link_response_schema_definitions = { "enum": ["path", "service", "l2circuit"] }, "service_type": {"type": "string"}, - "project": {"type": "string"} + "project": {"type": "string"}, + "sid": {"type": "string"} }, "required": [ "name", "status", "circuit_type", "service_type", "project"], @@ -445,6 +448,7 @@ _infinera_lambda_response_schema_definitions = { "type": "object", "properties": { "id": {"type": "integer"}, + "sid": {"type": "string"}, "name": {"type": "string"}, "status": { "type": "string", @@ -503,7 +507,8 @@ _infinera_lambda_response_schema_definitions = { "enum": ["path", "service", "l2circuit"] }, "service_type": {"type": "string"}, - "project": {"type": "string"} + "project": {"type": "string"}, + "sid": {"type": "string"} }, "required": [ "name", "status", "circuit_type", "service_type", "project"], diff --git a/inventory_provider/routes/poller.py b/inventory_provider/routes/poller.py index c9c283c5bff11e0655bfd009f77cd9c216260798..7ff8494c26edc49339598b64c229f573f9d11041 100644 --- a/inventory_provider/routes/poller.py +++ b/inventory_provider/routes/poller.py @@ -511,8 +511,6 @@ def _get_dashboard_data(ifc): host = ifc['router'] location = host.split('.')[1].upper() name = f'{name} - {location}' - elif BRIAN_DASHBOARDS.COPERNICUS.name in dashboards: - name = "COPERNICUS" else: name = _get_customer_name(description) diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index cdcbdcbed2c18f9557645b62cd95e144ddf13b7b..4d2ee9dbc3e62a8fd81f855f3000317939d37269 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -4,6 +4,7 @@ import json import logging import os import re +import time from typing import List from celery import Task, states, chord @@ -50,10 +51,13 @@ def log_task_entry_and_exit(f): @functools.wraps(f) def _w(*args, **kwargs): logger.debug(f'>>> {f.__name__}{args}') + start_time = time.time() try: return f(*args, **kwargs) finally: - logger.debug(f'<<< {f.__name__}{args}') + end_time = time.time() + duration = end_time - start_time + logger.debug(f'<<< {f.__name__}{args} -- duration {duration}') return _w @@ -727,33 +731,40 @@ def extract_ims_data(): port_id_details = defaultdict(list) port_id_services = defaultdict(list) + @log_task_entry_and_exit def _populate_locations(): nonlocal locations locations = {k: v for k, v in ims_data.get_node_locations(ds=_ds())} + @log_task_entry_and_exit def _populate_lg_routers(): nonlocal lg_routers lg_routers = list(ims_data.lookup_lg_routers(ds=_ds())) + @log_task_entry_and_exit def _populate_geant_nodes(): nonlocal geant_nodes geant_nodes = list(ims_data.lookup_geant_nodes(ds=_ds())) + @log_task_entry_and_exit def _populate_customer_contacts(): nonlocal customer_contacts customer_contacts = \ {k: v for k, v in ims_data.get_customer_service_emails(ds=_ds())} + @log_task_entry_and_exit def _populate_circuit_ids_to_monitor(): nonlocal circuit_ids_to_monitor circuit_ids_to_monitor = \ list(ims_data.get_monitored_circuit_ids(ds=_ds())) + @log_task_entry_and_exit def _populate_sids(): nonlocal circuit_ids_and_sids circuit_ids_and_sids = \ {cid: sid for cid, sid in ims_data.get_ids_and_sids(ds=_ds())} + @log_task_entry_and_exit def _populate_additional_circuit_customer_ids(): nonlocal additional_circuit_customer_ids additional_circuit_customer_ids = \ @@ -780,12 +791,14 @@ def extract_ims_data(): if exceptions: raise InventoryTaskError(json.dumps(exceptions, indent=2)) + @log_task_entry_and_exit def _populate_hierarchy(): nonlocal hierarchy hierarchy = { d['id']: d for d in ims_data.get_circuit_hierarchy(ds=_ds())} logger.debug("hierarchy complete") + @log_task_entry_and_exit def _populate_port_id_details(): nonlocal port_id_details for x in ims_data.get_port_details(ds=_ds()): @@ -793,6 +806,7 @@ def extract_ims_data(): pd.append(x) logger.debug("Port details complete") + @log_task_entry_and_exit def _populate_circuit_info(): for x in ims_data.get_port_id_services(ds=_ds()): port_id_services[x['port_a_id']].append(x) @@ -909,6 +923,9 @@ def transform_ims_data(data): else: rs[c['id']]['status'] = 'non-monitored' + if c['id'] in circuit_ids_and_sids: + rs[c['id']]['sid'] = circuit_ids_and_sids[c['id']] + if c['sub-circuits']: for sub in c['sub-circuits']: temp_parents = \ @@ -1003,6 +1020,7 @@ def transform_ims_data(data): if circ['id'] in circuit_ids_and_sids \ and circ['status'] == 'operational': sid = circuit_ids_and_sids[circ['id']] + circ['sid'] = sid if circ['circuit_type'] == 'circuit': logger.info(f'SID ({sid}) Circuit ({circ["id"]})' f' Name ({circ["name"]}) not a service') diff --git a/setup.py b/setup.py index 31813a1e481167d93f6be6e8c20b186986d8d86c..c39660a69a402deff27509e89d6751b142aa4288 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='inventory-provider', - version="0.79", + version="0.80", author='GEANT', author_email='swd@geant.org', description='Dashboard inventory provider', diff --git a/test/data/router-info.json b/test/data/router-info.json index a67ba47dd2433769769f39c5b96973b15b9bfe1a..cedf647a3126f2ca6213f9135729a3c6b5d95691 100644 Binary files a/test/data/router-info.json and b/test/data/router-info.json differ diff --git a/test/test_general_poller_routes.py b/test/test_general_poller_routes.py index 59b8065377dddfab93e338c0ed2a3851b5bd7d21..cda06e6b496aeea370a6b90c2f3025b69ce59d07 100644 --- a/test/test_general_poller_routes.py +++ b/test/test_general_poller_routes.py @@ -384,7 +384,7 @@ def test_interface_dashboard_mapping(description, expected_dashboards): ({ 'description': 'SRV_L3VPN RE_INTERCONNECT REDCLARA #REDCLARA-MAD-COPERNICUS | ASN27750', # noqa: E501 'dashboards': ['COPERNICUS'] - }, {'name': 'COPERNICUS', 'interface_type': 'LOGICAL'}), + }, {'name': 'REDCLARA', 'interface_type': 'LOGICAL'}), ]) def test_description_dashboard_parsing(interface, dashboard_info):