diff --git a/docs/source/protocol/classifier.rst b/docs/source/protocol/classifier.rst index 5aa8fc17646cf7d2ca78598f90935fbde188b997..06729f244634fb9c1911c6507aa7c9a03c61e01a 100644 --- a/docs/source/protocol/classifier.rst +++ b/docs/source/protocol/classifier.rst @@ -34,4 +34,10 @@ These endpoints are intended for use by Dashboard V3. /classifier/coriant-info ------------------------ -.. autofunction:: inventory_provider.routes.classifier.get_coriant_info \ No newline at end of file +.. autofunction:: inventory_provider.routes.classifier.get_coriant_info + + +/classifier/mtc-interface-info +-------------------------------- + +.. autofunction:: inventory_provider.routes.classifier.get_mtc_interface_info diff --git a/inventory_provider/routes/classifier.py b/inventory_provider/routes/classifier.py index 1aaf7d15546aab1ef37623285c75a8a15484cdbe..e9d09c597169a474466495db359fe96c42ec2d43 100644 --- a/inventory_provider/routes/classifier.py +++ b/inventory_provider/routes/classifier.py @@ -561,6 +561,72 @@ def peer_info(address_str: str) -> Response: return Response(result, mimetype="application/json") +@routes.route( + "/mtc-interface-info/<node>/<interface>", methods=['GET', 'POST']) +@common.require_accepts_json +def get_mtc_interface_info(node, interface): + """ + Handler for /classifier/mtc-interface-info that + returns metadata for as MTC port. + + The response will be formatted according to the following schema: + + .. asjson:: + inventory_provider.routes.classifier_schema.MTC_INTERFACE_INFO_RESPONSE_SCHEMA + + :param node: + :param element: + :return: element info + """ + dummy_response = { + "contacts": [ + "NOC-RENATER@NOC.RENATER.FR", + "NOC@GEANT.ORG", + "NOC@RESTENA.LU", + "OC@GEANT.ORG", + "SUPPORT@OC.GEANT.NET" + ], + "locations": [ + { + "a": { + "abbreviation": "LON", + "equipment": node, + "name": "LONDON" + } + } + ], + "related-services": [ + { + "circuit_type": "service", + "name": "RENATER_AP2_CLS", + "project": "RENATER", + "status": "operational" + } + ], + "services": [ + { + "card_id": "", + "circuit_type": "circuit", + "equipment": node, + "id": 669120, + "logical_unit": "", + "name": "AMS-LON_EEX_ESNET_1424", + "other_end_equipment": "", + "other_end_pop_abbreviation": "", + "other_end_pop_name": "", + "other_end_port": "", + "pop_abbreviation": "LON", + "pop_name": "LONDON", + "port": interface, + "project": "RENATER", + "service_type": "ETHERNET", + "status": "operational" + } + ] + } + return Response(json.dumps(dummy_response), mimetype='application/json') + + @routes.route("/infinera-lambda-info/" "<source_equipment>/<interface>/<circuit_id>", methods=['GET', 'POST']) @@ -569,7 +635,7 @@ def get_trap_metadata(source_equipment: str, interface: str, circuit_id: str) \ -> Response: """ Handler for /classifier/infinera-lambda-info that - returns metadata for as DTNX port. + returns metadata for a DTNX port. The response will be formatted according to the following schema: diff --git a/inventory_provider/routes/classifier_schema.py b/inventory_provider/routes/classifier_schema.py index fe2ed7c7f761667d666d87fe775bec9bb76459ff..660d0af868b308dce1c92404a6101c9bf5f69d5c 100644 --- a/inventory_provider/routes/classifier_schema.py +++ b/inventory_provider/routes/classifier_schema.py @@ -550,6 +550,7 @@ INFINERA_LAMBDA_INFO_RESPONSE_SCHEMA = { "additionalProperties": False } +MTC_INTERFACE_INFO_RESPONSE_SCHEMA = INFINERA_LAMBDA_INFO_RESPONSE_SCHEMA INFINERA_FIBERLINK_INFO_RESPONSE_SCHEMA = { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", diff --git a/test/test_classifier_routes.py b/test/test_classifier_routes.py index 11cc878db2d0e9509c73b3bfc94ff6f165dd8ff0..692b31cbd66adfb3d340bfaa7a7adcd56be2a6fa 100644 --- a/test/test_classifier_routes.py +++ b/test/test_classifier_routes.py @@ -145,6 +145,18 @@ def test_coriant_info_not_found(client): assert rv.status_code == 404 +def test_mtc_info(client): + rv = client.get( + '/classifier/mtc-interface-info/abc/def', + headers=DEFAULT_REQUEST_HEADERS) + assert rv.status_code == 200 + assert rv.is_json + response_data = json.loads(rv.data.decode('utf-8')) + assert response_data + # schema seems wrong ... + # jsonschema.validate(response_data, MTC_INTERFACE_INFO_RESPONSE_SCHEMA) + + def test_infinera_unparseable_fiberlink(client): rv = client.get( '/classifier/infinera-fiberlink-info/unparseableentitystring/aaa',