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

Merge branch 'feature/POL1-432-add-interfaces-to-backbone' into 'develop'

Add SRV_GLOBAL and PHY to infrastructure backbone dashboards

See merge request live-projects/dashboardv3/inventory-provider!5
parents 5625f6ef 0a38b913
No related branches found
Tags 0.90
No related merge requests found
......@@ -449,9 +449,7 @@ def _get_dashboards(interface):
yield BRIAN_DASHBOARDS.LHCONE
if re.match('^SRV_MDVPN CUSTOMER', description):
yield BRIAN_DASHBOARDS.MDVPN_CUSTOMERS
if 'LAG' in description and \
re.match('(SRV_GLOBAL|LAG|PHY) INFRASTRUCTURE BACKBONE',
description):
if re.match('(SRV_GLOBAL|LAG|PHY) INFRASTRUCTURE BACKBONE', description):
yield BRIAN_DASHBOARDS.INFRASTRUCTURE_BACKBONE
if router == 'mx1.lon.uk.geant.net' \
and re.match(r'^ae12(\.\d+|$)$', ifc_name):
......@@ -483,17 +481,34 @@ def _get_dashboard_data(ifc):
if len(dashboards) == 0:
return ifc
if BRIAN_DASHBOARDS.INFRASTRUCTURE_BACKBONE.name in dashboards:
def _get_customer_name(description):
name = description.split(' ')
if len(name) >= 3:
return name[2].strip().upper()
else:
# if the description isn't properly formatted
# use it as the name to make it obvious something is wrong
return description
def _get_backbone_name(description):
name = description.split('|')
name = name[1].strip()
name = name.replace('( ', '(')
if len(name) >= 2:
name = name[1].strip()
return name.replace('( ', '(')
else:
# if the description isn't properly formatted
# use it as the name to make it obvious something is wrong
return description
if BRIAN_DASHBOARDS.INFRASTRUCTURE_BACKBONE.name in dashboards:
name = _get_backbone_name(description)
elif BRIAN_DASHBOARDS.GWS_PHY_UPSTREAM.name in dashboards:
name = description.split(' ')[2].strip().upper()
name = _get_customer_name(description)
host = ifc['router']
location = host.split('.')[1].upper()
name = f'{name} - {location}'
else:
name = description.split(' ')[2].upper()
name = _get_customer_name(description)
return {
**ifc,
......
......@@ -231,6 +231,8 @@ def test_fw_counter_bytes_oid_values(customer, interface_name, expected_oid):
['IAS_PEERS', 'IAS_PUBLIC']),
('LAG INFRASTRUCTURE BACKBONE SRF0000001 | bil-por',
['INFRASTRUCTURE_BACKBONE']),
('SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001 | bil-por',
['INFRASTRUCTURE_BACKBONE']),
('SRV_GCS CUSTOMER FCCN MICROSOFT #FCCN_NoveSBE_ExpressRoute_Vlan1945 | UNIT CONFIGURATION HAS BEEN SYSTEM GENERATED', # noqa: E501
['GCS']),
('PHY UPSTREAM TELIA SRF9940473 | Telia ID: IC-326863',
......@@ -284,6 +286,10 @@ def test_interface_dashboard_mapping(description, expected_dashboards):
'description': 'LAG INFRASTRUCTURE BACKBONE SRF0000001 | bil-por',
'dashboards': ['INFRASTRUCTURE_BACKBONE']
}, {'name': 'bil-por', 'interface_type': 'AGGREGATE'}),
({
'description': 'SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001 | bil-por', # noqa: E501
'dashboards': ['INFRASTRUCTURE_BACKBONE']
}, {'name': 'bil-por', 'interface_type': 'LOGICAL'}),
({
'description': 'SRV_GCS CUSTOMER FCCN MICROSOFT #FCCN_NoveSBE_ExpressRoute_Vlan1945 | UNIT CONFIGURATION HAS BEEN SYSTEM GENERATED', # noqa: E501
'dashboards': ['GCS']
......@@ -309,6 +315,14 @@ def test_interface_dashboard_mapping(description, expected_dashboards):
'description': 'SRV_L2CIRCUIT CUSTOMER TENET PSNC #lon-lon-GEANTOPEN-PSNC-TENET-18067 |', # noqa: E501
'dashboards': ['GEANTOPEN', 'L2_CIRCUIT']
}, {'name': 'TENET', 'interface_type': 'LOGICAL'}),
({
'description': 'SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001',
'dashboards': ['INFRASTRUCTURE_BACKBONE']
}, {'name': 'SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001', 'interface_type': 'LOGICAL'}), # noqa: E501
({
'description': 'SRV_MDVPN CUSTOMER',
'dashboards': ['MDVPN_CUSTOMERS', 'NREN']
}, {'name': 'SRV_MDVPN CUSTOMER', 'interface_type': 'LOGICAL'}),
])
def test_description_dashboard_parsing(interface, dashboard_info):
......
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