diff --git a/inventory_provider/routes/classifier.py b/inventory_provider/routes/classifier.py index 5a7dd631009b36ab77171669b576f4f3f76041b2..91fb1df5d7e36ac60b4575c2bb1d91e3fd6a1ea4 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