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

Restricted multiple customers to L2 Circuits. RE DBOARD3-524

Updated tests
parent 17961a81
Branches
Tags
No related merge requests found
......@@ -219,16 +219,20 @@ def get_port_id_services(ds: IMS):
'customerid': circuit['customerid']
}
ports = []
cd['port_type'] = 'unknowm'
if circuit['internalports']:
ports = sorted(
circuit['internalports'], key=lambda x: x['sequencenumber'])
ports = [p['id'] for p in ports]
cd['port_type'] = 'internal'
elif circuit['ports']:
ports = sorted(
circuit['ports'], key=lambda x: x['sequencenumber'])
ports = [p['id'] for p in ports]
cd['port_type'] = 'ports'
elif circuit['portaid'] or circuit['portbid']:
ports = [circuit['portaid'], circuit['portbid']]
cd['port_type'] = 'ab'
yield from _populate_end_info(cd, ports)
ignore_status_str = ''.join([
......@@ -265,7 +269,8 @@ def get_port_id_services(ds: IMS):
'customerid': circuit['customerid'],
'port_a_id': portrelate.get(
'portid',
portrelate.get('internalportid', ''))
portrelate.get('internalportid', '')),
'port_type': 'port relate'
}
......
......@@ -475,7 +475,7 @@ def _get_dashboards(interface):
yield BRIAN_DASHBOARDS.NREN
def _get_dashboard_data(ifc, names):
def _get_dashboard_data(ifc, possible_names):
def _get_interface_type(description):
if re.match(r'^PHY', description):
......@@ -516,14 +516,17 @@ def _get_dashboard_data(ifc, names):
if BRIAN_DASHBOARDS.INFRASTRUCTURE_BACKBONE.name in dashboards:
name = _get_backbone_name(description)
names = {name}
names = [name]
elif BRIAN_DASHBOARDS.GWS_PHY_UPSTREAM.name in dashboards:
name = _get_customer_name(description)
host = ifc['router']
location = host.split('.')[1].upper()
name = f'{name} - {location}'
name = f'{_get_customer_name(description)} - {location}'
names = [name]
else:
name = _get_customer_name(description)
names = [name]
if BRIAN_DASHBOARDS.L2_CIRCUIT.name in dashboards:
names = names + possible_names
return {
**ifc,
......@@ -531,10 +534,19 @@ def _get_dashboard_data(ifc, names):
'name': name,
'interface_type': interface_type.name
},
# DBOARD3-524
# Uncomment this section if they want all customers from IMS
'dashboards_info': [{
'name': name,
'interface_type': interface_type.name
} for name in names]
} for name in set(names)]
# Uncomment this section if they only want customers from IMS that
# appear in the interface description
# 'dashboards_info': [{
# 'name': name,
# 'interface_type': interface_type.name
# } for name in set(names) if name in description.upper().split(' ')]
}
......@@ -572,7 +584,6 @@ def _get_services_and_customers(config, hostname=None, use_next_redis=False):
hostname = get_ims_equipment_name(hostname)
result = defaultdict(dict)
included_service_ids = set()
key_pattern = f'ims:interface_services:{hostname}:*' \
if hostname else 'ims:interface_services:*'
......@@ -583,16 +594,19 @@ def _get_services_and_customers(config, hostname=None, use_next_redis=False):
use_next_redis=use_next_redis):
cs = {
'services': [],
'customers': set()
'customers': []
}
included_service_ids = set()
for s in doc['value']:
if s['id'] in included_service_ids:
continue
if s.get('port_type', '') == 'ab':
continue
included_service_ids.add(s['id'])
cs['customers'].add(s['customer'])
cs['customers'].append(s['customer'])
for c in s.get('additional_customers', []):
cs['customers'].add(c['name'])
cs['customers'].append(c['name'])
if s['circuit_type'] == 'service':
cs['services'].append({
'id': s['id'],
......@@ -728,7 +742,7 @@ def load_interfaces_to_poll(
dashboards = _get_dashboards(ifc)
ifc['dashboards'] = sorted([d.name for d in dashboards])
yield _get_dashboard_data(
ifc, ifc_services_and_customers.get('customers', set()))
ifc, ifc_services_and_customers.get('customers', []))
else:
continue
return _get_populated_interfaces(basic_interfaces)
......
......@@ -395,9 +395,11 @@ def test_interface_dashboard_mapping(description, expected_dashboards):
])
def test_description_dashboard_parsing(interface, dashboard_info):
updated = poller._get_dashboard_data(interface, set())
updated = poller._get_dashboard_data(interface, [])
info = updated['dashboard_info']
assert info == dashboard_info
dashboards_info = updated['dashboards_info']
assert dashboards_info == [dashboard_info]
def test_gws_config_json(client):
......
......@@ -164,7 +164,8 @@ def test_get_port_id_services(mocker):
'project': 'ORG A',
'customer': 'ORG A',
'port_a_id': 224507,
'customerid': 57658
'customerid': 57658,
'port_type': 'internal'
},
{
'id': 663104,
......@@ -175,7 +176,8 @@ def test_get_port_id_services(mocker):
'project': 'ORG B',
'customer': 'ORG B',
'port_a_id': 224464,
'customerid': 57664
'customerid': 57664,
'port_type': 'internal'
},
{
'id': 679324,
......@@ -187,7 +189,8 @@ def test_get_port_id_services(mocker):
'customer': 'ETH',
'port_a_id': 6423107,
'port_b_id': 6419340,
'customerid': 57744
'customerid': 57744,
'port_type': 'ports'
},
{
'id': 679324,
......@@ -199,7 +202,8 @@ def test_get_port_id_services(mocker):
'customer': 'ETH',
'port_a_id': 6419340,
'port_b_id': 6423107,
'customerid': 57744
'customerid': 57744,
'port_type': 'ports'
},
{
'id': 679324,
......@@ -210,7 +214,8 @@ def test_get_port_id_services(mocker):
'project': 'ETH',
'customer': 'ETH',
'port_a_id': 6423111,
'customerid': 57744
'customerid': 57744,
'port_type': 'ports'
},
{
'id': 702560,
......@@ -221,7 +226,8 @@ def test_get_port_id_services(mocker):
'project': 'ORG C',
'customer': 'ORG C',
'port_a_id': 6419453,
'customerid': 57640
'customerid': 57640,
'port_type': 'port relate'
}
]
assert res == predicted
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment