diff --git a/inventory_provider/app.py b/inventory_provider/app.py index 96316f2319e545c2e8094b08d024a72c4f0b69a8..689f2d3ef62f62b8b284e500e54f77cfe3dcd4bd 100644 --- a/inventory_provider/app.py +++ b/inventory_provider/app.py @@ -20,4 +20,5 @@ logging.basicConfig( app = inventory_provider.create_app() if __name__ == "__main__": - app.run(host="::", port="7777") + # app.run(host="::", port="7777") + app.run(host="::", port="7878") diff --git a/inventory_provider/routes/data.py b/inventory_provider/routes/data.py index d882cc4b309d228e0a294722fa6413cb7f763a2b..45309fef2ed604b9826d0f97c34743461684b413 100644 --- a/inventory_provider/routes/data.py +++ b/inventory_provider/routes/data.py @@ -83,3 +83,24 @@ def router_interfaces(hostname): return Response( json.dumps(interfaces), mimetype="application/json") + + +@routes.route("/debug-dump/<hostname>", methods=['GET', 'POST']) +@require_accepts_json +def debug_dump_router_info(hostname): + redis_config = current_app.config["INVENTORY_PROVIDER_CONFIG"]["redis"] + r = redis.StrictRedis( + host=redis_config["hostname"], + port=redis_config["port"]) + + info = dict([(k.decode('utf-8'), json.loads(v.decode('utf-8'))) + for k,v in r.hgetall(hostname).items()]) + if not info: + return Response( + response="no info found for router '%s'" % hostname, + status=404, + mimetype="text/html") + + return Response( + json.dumps(info), + mimetype="application/json")