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): ...@@ -238,10 +238,11 @@ def peer_info(address):
return Response(result, mimetype="application/json") 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']) methods=['GET', 'POST'])
@common.require_accepts_json @common.require_accepts_json
def get_trap_metadata(source_equipment, interface): def get_trap_metadata(source_equipment, interface, circuit_id):
r = common.get_redis() r = common.get_redis()
cache_key = 'classifier-cache:infinera:%s:%s' % ( cache_key = 'classifier-cache:infinera:%s:%s' % (
...@@ -257,16 +258,12 @@ def get_trap_metadata(source_equipment, interface): ...@@ -257,16 +258,12 @@ def get_trap_metadata(source_equipment, interface):
'opsdb:interface_services:%s:%s' % (source_equipment, interface)) 'opsdb:interface_services:%s:%s' % (source_equipment, interface))
if services: if services:
result['services'] = json.loads(services.decode('utf=8')) result['services'] = json.loads(services.decode('utf=8'))
geant_lambdas = []
for s in result['services']: gl = r.get('opsdb:geant_lambdas:%s' % circuit_id.lower())
gl = r.get('opsdb:geant_lambdas:%s' % s['name']) if gl:
if gl: t_gl = json.loads(gl.decode('utf=8'))
t_gl = json.loads(gl.decode('utf=8')) t_gl['status'] = t_gl['status'].lower()
t_gl['status'] = t_gl['status'].lower() result['geant-lambda'] = t_gl
geant_lambdas.append(t_gl)
if geant_lambdas:
result['geant-lambdas'] = geant_lambdas
if not result: if not result:
return Response( return Response(
......
...@@ -210,7 +210,8 @@ def update_geant_lambdas(): ...@@ -210,7 +210,8 @@ def update_geant_lambdas():
r.delete(key) r.delete(key)
with db.connection(InventoryTask.config["ops-db"]) as cx: with db.connection(InventoryTask.config["ops-db"]) as cx:
for ld in opsdb.get_geant_lambdas(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') logger.debug('<<< geant_lambdas')
......
...@@ -61,7 +61,7 @@ INFINERA_LINK_METADATA = { ...@@ -61,7 +61,7 @@ INFINERA_LINK_METADATA = {
}, },
"additionalProperties": False "additionalProperties": False
}, },
"geant-lambdas": { "geant-lambda": {
"type": "object", "type": "object",
"properties": { "properties": {
"id": {"type": "integer"}, "id": {"type": "integer"},
...@@ -81,8 +81,8 @@ INFINERA_LINK_METADATA = { ...@@ -81,8 +81,8 @@ INFINERA_LINK_METADATA = {
"type": "array", "type": "array",
"items": {"$ref": "#/definitions/service-info"} "items": {"$ref": "#/definitions/service-info"}
}, },
"geant-lambdas": { "geant-lambda": {
"type": "array", "type": "object",
"items": {"$ref": "#/definitions/geant-lambdas"} "items": {"$ref": "#/definitions/geant-lambdas"}
}, },
}, },
...@@ -92,7 +92,8 @@ INFINERA_LINK_METADATA = { ...@@ -92,7 +92,8 @@ INFINERA_LINK_METADATA = {
def test_trap_metadata(client_with_mocked_data): def test_trap_metadata(client_with_mocked_data):
rv = client_with_mocked_data.get( 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) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
assert rv.is_json assert rv.is_json
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment