From d04009d74ec494730f2d4ada32e6ea05e87d60f5 Mon Sep 17 00:00:00 2001 From: Robert Latta <robert.latta@geant.org> Date: Tue, 15 Feb 2022 14:22:25 +0000 Subject: [PATCH] added sid to classifier response --- inventory_provider/routes/classifier.py | 3 ++- inventory_provider/routes/classifier_schema.py | 11 ++++++++--- inventory_provider/tasks/worker.py | 4 ++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/inventory_provider/routes/classifier.py b/inventory_provider/routes/classifier.py index bc5ffed3..18e1553f 100644 --- a/inventory_provider/routes/classifier.py +++ b/inventory_provider/routes/classifier.py @@ -156,7 +156,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', + 'sid' } keys_to_remove = set(_s.keys()) - keys for k in keys_to_remove: diff --git a/inventory_provider/routes/classifier_schema.py b/inventory_provider/routes/classifier_schema.py index 7e0cb0f3..9c8b0ffe 100644 --- a/inventory_provider/routes/classifier_schema.py +++ b/inventory_provider/routes/classifier_schema.py @@ -52,7 +52,8 @@ _common_schema_definitions = { "enum": ["circuit", "service"] }, "service_type": {"type": "string"}, - "project": {"type": "string"} + "project": {"type": "string"}, + "sid": {"type": "string"} }, "additionalProperties": False }, @@ -179,6 +180,7 @@ _juniper_link_response_schema_definitions = { "type": "object", "properties": { "id": {"type": "integer"}, + "sid": {"type": "string"}, "name": {"type": "string"}, "status": { "type": "string", @@ -251,7 +253,8 @@ _juniper_link_response_schema_definitions = { "enum": ["path", "service", "l2circuit"] }, "service_type": {"type": "string"}, - "project": {"type": "string"} + "project": {"type": "string"}, + "sid": {"type": "string"} }, "required": [ "name", "status", "circuit_type", "service_type", "project"], @@ -445,6 +448,7 @@ _infinera_lambda_response_schema_definitions = { "type": "object", "properties": { "id": {"type": "integer"}, + "sid": {"type": "string"}, "name": {"type": "string"}, "status": { "type": "string", @@ -503,7 +507,8 @@ _infinera_lambda_response_schema_definitions = { "enum": ["path", "service", "l2circuit"] }, "service_type": {"type": "string"}, - "project": {"type": "string"} + "project": {"type": "string"}, + "sid": {"type": "string"} }, "required": [ "name", "status", "circuit_type", "service_type", "project"], diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index 66bf119d..4d2ee9db 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -923,6 +923,9 @@ def transform_ims_data(data): else: rs[c['id']]['status'] = 'non-monitored' + if c['id'] in circuit_ids_and_sids: + rs[c['id']]['sid'] = circuit_ids_and_sids[c['id']] + if c['sub-circuits']: for sub in c['sub-circuits']: temp_parents = \ @@ -1017,6 +1020,7 @@ def transform_ims_data(data): if circ['id'] in circuit_ids_and_sids \ and circ['status'] == 'operational': 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') -- GitLab