From 5c0bfc74470e502c965405ed5bfdd316c50eb90c Mon Sep 17 00:00:00 2001 From: Robert Latta <robert.latta@geant.org> Date: Mon, 25 Nov 2019 18:16:27 +0000 Subject: [PATCH] Added related-services to infinera classification information --- inventory_provider/routes/classifier.py | 7 +++++++ test/test_infinera_classifier.py | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/inventory_provider/routes/classifier.py b/inventory_provider/routes/classifier.py index b6d83118..c4aaf73f 100644 --- a/inventory_provider/routes/classifier.py +++ b/inventory_provider/routes/classifier.py @@ -294,11 +294,18 @@ def get_trap_metadata(source_equipment, interface, circuit_id): result = result.decode('utf-8') else: result = {} + top_level_services = [] services = r.get( 'opsdb:interface_services:%s:%s' % (source_equipment, interface)) if services: result['services'] = json.loads(services.decode('utf=8')) + for s in result['services']: + tls = get_top_level_services(s['id'], r) + if tls: + top_level_services.extend(tls) + if top_level_services: + result['related-services'] = top_level_services gl = r.get('opsdb:geant_lambdas:%s' % circuit_id.lower()) if gl: diff --git a/test/test_infinera_classifier.py b/test/test_infinera_classifier.py index 892bd06f..81d2ad96 100644 --- a/test/test_infinera_classifier.py +++ b/test/test_infinera_classifier.py @@ -81,6 +81,10 @@ INFINERA_LINK_METADATA = { "type": "array", "items": {"$ref": "#/definitions/service-info"} }, + "related-services": { + "type": "array", + "items": {"$ref": "#/definitions/service-info"} + }, "geant-lambda": { "$ref": "#/definitions/geant-lambda" }, -- GitLab