Skip to content
Snippets Groups Projects
Commit 7aaaf557 authored by Robert Latta's avatar Robert Latta
Browse files

added MTC endpoint implementation

parent 8706040d
No related branches found
No related tags found
No related merge requests found
......@@ -578,53 +578,31 @@ def get_mtc_interface_info(node, interface):
: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')
r = common.get_current_redis()
interface = interface.rsplit('-', 1)[0]
# ims_source_equipment = get_ims_equipment_name(equipment_name, r)
# ims_interface = get_ims_interface(entity_string)
cache_key = f'classifier-cache:mtc:{node}:{interface}'
result = _ignore_cache_or_retrieve(request, cache_key, r)
if not result:
result = get_interface_services_and_loc(node, interface, r)
if not result['locations'] and 'services' not in result:
result = {}
if not result:
return Response(
response="no available info for "
f"{node} {interface}",
status=404,
mimetype="text/html")
return Response(json.dumps(result), mimetype="application/json")
@routes.route("/infinera-lambda-info/"
......
......@@ -449,7 +449,7 @@ _infinera_lambda_response_schema_definitions = {
},
"circuit_type": {
"type": "string",
"enum": ["path", "service", "l2circuit"]
"enum": ["path", "service", "l2circuit", "circuit"]
},
"service_type": {"type": "string"},
"project": {"type": "string"},
......
......@@ -5,7 +5,7 @@ import pytest
from inventory_provider.routes.classifier_schema \
import JUNIPER_LINK_RESPONSE_SCHEMA, PEER_INFO_RESPONSE_SCHEMA, \
INFINERA_LAMBDA_INFO_RESPONSE_SCHEMA, CORIANT_INFO_RESPONSE_SCHEMA, \
INFINERA_FIBERLINK_INFO_RESPONSE_SCHEMA
INFINERA_FIBERLINK_INFO_RESPONSE_SCHEMA, MTC_INTERFACE_INFO_RESPONSE_SCHEMA
DEFAULT_REQUEST_HEADERS = {
"Content-type": "application/json",
......@@ -147,14 +147,14 @@ def test_coriant_info_not_found(client):
def test_mtc_info(client):
rv = client.get(
'/classifier/mtc-interface-info/abc/def',
'/classifier/mtc-interface-info/MAD01-MTC6-1/1-A-1-S1-1',
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)
jsonschema.validate(response_data, MTC_INTERFACE_INFO_RESPONSE_SCHEMA)
def test_infinera_unparseable_fiberlink(client):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment