Skip to content
Snippets Groups Projects
Commit 12c44eec authored by Bjarke Madsen's avatar Bjarke Madsen
Browse files

Add interfaces to aggregate target aliases

parent 5c1de75c
No related branches found
No related tags found
No related merge requests found
......@@ -224,13 +224,17 @@ def get_interface_data(interfaces, name_parse_func=None):
def get_aggregate_interface_data(interfaces, agg_type):
result = []
# Aggregate dashboards have aggregates at the top for all remotes
# as well as aggregate panels for specific remotes.
# This builds a dict with interfaces for each remote
# and one with all interfaces.
def reduce_func(prev, curr):
remotes = prev.get(curr['remote'], [])
remotes.append(curr)
all_agg = prev.get('EVERYSINGLEPANEL', [])
all_agg = prev.get('EVERYSINGLETARGET', [])
all_agg.append(curr)
prev[curr['remote']] = remotes
prev['EVERYSINGLEPANEL'] = all_agg
prev['EVERYSINGLETARGET'] = all_agg
return prev
for interface in interfaces:
......@@ -241,12 +245,13 @@ def get_aggregate_interface_data(interfaces, agg_type):
remote = description.split(' ')[2].upper()
location = host.split('.')[1].upper()
result.append({
'type': agg_type,
'interface': interface_name,
'hostname': host,
'remote': remote,
'alias': f"{host.split('.')[1].upper()} - {remote}",
'alias': f"{location} - {remote} ({interface_name})",
})
return reduce(reduce_func, result, {})
......@@ -303,19 +308,10 @@ def get_panel_fields(panel, panel_type, datasource):
egress = ['Egress Traffic', 'Egress 95th Percentile']
is_v6 = panel_type == 'IPv6'
is_multicast = panel_type == 'multicast'
is_error = panel_type == 'errors'
in_field = 'ingressv6' if is_v6 else \
'ingressMulticast' if is_multicast else 'ingress'
in_field = 'ingressv6' if is_v6 else 'ingress'
out_field = 'egressv6' if is_v6 else \
'egressMulticast' if is_multicast else 'egress'
if is_multicast:
def add_multicast(label):
return 'Multicast ' + label
ingress = list(map(add_multicast, ingress))
egress = list(map(add_multicast, egress))
out_field = 'egressv6' if is_v6 else 'egress'
fields = [*product(ingress, [in_field]), *product(egress, [out_field])]
......@@ -343,8 +339,6 @@ def get_dashboard_data(data, datasource, tag, errors=False):
if panel.get('has_v6', False):
result.append(get_panel_fields(
{**panel, **next(gridPos)}, 'IPv6', datasource))
# result.append(get_panel_fields(
# {**panel, **next(gridPos)}, 'multicast', datasource))
if errors:
result.append(get_panel_fields(
{**panel, **next(gridPos)}, 'errors', datasource))
......@@ -417,7 +411,7 @@ def get_aggregate_dashboard_data(title, targets, datasource, tag):
gridPos = gridPos_generator(id_gen, agg=True)
panels = []
all_targets = targets.get('EVERYSINGLEPANEL', [])
all_targets = targets.get('EVERYSINGLETARGET', [])
ingress, egress = create_aggregate_panel(
title, gridPos, all_targets, datasource)
......@@ -428,8 +422,8 @@ def get_aggregate_dashboard_data(title, targets, datasource, tag):
totals_title, gridPos, all_targets, datasource)
panels.extend([t_in, t_eg])
if 'EVERYSINGLEPANEL' in targets:
del targets['EVERYSINGLEPANEL']
if 'EVERYSINGLETARGET' in targets:
del targets['EVERYSINGLETARGET']
for target in targets:
_in, _out = create_aggregate_panel(
......
......@@ -25,11 +25,12 @@ def get_nrens(interfaces):
router = host.replace('.geant.net', '')
panel_title = f"{router} - {{}} - {interface_name} - {description}"
location = host.split('.')[1].upper()
if is_aggregate_interface(interface):
nren['AGGREGATES'].append({
'interface': interface_name,
'hostname': host,
'alias': f"{host.split('.')[1].upper()} - {nren_name}"
'alias': f"{location} - {nren_name} ({interface_name})"
})
# link aggregates are also shown
......@@ -73,8 +74,6 @@ def get_panel_definitions(panels, datasource, errors=False):
if panel.get('has_v6', False):
result.append(get_panel_fields(
{**panel, **next(gridPos)}, 'IPv6', datasource))
# result.append(get_panel_fields(
# {**panel, **next(gridPos)}, 'multicast', datasource))
if errors:
result.append(get_panel_fields(
{**panel, **next(gridPos)}, 'errors', datasource))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment