diff --git a/Changelog.md b/Changelog.md index 4b19a624590645f1fb5cb68a8c899f4d7e2f2023..85f13623c2e8e4d948132baad83021a952152c22 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,22 @@ All notable changes to this project will be documented in this file. +## [0.115] - 2024-04-12 +- adding related service for circuit hierarchy + +## [0.114] - 2024-03-27 +- adding new api for mic third party +- additional search for hostname in IMS cache +- rewrote _load_interfaces to not parse the entire netconf docs +- POL1-0703: add support for IC1 dashboard +- DBOARD3-894 : Extract and persist interface-host information +- DBOARD3-888 : Add netconf retrieval +- added link-info and nokia-link-info routes +- added verify_option to allow querying of lab IMS +- initial nokia module, with netconf retrieval +- added retrieval of nokia netconf +- added retrieval of router vendor + ## [0.113] - 2024-02-06 - adding third party id as part of DBOARD3-676 - pinning lxml diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index 1cf0145609645d0dd2a6e4b06e6938c4d23db109..2df579bfd8e2ac7e589bbd99e30aa84259e7579e 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -654,7 +654,6 @@ def retrieve_and_persist_netconf_config_nokia( def refresh_nokia_interface_list(hostname, netconf_config, redis, lab=False): - bundles_keybase = f'netconf-interface-bundles:{hostname}' interfaces_all_key = f'netconf-interfaces-hosts:{hostname}' interfaces_key_base = f'netconf-interfaces:{hostname}' @@ -1225,6 +1224,7 @@ def transform_ims_data(data): c, ttc = _get_circuit_contacts(d) d['contacts'] = sorted(list(c)) d['planned_work_contacts'] = sorted(list(ttc)) + d['sid'] = circuit_ids_and_sids.get(d['id'], '') if d['id'] in circuit_ids_and_third_party_ids: d['third_party_id'] = circuit_ids_and_third_party_ids[d['id']] @@ -1618,16 +1618,60 @@ def populate_mic_with_third_party_data(interface_services, hierarchy, r): third_party_data = defaultdict(lambda: defaultdict(dict)) third_party_interface_data = defaultdict(lambda: defaultdict(dict)) + def get_related_services_ids(base_id): + s = set() + base = hierarchy[base_id] + if base['circuit-type'] == 'service': + s.add(base['id']) + if base['sub-circuits']: + for sub_circuit in base['sub-circuits']: + s |= get_related_services_ids(sub_circuit) + return s + + def get_formatted_third_party_rs(_circuit_data): + if _circuit_data and _circuit_data['status'] == 'operational' and _circuit_data['circuit-type'] == 'service': + return { + 'id': _circuit_data['id'], + 'name': _circuit_data['name'] + ' (' + _circuit_data['sid'] + ')', + 'service_type': _circuit_data['product'], + } + else: + return None + + def get_related_services_for_third_party_type_circuit(_circuit_data): + related_service_ids = list(get_related_services_ids(_circuit_data['id'])) + related_services = [] + seen_names = set() # Set to keep track of already added names + for rs_id in related_service_ids: + rs_info = hierarchy.get(rs_id) + if rs_info is not None: + formatted_rs = get_formatted_third_party_rs(rs_info) + if formatted_rs is None: + # print("Formatted RS is None for ID:", rs_id) + continue + name = formatted_rs['name'] + if name not in seen_names: # Check if the name has not been seen before + related_services.append({ + 'id': formatted_rs['id'], + 'name': name, + 'service_type': formatted_rs['service_type'] + }) + seen_names.add(name) # Add the name to the set of seen names + return related_services + def _get_formatted_third_party_data(_circuit_data): if _circuit_data['status'] == 'operational' and _circuit_data.get('third_party_id'): return { 'id': _circuit_data['id'], 'status': _circuit_data['status'], 'name': _circuit_data['name'], + 'sid': _circuit_data.get('sid', ''), + 'service': _circuit_data['circuit-type'], 'service_type': 'circuit_hierarchy', 'contacts': _circuit_data['contacts'], 'planned_work_contacts': _circuit_data['planned_work_contacts'], 'third_party_id': _circuit_data['third_party_id'], + 'related_services': get_related_services_for_third_party_type_circuit(_circuit_data) } def _get_formatted_related_service(_d): diff --git a/setup.py b/setup.py index 794247c85987689e19cd7ccfe2cd9abb68e5616e..f80da7bc8a0e6386d3c45aba57bd968e18e5a2ef 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='inventory-provider', - version="0.114", + version="0.115", author='GEANT', author_email='swd@geant.org', description='Dashboard inventory provider',