diff --git a/README.md b/README.md index ec85814ea52d72c0a0494294db37caedb082087e..4c0efb8a76365491a6facab3c99902d7dd64f44a 100644 --- a/README.md +++ b/README.md @@ -116,9 +116,9 @@ configuration are beyond the scope of this document. The following resources can be requested from the webservice. -### synchronous resources +### resources -All responses are JSON formatted messages. +Any non-empty responses are JSON formatted messages. * `/data/version` @@ -158,3 +158,7 @@ All responses are JSON formatted messages. "items": {"type": "string"} } ``` + +* /jobs/update + + This resource updates the inventory network data. \ No newline at end of file diff --git a/inventory_provider/__init__.py b/inventory_provider/__init__.py index 44220ddd9943d057f324df3cb9ad80ff898b2c9e..3eb4592480884d54a4bde47e961fea4ec900c2e3 100644 --- a/inventory_provider/__init__.py +++ b/inventory_provider/__init__.py @@ -20,6 +20,9 @@ def create_app(): from inventory_provider import data_routes app.register_blueprint(data_routes.routes, url_prefix='/data') + from inventory_provider import job_routes + app.register_blueprint(job_routes.routes, url_prefix='/jobs') + if "SETTINGS_FILENAME" not in os.environ: assert False, \ "environment variable SETTINGS_FILENAME' must be defined" diff --git a/inventory_provider/data_routes.py b/inventory_provider/data_routes.py index 804cbcebed9fc9f1fd819658a2f3033ab7afd698..25518cdccac8e0cb7f7afe9506ba6f93668fde79 100644 --- a/inventory_provider/data_routes.py +++ b/inventory_provider/data_routes.py @@ -2,10 +2,9 @@ import functools import json from flask import Blueprint, request, Response, current_app -# render_template, url_for import redis -routes = Blueprint("python-utils-ui-routes", __name__) +routes = Blueprint("inventory-data-query-routes", __name__) VERSION = { "api": "0.1", @@ -43,7 +42,7 @@ def version(): @routes.route("/routers", methods=['GET', 'POST']) @require_accepts_json -def abc(): +def routers(): redis_config = current_app.config["INVENTORY_PROVIDER_CONFIG"]["redis"] r = redis.StrictRedis( host=redis_config["hostname"], diff --git a/inventory_provider/job_routes.py b/inventory_provider/job_routes.py new file mode 100644 index 0000000000000000000000000000000000000000..41f8b7a0b466574cad024aacae4ad007ed9e4bf5 --- /dev/null +++ b/inventory_provider/job_routes.py @@ -0,0 +1,12 @@ +from flask import Blueprint, Response, current_app + +from inventory_provider import router_details + +routes = Blueprint("inventory-data-job-routes", __name__) + + +@routes.route("/update", methods=['GET', 'POST']) +def update(): + router_details.update_network_details( + current_app.config["INVENTORY_PROVIDER_CONFIG"]) + return Response("OK")