Skip to content
Snippets Groups Projects
Commit 937af5f4 authored by Erik Reid's avatar Erik Reid
Browse files

added snmp to peer-info response

parent 90aaa554
No related branches found
No related tags found
No related merge requests found
......@@ -240,7 +240,7 @@ def get_juniper_link_info(source_equipment, interface):
# cache this data for the next call
r.set(cache_key, result.encode('utf-8'))
return Response(result, mimetype="application/json")
return Response(result, mimetype='application/json')
def ix_peering_info(peer_info):
......@@ -362,14 +362,14 @@ def peer_info(address):
'locations': []
}
info = r.get('ix_public_peer:%s' % address)
info = r.get(f'ix_public_peer:{address}')
if info:
info = info.decode('utf-8')
info = json.loads(info)
result['ix-public-peer-info'] = ix_peering_info(info)
result['locations'] += _locations_from_router(info['router'])
info = r.get('vpn_rr_peer:%s' % address)
info = r.get(f'vpn_rr_peer:{address}')
if info:
info = info.decode('utf-8')
info = json.loads(info)
......@@ -383,12 +383,21 @@ def peer_info(address):
result['locations'] += [
_location_from_service_dict(s) for s in i['services']]
snmp_info = r.get(
f'snmp-peerings:{address}')
if snmp_info:
snmp_info = json.loads(snmp_info.decode('utf-8'))
result['snmp'] = {
'community': snmp_info['community'],
'oid': snmp_info['oid']
}
result['locations'] = _remove_duplicates_from_list(result['locations'])
result = json.dumps(result)
# cache this data for the next call
r.set(cache_key, result.encode('utf-8'))
return Response(result, mimetype="application/json")
return Response(result, mimetype='application/json')
@routes.route("/infinera-lambda-info/"
......@@ -442,7 +451,7 @@ def get_trap_metadata(source_equipment, interface, circuit_id):
# cache this data for the next call
r.set(cache_key, result.encode('utf-8'))
return Response(result, mimetype="application/json")
return Response(result, mimetype='application/json')
@routes.route("/infinera-fiberlink-info/<ne_name_str>/<object_name_str>",
......@@ -512,7 +521,7 @@ def get_fiberlink_trap_metadata(ne_name_str, object_name_str):
status=404,
mimetype="text/html")
return Response(result, mimetype="application/json")
return Response(result, mimetype='application/json')
@routes.route('/coriant-info/<equipment_name>/<path:entity_string>',
......@@ -575,4 +584,4 @@ def get_coriant_info(equipment_name, entity_string):
result = json.dumps(result).encode('utf-8')
r.set(cache_key, result)
return Response(result, mimetype="application/json")
return Response(result, mimetype='application/json')
......@@ -90,6 +90,8 @@ class InventoryTask(Task):
def snmp_refresh_peerings(self, hostname, community):
try:
peerings = list(snmp.get_peer_state_info(hostname, community))
for p in peerings:
p['community'] = community
except ConnectionError:
msg = f'error loading snmp peering data from {hostname}'
logger.exception(msg)
......
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