Skip to content
Snippets Groups Projects

Add feature to raise SIDs defined on ports to services on those ports

Merged Bjarke Madsen requested to merge feature/POL1-533-SERVICE-BASED-DASHBOARDS into develop
Files
6
@@ -129,9 +129,9 @@ def get_circuit_related_customers(ds: IMS):
return_value = defaultdict(list)
for ccr in ds.get_filtered_entities(
'CircuitCustomerRelation',
'circuit.inventoryStatusId== 3',
ims.CIRCUIT_CUSTOMER_RELATION['Customer']):
'CircuitCustomerRelation',
'circuit.inventoryStatusId== 3',
ims.CIRCUIT_CUSTOMER_RELATION['Customer']):
return_value[ccr['circuitid']].append(
{
'id': ccr['customer']['id'],
@@ -210,7 +210,7 @@ def get_port_id_services(ds: IMS):
'id': circuit['id'],
'name': circuit['name'],
'status': IMS_OPSDB_STATUS_MAP.get(
InventoryStatus(circuit['inventorystatusid']), 'unknown'),
InventoryStatus(circuit['inventorystatusid']), 'unknown'),
'circuit_type': circuit['circuit_type'],
'service_type': products[circuit['productid']],
'project': customers[circuit['customerid']],
@@ -273,6 +273,32 @@ def get_port_id_services(ds: IMS):
}
def get_port_sids(ds: IMS):
"""
This function fetches SIDs for external ports that have them defined,
:param ds: IMS datasource object
:returns: Dict mapping external port IDs to the SID assigned to the port
"""
return {
p['objectid']: p['value'] for p in ds.get_filtered_entities(
'ExtraFieldValue', 'extrafieldid == 3249 | value <> ""',
step_count=10000)}
def get_internal_port_sids(ds: IMS):
"""
This function fetches SIDs for external ports that have them defined,
:param ds: IMS datasource object
:returns: Dict mapping internal port IDs to the SID assigned to the port
"""
return {
p['objectid']: p['value'] for p in ds.get_filtered_entities(
'ExtraFieldValue', 'extrafieldid == 3250 | value <> ""',
step_count=10000)}
def get_port_details(ds: IMS):
port_nav_props = [
ims.PORT_PROPERTIES['Node'],
@@ -285,6 +311,13 @@ def get_port_details(ds: IMS):
# this is here instead of chaining to make debugging easier
def _process_ports(ports, p_type):
_port_sids = {}
if p_type == 'external':
_port_sids = get_port_sids(ds)
else:
_port_sids = get_internal_port_sids(ds)
for p in ports:
vendor = None
interface_name = None
@@ -303,11 +336,16 @@ def get_port_details(ds: IMS):
if not interface_name:
interface_name = p['name']
data = {
'port_id': p['id'],
'equipment_name': p['node']['name'],
'interface_name': interface_name
}
if p['id'] in _port_sids:
data['sid'] = _port_sids[p['id']]
yield data
yield from _process_ports(ds.get_all_entities(
@@ -479,8 +517,8 @@ def lookup_lg_routers(ds: IMS):
pass # no alias - ignore silently
eq = {
'equipment name': node['name'],
'type':
'equipment name': node['name'],
'type':
'INTERNAL'
if site['name'] in INTERNAL_POP_NAMES
else 'CORE',
@@ -492,8 +530,8 @@ def lookup_lg_routers(ds: IMS):
'abbreviation': abbreviation,
'longitude': site['longitude'],
'latitude': site['latitude'],
}
}
}
yield eq
Loading