Skip to content
Snippets Groups Projects
Commit ad0cd942 authored by Robert Latta's avatar Robert Latta
Browse files

Changed to provision using dashboards_info

when processing data from the inventory_provider poller/interfaces endpoint BDM now uses dashboards_info rather than dashboard_info
dashboards_info contains a list of objects rather than dashboard_info which contains a single object
parent 10c92fcb
No related branches found
No related tags found
No related merge requests found
......@@ -173,12 +173,17 @@ def provision_folder(token_request, folder_name, dash,
Function to provision dashboards within a folder.
"""
def _check_valid(interface):
return interface['dashboard_info']['name'] != ''
# def _check_valid(interface):
# return interface['dashboard_info']['name'] != ''
folder = find_folder(token_request, folder_name)
tag = dash['tag']
interfaces = list(filter(_check_valid, dash['interfaces']))
interfaces = list(
filter(
lambda x: x['dashboards_info'],
dash['interfaces']
)
)
# dashboard should include error panels
errors = dash.get('errors', False)
......@@ -289,6 +294,11 @@ def _provision_interfaces(config, org_config, ds_name, token):
return not (to_exclude or lab)
relevant_interfaces = list(filter(excluded, interfaces))
for interface in relevant_interfaces:
interface['dashboards_info'] = filter(
lambda x: x['name'] != '',
interface['dashboards_info']
)
# loop over interfaces and add them to the dashboard_name
# -> folder mapping structure `dashboards` above, for convenience.
......
......@@ -79,49 +79,50 @@ def get_nren_interface_data(interfaces):
host = interface['router']
router = host.replace('.geant.net', '')
location = host.split('.')[1].upper()
panel_title = f"{router} - {{}} - {interface_name} - {description}"
info = interface['dashboard_info']
dashboard_name = info['name']
dashboards_info = interface['dashboards_info']
dashboard = result.get(dashboard_name, {
'AGGREGATES': [],
'SERVICES': [],
'PHYSICAL': []
})
location = host.split('.')[1].upper()
for info in dashboards_info:
dashboard_name = info['name']
if info['interface_type'] == 'AGGREGATE':
dashboard['AGGREGATES'].append({
'interface': interface_name,
'hostname': host,
'alias': f"{location} - {dashboard_name} ({interface_name})"
dashboard = result.get(dashboard_name, {
'AGGREGATES': [],
'SERVICES': [],
'PHYSICAL': []
})
# link aggregates are also shown
# under the physical dropdown
dashboard['PHYSICAL'].append({
'title': panel_title,
'hostname': host,
'interface': interface_name
})
elif info['interface_type'] == 'LOGICAL':
dashboard['SERVICES'].append({
'title': panel_title,
'hostname': host,
'interface': interface_name
})
elif info['interface_type'] == 'PHYSICAL':
dashboard['PHYSICAL'].append({
'title': panel_title,
'hostname': host,
'interface': interface_name
})
result[dashboard_name] = dashboard
if info['interface_type'] == 'AGGREGATE':
dashboard['AGGREGATES'].append({
'interface': interface_name,
'hostname': host,
'alias':
f"{location} - {dashboard_name} ({interface_name})"
})
# link aggregates are also shown
# under the physical dropdown
dashboard['PHYSICAL'].append({
'title': panel_title,
'hostname': host,
'interface': interface_name
})
elif info['interface_type'] == 'LOGICAL':
dashboard['SERVICES'].append({
'title': panel_title,
'hostname': host,
'interface': interface_name
})
elif info['interface_type'] == 'PHYSICAL':
dashboard['PHYSICAL'].append({
'title': panel_title,
'hostname': host,
'interface': interface_name
})
result[dashboard_name] = dashboard
return result
......@@ -141,19 +142,20 @@ def get_interface_data(interfaces):
router = host.replace('.geant.net', '')
panel_title = f"{router} - {{}} - {interface_name} - {description}"
info = interface['dashboard_info']
dashboards_info = interface['dashboards_info']
dashboard_name = info['name']
for info in dashboards_info:
dashboard_name = info['name']
dashboard = result.get(dashboard_name, [])
dashboard.append({
'title': panel_title,
'interface': interface_name,
'hostname': host,
'has_v6': len(interface.get('ipv6', [])) > 0
})
dashboard = result.get(dashboard_name, [])
dashboard.append({
'title': panel_title,
'interface': interface_name,
'hostname': host,
'has_v6': len(interface.get('ipv6', [])) > 0
})
result[dashboard_name] = dashboard
result[dashboard_name] = dashboard
return result
......@@ -187,17 +189,18 @@ def get_aggregate_interface_data(interfaces, agg_type, group_field):
interface_name = interface.get('name')
host = interface.get('router', '')
remote = interface['dashboard_info']['name']
for info in interface['dashboards_info']:
remote = info['name']
location = host.split('.')[1].upper()
result.append({
'type': agg_type,
'interface': interface_name,
'hostname': host,
'remote': remote,
'location': location,
'alias': f"{location} - {remote} ({interface_name})",
})
location = host.split('.')[1].upper()
result.append({
'type': agg_type,
'interface': interface_name,
'hostname': host,
'remote': remote,
'location': location,
'alias': f"{location} - {remote} ({interface_name})",
})
return reduce(get_reduce_func_for_field(group_field), result, {})
......
......@@ -39,6 +39,10 @@ TEST_DASHBOARD = {
"name": "EXOSCALE",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "EXOSCALE",
"interface_type": "LOGICAL"
}],
"ipv4": [
"62.40.100.26/31"
],
......@@ -71,6 +75,10 @@ TEST_DASHBOARD = {
"name": "EXOSCALE",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "EXOSCALE",
"interface_type": "LOGICAL"
}],
"ipv4": [
"62.40.100.20/31"
],
......@@ -103,6 +111,10 @@ TEST_DASHBOARD = {
"name": "T-SYSTEMS",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "T-SYSTEMS",
"interface_type": "LOGICAL"
}],
"ipv4": [
"94.100.252.88/31"
],
......@@ -133,6 +145,10 @@ TEST_DASHBOARD = {
"name": "AWS",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "AWS",
"interface_type": "LOGICAL"
}],
"ipv4": [
"52.95.219.129/31"
],
......@@ -165,6 +181,10 @@ TEST_DASHBOARD = {
"name": "CLOUDFERRO",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "CLOUDFERRO",
"interface_type": "LOGICAL"
}],
"ipv4": [
"45.92.241.127/31"
],
......@@ -195,6 +215,10 @@ TEST_DASHBOARD = {
"name": "ORACLE",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "ORACLE",
"interface_type": "LOGICAL"
}],
"ipv4": [
"130.61.6.73/31"
],
......@@ -227,6 +251,10 @@ TEST_DASHBOARD = {
"name": "AWS",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "AWS",
"interface_type": "LOGICAL"
}],
"ipv4": [
"52.95.219.37/31"
],
......@@ -259,6 +287,10 @@ TEST_DASHBOARD = {
"name": "ORACLE",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "ORACLE",
"interface_type": "LOGICAL"
}],
"ipv4": [
"132.145.7.81/31"
],
......
......@@ -28,6 +28,10 @@ TEST_INTERFACES = [
"name": "GEANT",
"interface_type": "PHYSICAL"
},
"dashboards_info": [{
"name": "GEANT",
"interface_type": "PHYSICAL"
}],
"ipv4": [],
"ipv6": []
},
......@@ -54,6 +58,10 @@ TEST_INTERFACES = [
"name": "GEANT",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "GEANT",
"interface_type": "LOGICAL"
}],
"ipv4": [
"62.40.127.131/31"
],
......@@ -84,6 +92,10 @@ TEST_INTERFACES = [
"name": "GEANT",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "GEANT",
"interface_type": "LOGICAL"
}],
"ipv4": [
"10.101.0.6/30"
],
......@@ -112,6 +124,10 @@ TEST_INTERFACES = [
"name": "GEANT",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "GEANT",
"interface_type": "LOGICAL"
}],
"ipv4": [
"62.40.127.141/31"
],
......@@ -140,6 +156,10 @@ TEST_INTERFACES = [
"name": "GEANT",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "GEANT",
"interface_type": "LOGICAL"
}],
"ipv4": [
"10.1.1.1/30"
],
......@@ -163,6 +183,10 @@ TEST_INTERFACES = [
"name": "KIAE",
"interface_type": "PHYSICAL"
},
"dashboards_info": [{
"name": "KIAE",
"interface_type": "PHYSICAL"
}],
"ipv4": [],
"ipv6": []
},
......@@ -184,6 +208,10 @@ TEST_INTERFACES = [
"name": "SWITCH",
"interface_type": "PHYSICAL"
},
"dashboards_info": [{
"name": "SWITCH",
"interface_type": "PHYSICAL"
}],
"ipv4": [],
"ipv6": []
},
......@@ -202,6 +230,10 @@ TEST_INTERFACES = [
"name": "GEANT",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "GEANT",
"interface_type": "LOGICAL"
}],
"ipv4": [],
"ipv6": []
},
......@@ -220,6 +252,10 @@ TEST_INTERFACES = [
"name": "GEANT",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "GEANT",
"interface_type": "LOGICAL"
}],
"ipv4": [],
"ipv6": []
},
......@@ -238,6 +274,10 @@ TEST_INTERFACES = [
"name": "GEANT",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "GEANT",
"interface_type": "LOGICAL"
}],
"ipv4": [],
"ipv6": []
}
......@@ -262,6 +302,10 @@ NREN_INTERFACES = [
"name": "HEANET",
"interface_type": "PHYSICAL"
},
"dashboards_info": [{
"name": "HEANET",
"interface_type": "PHYSICAL"
}],
"ipv4": [],
"ipv6": []
},
......@@ -283,6 +327,10 @@ NREN_INTERFACES = [
"name": "HEANET",
"interface_type": "PHYSICAL"
},
"dashboards_info": [{
"name": "HEANET",
"interface_type": "PHYSICAL"
}],
"ipv4": [],
"ipv6": []
},
......@@ -304,6 +352,10 @@ NREN_INTERFACES = [
"name": "HEANET",
"interface_type": "PHYSICAL"
},
"dashboards_info": [{
"name": "HEANET",
"interface_type": "PHYSICAL"
}],
"ipv4": [],
"ipv6": []
},
......@@ -327,6 +379,10 @@ NREN_INTERFACES = [
"name": "HEANET",
"interface_type": "AGGREGATE"
},
"dashboards_info": [{
"name": "HEANET",
"interface_type": "AGGREGATE"
}],
"ipv4": [],
"ipv6": []
},
......@@ -357,6 +413,10 @@ NREN_INTERFACES = [
"name": "HEANET",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "HEANET",
"interface_type": "LOGICAL"
}],
"ipv4": [
"62.40.125.13/30"
],
......@@ -391,6 +451,10 @@ NREN_INTERFACES = [
"name": "HEANET",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "HEANET",
"interface_type": "LOGICAL"
}],
"ipv4": [
"62.40.102.36/31"
],
......@@ -423,6 +487,10 @@ NREN_INTERFACES = [
"name": "HEANET",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "HEANET",
"interface_type": "LOGICAL"
}],
"ipv4": [
"83.97.88.77/30"
],
......@@ -456,6 +524,14 @@ NREN_INTERFACES = [
"name": "HEANET",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "GEANT",
"interface_type": "LOGICAL"
},
{
"name": "HEANET",
"interface_type": "LOGICAL"
}],
"ipv4": [],
"ipv6": []
}
......
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