Skip to content
Snippets Groups Projects
Commit 99dd0408 authored by Saket Agrahari's avatar Saket Agrahari
Browse files

Merge branch 'feature/DBOARD3-676' into 'develop'

[DBOARD3-676]: Adding changes to add third party id support on inventory provider side

See merge request !25
parents 8240dc9d 6dc6fdc8
Branches
Tags
1 merge request!25[DBOARD3-676]: Adding changes to add third party id support on inventory provider side
...@@ -123,6 +123,14 @@ def get_ids_and_sids(ds: IMS): ...@@ -123,6 +123,14 @@ def get_ids_and_sids(ds: IMS):
): ):
yield sid_circuit['objectid'], sid_circuit['value'] yield sid_circuit['objectid'], sid_circuit['value']
@log_entry_and_exit
def get_ids_and_third_party_ids(ds: IMS):
for circuit in ds.get_filtered_entities(
'ExtraFieldValue',
'extrafieldid == 2640 | value <> ""',
step_count=10000
):
yield circuit['objectid'], circuit['value']
@log_entry_and_exit @log_entry_and_exit
def get_service_types(ds: IMS): def get_service_types(ds: IMS):
......
...@@ -51,9 +51,13 @@ ALL_DATA_SCHEMA = { ...@@ -51,9 +51,13 @@ ALL_DATA_SCHEMA = {
"planned_work_contacts": { "planned_work_contacts": {
"type": "array", "type": "array",
"items": {"type": "string"} "items": {"type": "string"}
},
"third_party_id": {
"type": "array",
"items": {"type": "string"}
} }
}, },
"required": ["id", "sid", "status", "name", "service_type", "contacts", "planned_work_contacts"], # noqa E501 "required": ["id", "sid", "status", "name", "service_type", "contacts", "planned_work_contacts","third_party_id"], # noqa E501
"additionalProperties": False "additionalProperties": False
} }
} }
......
...@@ -789,6 +789,7 @@ def _extract_ims_data(ims_api_url, ims_username, ims_password): ...@@ -789,6 +789,7 @@ def _extract_ims_data(ims_api_url, ims_username, ims_password):
planned_work_contacts = {} planned_work_contacts = {}
circuit_ids_to_monitor = [] circuit_ids_to_monitor = []
circuit_ids_and_sids = {} circuit_ids_and_sids = {}
circuit_ids_and_third_party_ids = {}
additional_circuit_customers = {} additional_circuit_customers = {}
flexils_data = {} flexils_data = {}
customers = {} customers = {}
...@@ -842,6 +843,12 @@ def _extract_ims_data(ims_api_url, ims_username, ims_password): ...@@ -842,6 +843,12 @@ def _extract_ims_data(ims_api_url, ims_username, ims_password):
circuit_ids_and_sids = \ circuit_ids_and_sids = \
{cid: sid for cid, sid in ims_data.get_ids_and_sids(ds=_ds())} {cid: sid for cid, sid in ims_data.get_ids_and_sids(ds=_ds())}
@log_task_entry_and_exit
def _populate_third_party_ids():
nonlocal circuit_ids_and_third_party_ids
circuit_ids_and_third_party_ids = \
{cid: tpid for cid, tpid in ims_data.get_ids_and_third_party_ids(ds=_ds())}
@log_task_entry_and_exit @log_task_entry_and_exit
def _populate_additional_circuit_customers(): def _populate_additional_circuit_customers():
nonlocal additional_circuit_customers nonlocal additional_circuit_customers
...@@ -861,6 +868,7 @@ def _extract_ims_data(ims_api_url, ims_username, ims_password): ...@@ -861,6 +868,7 @@ def _extract_ims_data(ims_api_url, ims_username, ims_password):
executor.submit(_populate_circuit_ids_to_monitor): executor.submit(_populate_circuit_ids_to_monitor):
'circuit_ids_to_monitor', 'circuit_ids_to_monitor',
executor.submit(_populate_sids): 'sids', executor.submit(_populate_sids): 'sids',
executor.submit(_populate_third_party_ids): 'third_party_ids',
executor.submit(_populate_additional_circuit_customers): executor.submit(_populate_additional_circuit_customers):
'additional_circuit_customers' 'additional_circuit_customers'
} }
...@@ -927,6 +935,7 @@ def _extract_ims_data(ims_api_url, ims_username, ims_password): ...@@ -927,6 +935,7 @@ def _extract_ims_data(ims_api_url, ims_username, ims_password):
'planned_work_contacts': planned_work_contacts, 'planned_work_contacts': planned_work_contacts,
'circuit_ids_to_monitor': circuit_ids_to_monitor, 'circuit_ids_to_monitor': circuit_ids_to_monitor,
'circuit_ids_sids': circuit_ids_and_sids, 'circuit_ids_sids': circuit_ids_and_sids,
'circuit_ids_third_party_ids': circuit_ids_and_third_party_ids,
'additional_circuit_customers': additional_circuit_customers, 'additional_circuit_customers': additional_circuit_customers,
'hierarchy': hierarchy, 'hierarchy': hierarchy,
'port_id_details': port_id_details, 'port_id_details': port_id_details,
...@@ -947,6 +956,7 @@ def transform_ims_data(data): ...@@ -947,6 +956,7 @@ def transform_ims_data(data):
port_id_details = data['port_id_details'] port_id_details = data['port_id_details']
port_id_services = data['port_id_services'] port_id_services = data['port_id_services']
circuit_ids_and_sids = data['circuit_ids_sids'] circuit_ids_and_sids = data['circuit_ids_sids']
circuit_ids_and_third_party_ids = data['circuit_ids_third_party_ids']
geant_nodes = data['geant_nodes'] geant_nodes = data['geant_nodes']
flexils_data = data['flexils_data'] flexils_data = data['flexils_data']
customers = data['customers'] customers = data['customers']
...@@ -1064,6 +1074,9 @@ def transform_ims_data(data): ...@@ -1064,6 +1074,9 @@ def transform_ims_data(data):
if c['id'] in circuit_ids_and_sids: if c['id'] in circuit_ids_and_sids:
rs[c['id']]['sid'] = circuit_ids_and_sids[c['id']] rs[c['id']]['sid'] = circuit_ids_and_sids[c['id']]
if c['id'] in circuit_ids_and_third_party_ids:
rs[c['id']]['third_party_id'] = circuit_ids_and_third_party_ids[c['id']]
if c['sub-circuits']: if c['sub-circuits']:
for sub in c['sub-circuits']: for sub in c['sub-circuits']:
temp_parents = \ temp_parents = \
...@@ -1182,6 +1195,9 @@ def transform_ims_data(data): ...@@ -1182,6 +1195,9 @@ def transform_ims_data(data):
except StopIteration: except StopIteration:
port_circuit = None port_circuit = None
if circ['id'] in circuit_ids_and_third_party_ids:
circ['third_party_id'] = circuit_ids_and_third_party_ids[circ['id']]
sid = None sid = None
if circ['id'] in circuit_ids_and_sids: if circ['id'] in circuit_ids_and_sids:
sid = circuit_ids_and_sids[circ['id']] sid = circuit_ids_and_sids[circ['id']]
...@@ -1363,16 +1379,21 @@ def populate_mic_cache(interface_services, r): ...@@ -1363,16 +1379,21 @@ def populate_mic_cache(interface_services, r):
'name': rs['name'], 'name': rs['name'],
'service_type': rs['service_type'], 'service_type': rs['service_type'],
'contacts': rs['contacts'], 'contacts': rs['contacts'],
'planned_work_contacts': rs['planned_work_contacts'] 'planned_work_contacts': rs['planned_work_contacts'],
'third_party_id': rs.get('third_party_id', '')
} }
for services in interface_services.values(): for services in interface_services.values():
if services: if services:
current_interface_services = [] current_interface_services = []
seen_ids = set()
for d in services: for d in services:
if d.get('related-services'): if d.get('related-services'):
current_interface_services.extend( for rs in _get_formatted_rs(d):
list(_get_formatted_rs(d))) if rs['id'] not in seen_ids:
current_interface_services.append(rs)
seen_ids.add(rs['id'])
if current_interface_services: if current_interface_services:
site = f'{services[0]["pop_name"]} ' \ site = f'{services[0]["pop_name"]} ' \
f'({services[0]["pop_abbreviation"]})' f'({services[0]["pop_abbreviation"]})'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment