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

Add SIDs to services from ports

parent 6a9a582e
No related branches found
No related tags found
1 merge request!4Add feature to raise SIDs defined on ports to services on those ports
......@@ -140,7 +140,7 @@ def get_circuit_related_customers(ds: IMS):
'id': c['customer']['id'],
'name': c['customer']['name']
} for c in v] for k, v in
groupby(relations, key=itemgetter('circuitid'))}
groupby(relations, key=itemgetter('circuitid'))}
def get_port_id_services(ds: IMS):
......@@ -211,7 +211,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']],
......@@ -284,6 +284,16 @@ def get_port_details(ds: IMS):
ims.PORT_PROPERTIES['Shelf']
}
_port_sids = {
p['objectid']: p['value'] for p in ds.get_filtered_entities(
'ExtraFieldValue', 'extrafieldid == 3249 | value <> ""',
step_count=10000)}
_internal_port_sids = {
p['objectid']: p['value'] for p in ds.get_filtered_entities(
'ExtraFieldValue', 'extrafieldid == 3250 | value <> ""',
step_count=10000)}
# this is here instead of chaining to make debugging easier
def _process_ports(ports, p_type):
for p in ports:
......@@ -304,11 +314,22 @@ 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
}
_port_sid = None
if p_type == 'internal' and p['id'] in _internal_port_sids:
_port_sid = _internal_port_sids[p['id']]
elif p_type == 'external' and p['id'] in _port_sids:
_port_sid = _port_sids.get(p['id'])
if _port_sid is not None:
data['sid'] = _port_sid
yield data
yield from _process_ports(ds.get_all_entities(
......@@ -477,8 +498,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',
......@@ -490,8 +511,8 @@ def lookup_lg_routers(ds: IMS):
'abbreviation': abbreviation,
'longitude': site['longitude'],
'latitude': site['latitude'],
}
}
}
yield eq
......
......@@ -78,8 +78,8 @@ class InventoryTask(Task):
with open(os.environ['INVENTORY_PROVIDER_CONFIG_FILENAME']) as f:
logging.info(
"Initializing worker with config from: %r" %
os.environ['INVENTORY_PROVIDER_CONFIG_FILENAME'])
"Initializing worker with config from: %r" %
os.environ['INVENTORY_PROVIDER_CONFIG_FILENAME'])
InventoryTask.config = config.load(f)
logging.debug("loaded config: %r" % InventoryTask.config)
......@@ -1038,29 +1038,41 @@ def transform_ims_data(data):
f"{circ['equipment']}/{circ['other_end_equipment']}"
][circ['id']] = circ
sid = None
if circ['id'] in circuit_ids_and_sids:
sid = circuit_ids_and_sids[circ['id']]
circ['sid'] = sid
if circ['circuit_type'] == 'circuit':
logger.info(f'SID ({sid}) Circuit ({circ["id"]})'
f' Name ({circ["name"]}) not a service')
else:
sid_info = {
'circuit_id': circ['id'],
'sid': sid,
'status': circ['original_status'],
'monitored': circ['monitored'],
'name': circ['name'],
'speed': circ['calculated-speed'],
'service_type': circ['service_type'],
'project': circ['project'],
'customer': circ['customer'],
'equipment': circ['equipment'],
'port': circ['port'],
'geant_equipment': circ['equipment'] in geant_nodes
}
if sid_info not in sid_services[sid]:
sid_services[sid].append(sid_info)
elif 'sid' in details:
if len(circuits) > 1:
# we don't know which circuit
# to give the SID in this case, so skip
continue
sid = details['sid']
if sid is None:
continue
circ['sid'] = sid
# if circ['circuit_type'] == 'circuit':
# logger.info(f'SID ({sid}) Circuit ({circ["id"]})'
# f' Name ({circ["name"]}) not a service')
# else:
sid_info = {
'circuit_id': circ['id'],
'sid': sid,
'status': circ['original_status'],
'monitored': circ['monitored'],
'name': circ['name'],
'speed': circ['calculated-speed'],
'service_type': circ['service_type'],
'project': circ['project'],
'customer': circ['customer'],
'equipment': circ['equipment'],
'port': circ['port'],
'geant_equipment': circ['equipment'] in geant_nodes
}
if sid_info not in sid_services[sid]:
sid_services[sid].append(sid_info)
interface_services[k].extend(circuits)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment