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

populated L2 Circuit customers from IMS RE POL1-526

parent 6fb43483
No related branches found
No related tags found
No related merge requests found
...@@ -475,7 +475,7 @@ def _get_dashboards(interface): ...@@ -475,7 +475,7 @@ def _get_dashboards(interface):
yield BRIAN_DASHBOARDS.NREN yield BRIAN_DASHBOARDS.NREN
def _get_dashboard_data(ifc, possible_names): def _get_dashboard_data(ifc, customers):
def _get_interface_type(description): def _get_interface_type(description):
if re.match(r'^PHY', description): if re.match(r'^PHY', description):
...@@ -529,18 +529,21 @@ def _get_dashboard_data(ifc, possible_names): ...@@ -529,18 +529,21 @@ def _get_dashboard_data(ifc, possible_names):
names = [f'{_get_customer_name(description)} - {location}'] names = [f'{_get_customer_name(description)} - {location}']
elif BRIAN_DASHBOARDS.L2_CIRCUIT.name in dashboards: elif BRIAN_DASHBOARDS.L2_CIRCUIT.name in dashboards:
# This will give names derived from the Interface Description # This will give names derived from the Interface Description
names = list(_get_l2_customer_names(description)) # names = list(_get_l2_customer_names(description))
# This will give first 2 names IMS
# DBOARD3-526 names = [c['name'] for c in customers][:2]
# This will give the first customer from the Interface Description
# and additional names derived from IMS provided they also appear in
# the Interface Description
# names = [_get_customer_name(description)]
# names = names + [n for n in possible_names
# if n in description.upper().split(' ')]
else: else:
names = [_get_customer_name(description)] names = [_get_customer_name(description)]
# if no customers found just return the original data
if not names:
return ifc
# to maintain compatability with current brian dashboard manager we will
# continue to return dashboard_info with the first customer name. We will
# also return dashboards_info (note the plural of dashboards) with up to
# two customers
return { return {
**ifc, **ifc,
'dashboard_info': { 'dashboard_info': {
...@@ -608,9 +611,15 @@ def _get_services_and_customers(config, hostname=None, use_next_redis=False): ...@@ -608,9 +611,15 @@ def _get_services_and_customers(config, hostname=None, use_next_redis=False):
continue continue
included_service_ids.add(s['id']) included_service_ids.add(s['id'])
cs['customers'].append(s['customer']) cs['customers'].append({
'name': s['customer'],
'type': 'UNKNOWN'
})
for c in s.get('additional_customers', []): for c in s.get('additional_customers', []):
cs['customers'].append(c['name']) cs['customers'].append({
'name': c['name'],
'type': c.get('type', 'UNKNOWN')
})
if s['circuit_type'] == 'service': if s['circuit_type'] == 'service':
cs['services'].append({ cs['services'].append({
'id': s['id'], 'id': s['id'],
......
...@@ -318,96 +318,97 @@ def test_interface_dashboard_mapping(description, expected_dashboards): ...@@ -318,96 +318,97 @@ def test_interface_dashboard_mapping(description, expected_dashboards):
assert set(list(dashboards)) == set(expected_dashboards) assert set(list(dashboards)) == set(expected_dashboards)
@pytest.mark.parametrize('interface,expected_names,dashboard_info', [ @pytest.mark.parametrize('interface,customers,dashboard_info', [
({ ({
'description': 'SRV_IAS CUSTOMER JISC #JISC-AP1-IAS IASPS | ASN786', 'description': 'SRV_IAS CUSTOMER JISC #JISC-AP1-IAS IASPS | ASN786',
'dashboards': ['IAS_CUSTOMER', 'NREN'] 'dashboards': ['IAS_CUSTOMER', 'NREN']
}, ['JISC'], {'name': 'JISC', 'interface_type': 'LOGICAL'}), }, [{'name': 'JISC'}], {'name': 'JISC', 'interface_type': 'LOGICAL'}),
({ ({
'description': 'SRV_L2CIRCUIT CUSTOMER JISC JISC #DUB-LON-NRENBBEXT-JANET-13015 | backup for niran ', # noqa: E501 'description': 'SRV_L2CIRCUIT CUSTOMER JISC JISC #DUB-LON-NRENBBEXT-JANET-13015 | backup for niran ', # noqa: E501
'dashboards': ['L2_CIRCUIT'] 'dashboards': ['L2_CIRCUIT']
}, ['JISC'], {'name': 'JISC', 'interface_type': 'LOGICAL'}), }, [{'name': 'JISC'}], {'name': 'JISC', 'interface_type': 'LOGICAL'}),
({ ({
'description': 'SRV_L3VPN CUSTOMER EENET #EENET-AP2-LHCONE | ASN3221', 'description': 'SRV_L3VPN CUSTOMER EENET #EENET-AP2-LHCONE | ASN3221',
'dashboards': ['LHCONE', 'LHCONE_CUST', 'NREN'] 'dashboards': ['LHCONE', 'LHCONE_CUST', 'NREN']
}, ['EENET'], {'name': 'EENET', 'interface_type': 'LOGICAL'}), }, [{'name': 'EENET'}], {'name': 'EENET', 'interface_type': 'LOGICAL'}),
({ ({
'description': 'SRV_IAS PRIVATE OPTIMA-TELEKOM #HR-EduZone | For Eduzone', # noqa: E501 'description': 'SRV_IAS PRIVATE OPTIMA-TELEKOM #HR-EduZone | For Eduzone', # noqa: E501
'dashboards': ['IAS_PEERS', 'IAS_PRIVATE'] 'dashboards': ['IAS_PEERS', 'IAS_PRIVATE']
}, },
['OPTIMA-TELEKOM'], [{'name': 'OPTIMA-TELEKOM'}],
{'name': 'OPTIMA-TELEKOM', 'interface_type': 'LOGICAL'}), {'name': 'OPTIMA-TELEKOM', 'interface_type': 'LOGICAL'}),
({ ({
'description': 'SRV_CLS PRIVATE AWS #AT-AWS-CLS|ASN16509 | ', 'description': 'SRV_CLS PRIVATE AWS #AT-AWS-CLS|ASN16509 | ',
'dashboards': ['CLS', 'CLS_PEERS'] 'dashboards': ['CLS', 'CLS_PEERS']
}, ['AWS'], {'name': 'AWS', 'interface_type': 'LOGICAL'}), }, [{'name': 'AWS'}], {'name': 'AWS', 'interface_type': 'LOGICAL'}),
({ ({
'description': 'SRV_IAS PUBLIC MIX #IX_Peerings_in_MIX |', 'description': 'SRV_IAS PUBLIC MIX #IX_Peerings_in_MIX |',
'dashboards': ['IAS_PEERS', 'IAS_PUBLIC'] 'dashboards': ['IAS_PEERS', 'IAS_PUBLIC']
}, ['MIX'], {'name': 'MIX', 'interface_type': 'LOGICAL'}), }, [{'name': 'MIX'}], {'name': 'MIX', 'interface_type': 'LOGICAL'}),
({ ({
'description': 'LAG INFRASTRUCTURE BACKBONE SRF0000001 | bil-por', 'description': 'LAG INFRASTRUCTURE BACKBONE SRF0000001 | bil-por',
'dashboards': ['INFRASTRUCTURE_BACKBONE'] 'dashboards': ['INFRASTRUCTURE_BACKBONE']
}, ['bil-por'], {'name': 'bil-por', 'interface_type': 'AGGREGATE'}), }, [{'name': 'bil-por'}], {'name': 'bil-por', 'interface_type': 'AGGREGATE'}), # noqa: E501
({ ({
'description': 'SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001 | bil-por', # noqa: E501 'description': 'SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001 | bil-por', # noqa: E501
'dashboards': ['INFRASTRUCTURE_BACKBONE'] 'dashboards': ['INFRASTRUCTURE_BACKBONE']
}, ['bil-por'], {'name': 'bil-por', 'interface_type': 'LOGICAL'}), }, [{'name': 'bil-por'}], {'name': 'bil-por', 'interface_type': 'LOGICAL'}), # noqa: E501
({ ({
'description': 'SRV_GCS CUSTOMER FCCN MICROSOFT #FCCN_NoveSBE_ExpressRoute_Vlan1945 | UNIT CONFIGURATION HAS BEEN SYSTEM GENERATED', # noqa: E501 'description': 'SRV_GCS CUSTOMER FCCN MICROSOFT #FCCN_NoveSBE_ExpressRoute_Vlan1945 | UNIT CONFIGURATION HAS BEEN SYSTEM GENERATED', # noqa: E501
'dashboards': ['GCS'] 'dashboards': ['GCS']
}, ['FCCN'], {'name': 'FCCN', 'interface_type': 'LOGICAL'}), }, [{'name': 'FCCN'}], {'name': 'FCCN', 'interface_type': 'LOGICAL'}),
({ ({
'description': 'PHY UPSTREAM TELIA SRF9940473 | Telia ID: IC-326863', 'description': 'PHY UPSTREAM TELIA SRF9940473 | Telia ID: IC-326863',
'router': 'mx1.bud.hu.geant.net', 'router': 'mx1.bud.hu.geant.net',
'dashboards': ['GWS_PHY_UPSTREAM'] 'dashboards': ['GWS_PHY_UPSTREAM']
}, ['TELIA - BUD'], {'name': 'TELIA - BUD', 'interface_type': 'PHYSICAL'}), }, [{'name': 'TELIA - BUD'}], {'name': 'TELIA - BUD', 'interface_type': 'PHYSICAL'}), # noqa: E501
({ ({
'description': 'SRV_IAS UPSTREAM COGENT #COGENT_GWS_VIE | ASN174', 'description': 'SRV_IAS UPSTREAM COGENT #COGENT_GWS_VIE | ASN174',
'dashboards': ['IAS_UPSTREAM'] 'dashboards': ['IAS_UPSTREAM']
}, ['COGENT'], {'name': 'COGENT', 'interface_type': 'LOGICAL'}), }, [{'name': 'COGENT'}], {'name': 'COGENT', 'interface_type': 'LOGICAL'}),
({ ({
'description': 'SRV_L3VPN RE_INTERCONNECT CLARA #REDCLARA-LIS-LHCONE | ASN27750', # noqa: E501 'description': 'SRV_L3VPN RE_INTERCONNECT CLARA #REDCLARA-LIS-LHCONE | ASN27750', # noqa: E501
'dashboards': ['LHCONE', 'LHCONE_PEER', 'RE_PEER'] 'dashboards': ['LHCONE', 'LHCONE_PEER', 'RE_PEER']
}, ['CLARA'], {'name': 'CLARA', 'interface_type': 'LOGICAL'}), }, [{'name': 'CLARA'}], {'name': 'CLARA', 'interface_type': 'LOGICAL'}),
({ ({
'description': 'SRV_MDVPN CUSTOMER REDIRIS #RedIRIS_AP1_BGP_LU_CoC_1 | MD VPN CoC-REDIRIS - ', # noqa: E501 'description': 'SRV_MDVPN CUSTOMER REDIRIS #RedIRIS_AP1_BGP_LU_CoC_1 | MD VPN CoC-REDIRIS - ', # noqa: E501
'dashboards': ['MDVPN_CUSTOMERS', 'NREN'] 'dashboards': ['MDVPN_CUSTOMERS', 'NREN']
}, ['REDIRIS'], {'name': 'REDIRIS', 'interface_type': 'LOGICAL'}), }, [{'name': 'REDIRIS'}], {'name': 'REDIRIS', 'interface_type': 'LOGICAL'}), # noqa: E501
({ ({
'description': 'SRV_L2CIRCUIT CUSTOMER TENET PSNC #lon-lon-GEANTOPEN-PSNC-TENET-18067 |', # noqa: E501 'description': 'SRV_L2CIRCUIT CUSTOMER TENET PSNC #lon-lon-GEANTOPEN-PSNC-TENET-18067 |', # noqa: E501
'dashboards': ['GEANTOPEN', 'L2_CIRCUIT'] 'dashboards': ['GEANTOPEN', 'L2_CIRCUIT']
}, ['TENET', 'PSNC'], {'name': 'TENET', 'interface_type': 'LOGICAL'}), }, [{'name': 'TENET'}, {'name': 'PSNC'}], {'name': 'TENET', 'interface_type': 'LOGICAL'}), # noqa: E501
({ ({
'description': 'SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001', 'description': 'SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001',
'dashboards': ['INFRASTRUCTURE_BACKBONE'] 'dashboards': ['INFRASTRUCTURE_BACKBONE']
}, },
['SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001'], [{'name': 'SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001'}],
{'name': 'SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001', 'interface_type': 'LOGICAL'}), # noqa: E501 {'name': 'SRV_GLOBAL INFRASTRUCTURE BACKBONE SRF0000001', 'interface_type': 'LOGICAL'}), # noqa: E501
({ ({
'description': 'SRV_MDVPN CUSTOMER', 'description': 'SRV_MDVPN CUSTOMER',
'dashboards': ['MDVPN_CUSTOMERS', 'NREN'] 'dashboards': ['MDVPN_CUSTOMERS', 'NREN']
}, },
['SRV_MDVPN CUSTOMER'], [{'name': 'SRV_MDVPN CUSTOMER'}],
{'name': 'SRV_MDVPN CUSTOMER', 'interface_type': 'LOGICAL'}), {'name': 'SRV_MDVPN CUSTOMER', 'interface_type': 'LOGICAL'}),
({ ({
'description': 'SRV_MDVPN CUSTOMER', 'description': 'SRV_MDVPN CUSTOMER',
'dashboards': ['MDVPN_CUSTOMERS', 'NREN'] 'dashboards': ['MDVPN_CUSTOMERS', 'NREN']
}, },
['SRV_MDVPN CUSTOMER'], [{'name': 'SRV_MDVPN CUSTOMER'}],
{'name': 'SRV_MDVPN CUSTOMER', 'interface_type': 'LOGICAL'}), {'name': 'SRV_MDVPN CUSTOMER', 'interface_type': 'LOGICAL'}),
({ ({
'description': 'SRV_L3VPN RE_INTERCONNECT REDCLARA #REDCLARA-MAD-COPERNICUS | ASN27750', # noqa: E501 'description': 'SRV_L3VPN RE_INTERCONNECT REDCLARA #REDCLARA-MAD-COPERNICUS | ASN27750', # noqa: E501
'dashboards': ['COPERNICUS'] 'dashboards': ['COPERNICUS']
}, ['REDCLARA'], {'name': 'REDCLARA', 'interface_type': 'LOGICAL'}), }, [{'name': 'REDCLARA'}], {'name': 'REDCLARA', 'interface_type': 'LOGICAL'}), # noqa: E501
]) ])
def test_description_dashboard_parsing( def test_description_dashboard_parsing(
interface, expected_names, dashboard_info): interface, customers, dashboard_info):
updated = poller._get_dashboard_data(interface, expected_names) updated = poller._get_dashboard_data(interface, customers)
info = updated['dashboard_info'] info = updated['dashboard_info']
assert info == dashboard_info assert info == dashboard_info
dashboards_info = updated['dashboards_info'] dashboards_info = updated['dashboards_info']
expected_names = [c['name'] for c in customers]
assert set(expected_names) == {d['name'] for d in dashboards_info} assert set(expected_names) == {d['name'] for d in dashboards_info}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment