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

Merge branch 'feature/modify-geant-lambda-classification-population' into develop

parents fd231b30 48d3da2c
No related branches found
No related tags found
No related merge requests found
......@@ -238,10 +238,11 @@ def peer_info(address):
return Response(result, mimetype="application/json")
@routes.route("/infinera-lambda-info/<source_equipment>/<path:interface>",
@routes.route("/infinera-lambda-info/"
"<source_equipment>/<interface>/<circuit_id>",
methods=['GET', 'POST'])
@common.require_accepts_json
def get_trap_metadata(source_equipment, interface):
def get_trap_metadata(source_equipment, interface, circuit_id):
r = common.get_redis()
cache_key = 'classifier-cache:infinera:%s:%s' % (
......@@ -257,16 +258,12 @@ def get_trap_metadata(source_equipment, interface):
'opsdb:interface_services:%s:%s' % (source_equipment, interface))
if services:
result['services'] = json.loads(services.decode('utf=8'))
geant_lambdas = []
for s in result['services']:
gl = r.get('opsdb:geant_lambdas:%s' % s['name'])
if gl:
t_gl = json.loads(gl.decode('utf=8'))
t_gl['status'] = t_gl['status'].lower()
geant_lambdas.append(t_gl)
if geant_lambdas:
result['geant-lambdas'] = geant_lambdas
gl = r.get('opsdb:geant_lambdas:%s' % circuit_id.lower())
if gl:
t_gl = json.loads(gl.decode('utf=8'))
t_gl['status'] = t_gl['status'].lower()
result['geant-lambda'] = t_gl
if not result:
return Response(
......
......@@ -210,7 +210,8 @@ def update_geant_lambdas():
r.delete(key)
with db.connection(InventoryTask.config["ops-db"]) as cx:
for ld in opsdb.get_geant_lambdas(cx):
r.set('opsdb:geant_lambdas:%s' % ld['name'], json.dumps(ld))
r.set('opsdb:geant_lambdas:%s' % ld['name'].lower(),
json.dumps(ld))
logger.debug('<<< geant_lambdas')
......
......@@ -61,7 +61,7 @@ INFINERA_LINK_METADATA = {
},
"additionalProperties": False
},
"geant-lambdas": {
"geant-lambda": {
"type": "object",
"properties": {
"id": {"type": "integer"},
......@@ -81,8 +81,8 @@ INFINERA_LINK_METADATA = {
"type": "array",
"items": {"$ref": "#/definitions/service-info"}
},
"geant-lambdas": {
"type": "array",
"geant-lambda": {
"type": "object",
"items": {"$ref": "#/definitions/geant-lambdas"}
},
},
......@@ -92,7 +92,8 @@ INFINERA_LINK_METADATA = {
def test_trap_metadata(client_with_mocked_data):
rv = client_with_mocked_data.get(
'/classifier/infinera-lambda-info/LON01-DTNX10-1/1-B-2-1-3',
'/classifier/infinera-lambda-info/'
'LON2-DTNX10-1/1-A-2-1-4/gen-lon3_LHC_CERN-JANET_09013',
headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200
assert rv.is_json
......
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