From 0db76af9c95dbf5313e0268dbd51d3e6a6bb718b Mon Sep 17 00:00:00 2001 From: Robert Latta <robert.latta@geant.org> Date: Wed, 14 Apr 2021 13:20:22 +0000 Subject: [PATCH] added contacts to classifier response --- inventory_provider/routes/classifier.py | 6 +++++- inventory_provider/routes/classifier_schema.py | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/inventory_provider/routes/classifier.py b/inventory_provider/routes/classifier.py index 08110ba2..fb006ac2 100644 --- a/inventory_provider/routes/classifier.py +++ b/inventory_provider/routes/classifier.py @@ -157,7 +157,8 @@ def get_interface_services_and_loc(ims_source_equipment, ims_interface, redis): 'project', 'pop_name', 'pop_abbreviation', 'equipment', 'card_id', 'port', 'logical_unit', 'other_end_pop_name', 'other_end_pop_abbreviation', 'other_end_equipment', - 'other_end_card_id', 'other_end_port', 'other_end_logical_unit'} + 'other_end_card_id', 'other_end_port', 'other_end_logical_unit' + } keys_to_remove = set(_s.keys()) - keys for k in keys_to_remove: _s.pop(k) @@ -166,8 +167,11 @@ def get_interface_services_and_loc(ims_source_equipment, ims_interface, redis): result = {} if raw_services: result['services'] = json.loads(raw_services.decode('utf-8')) + contacts = set() for s in result['services']: + contacts.update(set(s.pop('contacts', set()))) _format_service(s) + result['contacts'] = sorted(list(contacts)) result['related-services'] = list( get_related_services(ims_source_equipment, ims_interface, redis)) if not result['services']: diff --git a/inventory_provider/routes/classifier_schema.py b/inventory_provider/routes/classifier_schema.py index 60cc97ee..6b67e1ba 100644 --- a/inventory_provider/routes/classifier_schema.py +++ b/inventory_provider/routes/classifier_schema.py @@ -274,7 +274,11 @@ JUNIPER_LINK_RESPONSE_SCHEMA = { "type": "array", "items": {"$ref": "#/definitions/related-service-info"} }, - "locations": {"$ref": "#/definitions/locations-list"} + "locations": {"$ref": "#/definitions/locations-list"}, + "contacts": { + "type": "array", + "items": {"type": "string"} + } }, "required": ["interface", "locations"], "additionalProperties": False @@ -622,6 +626,10 @@ CORIANT_INFO_RESPONSE_SCHEMA = { "type": "array", "items": {"$ref": "#/definitions/related-service-info"} }, + "contacts": { + "type": "array", + "items": {"type": "string"} + }, }, "required": ["equipment name", "card id", "port number"], "additionalProperties": False -- GitLab