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

added '/classifier/juniper-server-addresses' resource

parent 2f2a8a3a
No related branches found
No related tags found
No related merge requests found
import functools
from flask import Blueprint, request, Response, current_app, jsonify
import json
import jsonschema
from inventory_provider import db
routes = Blueprint("inventory-data-classifier-support-routes", __name__)
......@@ -31,3 +35,29 @@ def infinera_addresses():
"INVENTORY_PROVIDER_CONFIG"]["infinera-dna"]
return jsonify([dna['address'] for dna in infinera_config])
@routes.route("/juniper-server-addresses", methods=['GET', 'POST'])
@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 = db.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])
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