Skip to content
Snippets Groups Projects
Commit e848bd3b authored by Release Webservice's avatar Release Webservice
Browse files

Finished release 0.4.

parents d736769c f9e04933
No related branches found
No related tags found
No related merge requests found
0.1: initial skeleton
0.2: use celery for task management
0.3: basic opsdb, alarmsdb coms & test api
\ No newline at end of file
0.3: basic opsdb, alarmsdb coms & test api
0.4: added some further sample resources
\ No newline at end of file
......@@ -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")
......@@ -50,3 +50,86 @@ def routers():
return Response(
json.dumps(list([k.decode("utf-8") for k in r.keys("*")])),
mimetype="application/json")
@routes.route("/interfaces/<hostname>", methods=['GET', 'POST'])
@require_accepts_json
def router_interfaces(hostname):
redis_config = current_app.config["INVENTORY_PROVIDER_CONFIG"]["redis"]
r = redis.StrictRedis(
host=redis_config["hostname"],
port=redis_config["port"])
ifc_data_string = r.hget(hostname, 'interfaces')
if not ifc_data_string:
return Response(
response="no available info for '%s'" % hostname,
status=404,
mimetype="text/html")
def _interfaces(s):
for ifc in json.loads(s):
if 'v4InterfaceName' in ifc:
yield ifc['v4InterfaceName']
if 'v6InterfaceName' in ifc:
yield ifc['v6InterfaceName']
interfaces = list(_interfaces(ifc_data_string.decode('utf-8')))
if not interfaces:
return Response(
response="no interfaces found for '%s'" % hostname,
status=404,
mimetype="text/html")
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")
@routes.route("/bgp/<hostname>", methods=['GET', 'POST'])
@require_accepts_json
def bgp_configs(hostname):
redis_config = current_app.config["INVENTORY_PROVIDER_CONFIG"]["redis"]
r = redis.StrictRedis(
host=redis_config["hostname"],
port=redis_config["port"])
bgp_data_string = r.hget(hostname, 'bgp')
if not bgp_data_string:
return Response(
response="no available bgp info for '%s'" % hostname,
status=404,
mimetype="text/html")
def _interfaces(s):
for ifc in json.loads(s):
yield {
"description": ifc["description"][0],
"as": {
"peer": ifc["peer-as"][0],
"local": ifc["local-as"][0]["as-number"][0]
}
}
interfaces = list(_interfaces(bgp_data_string.decode('utf-8')))
return Response(
json.dumps(interfaces),
mimetype="application/json")
......@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name='inventory-provider',
version="0.3",
version="0.4",
author='GEANT',
author_email='swd@geant.org',
description='Dashboard inventory provider',
......
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