From ed62d254904a2c15817413b9130dbb014e908b4e Mon Sep 17 00:00:00 2001 From: Robert Latta <robert.latta@geant.org> Date: Thu, 22 Apr 2021 13:49:34 +0000 Subject: [PATCH] added path to coriant classification --- inventory_provider/routes/classifier.py | 38 ++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/inventory_provider/routes/classifier.py b/inventory_provider/routes/classifier.py index 5a7dd631..91fb1df5 100644 --- a/inventory_provider/routes/classifier.py +++ b/inventory_provider/routes/classifier.py @@ -855,7 +855,8 @@ def get_coriant_info(equipment_name: str, entity_string: str) -> Response: interface_name, r )) - for s in result.get('services', []): + services = result.get('services', []) + for s in services: s.pop('card_id', None) s.pop('port', None) s.pop('logical_unit', None) @@ -863,6 +864,41 @@ def get_coriant_info(equipment_name: str, entity_string: str) -> Response: s.pop('other_end_port', None) s.pop('other_end_logical_unit', None) + p = { + 'category': '', + 'circuit_type': '', + 'service_type': '', + 'peering_type': '', + 'status': '', + 'name': '', + 'a': { + 'equipment name': '', + 'card id': '', + 'port number': '', + 'pop': { + 'name': '', + 'city': '', + 'country': '', + 'abbreviation': '', + 'longitude': 0, + 'latitude': 0, + } + } + } + + if services: + s = services[0] + p['status'] = s['status'] + p['name'] = s['name'] + p['a']['equipment name'] = ims_source_equipment + p['a']['card id'] = card_id + p['a']['port number'] = port + p['a']['pop']['name'] = s.get('pop_name', '') + p['a']['pop']['city'] = s.get('pop_name', '') + p['a']['pop']['abbreviation'] = s.get('pop_abbreviation', '') + p['b'] = p['a'] + result['path'] = p + result['locations'] = _remove_duplicates_from_list(result['locations']) result = json.dumps(result) # cache this data for the next call -- GitLab