From 63e783678b79d6c54903d292b72b1469c1bc7a84 Mon Sep 17 00:00:00 2001 From: Bjarke Madsen <bjarke.madsen@geant.org> Date: Wed, 7 Dec 2022 15:47:05 +0100 Subject: [PATCH] Remove duplicate interfaces in NREN aggregates --- brian_dashboard_manager/templating/helpers.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/brian_dashboard_manager/templating/helpers.py b/brian_dashboard_manager/templating/helpers.py index dd71709..6f98043 100644 --- a/brian_dashboard_manager/templating/helpers.py +++ b/brian_dashboard_manager/templating/helpers.py @@ -140,6 +140,7 @@ def get_nren_interface_data(services, interfaces, excluded_dashboards): result = {} customers = defaultdict(list) + aggregate_interfaces = dict() for service in services: _customers = service.get('customers') @@ -187,6 +188,8 @@ def get_nren_interface_data(services, interfaces, excluded_dashboards): router = router.replace('.geant.net', '') location = router.split('.')[1].upper() title = f'{location} - {customer} ({if_name}) | {name}' + + aggregate_interfaces[f'{router}:::{if_name}'] = True dashboard['AGGREGATES'].append({ 'measurement': measurement, 'alias': title, @@ -203,6 +206,9 @@ def get_nren_interface_data(services, interfaces, excluded_dashboards): 'scid': scid }) + def _check_in_aggregate(router, interface): + return f'{router}:::{interface}' in aggregate_interfaces + for interface in interfaces: description = interface['description'].strip() @@ -225,7 +231,8 @@ def get_nren_interface_data(services, interfaces, excluded_dashboards): 'PHYSICAL': [] }) - if port_type == 'access': + _covered_by_service = _check_in_aggregate(router, interface_name) + if port_type == 'access' and not _covered_by_service: dashboard['AGGREGATES'].append({ 'interface': interface_name, 'hostname': host, -- GitLab