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

use new redis schema for classifier routes

parent f8773eed
No related branches found
No related tags found
No related merge requests found
......@@ -27,28 +27,11 @@ def coriant_addresses():
@routes.route("/juniper-server-addresses", methods=['GET', 'POST'])
@common.require_accepts_json
def juniper_addresses():
backend_data_schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "array",
"items": {
"type": "object",
"properties": {
"ip_address": {"type": "string"}
},
"required": ["ip_address"]
}
}
servers = common.get_redis().get('alarmsdb:juniper_servers')
if not servers:
return Response(
response="no juniper server data found",
status=404,
mimetype="text/html")
servers = json.loads(servers.decode('utf-8'))
jsonschema.validate(servers, backend_data_schema)
return jsonify([s['ip_address'] for s in servers])
# TODO: definitive way of returning these addresses
# TODO: probably this (and corant, infinera routes) can be removed
routers = current_app.config[
"INVENTORY_PROVIDER_CONFIG"]["routers"]
return jsonify([r['hostname'] for r in routers])
@routes.route("/trap-metadata/<trap_type>/<source_equipment>/<path:interface>",
......@@ -64,8 +47,8 @@ def get_trap_metadata(trap_type, source_equipment, interface):
# This could be different calls dependant on vendor, in which case we may
# need to check the trap type, or it could be a case of a key check for
# each possible data source
interface_info = r.hget(interface_info_key,
"{}::{}".format(source_equipment, interface))
interface_info = r.get(
'opsdb:interface_services:%s:%s' % (source_equipment, interface))
if not interface_info:
return Response(
......
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