Skip to content
Snippets Groups Projects
jobs.py 1.05 KiB
from flask import Blueprint, current_app, jsonify
from inventory_provider.tasks import worker
from inventory_provider.routes import common

routes = Blueprint("inventory-data-job-routes", __name__)


@routes.route("/update", methods=['GET', 'POST'])
@common.require_accepts_json
def update():
    job_ids = worker.launch_refresh_cache_all(
        current_app.config["INVENTORY_PROVIDER_CONFIG"])
    return jsonify(job_ids)


# TODO: remove this when alarmsdb is
# @routes.route("update-interface-statuses", methods=['GET', 'POST'])
# def update_interface_statuses():
#     worker.update_interface_statuses.delay()
#     return Response("OK")


@routes.route("reload-router-config/<equipment_name>", methods=['GET', 'POST'])
@common.require_accepts_json
def reload_router_config(equipment_name):
    result = worker.reload_router_config.delay(equipment_name)
    return jsonify([result.id])


@routes.route("check-task-status/<task_id>", methods=['GET', 'POST'])
@common.require_accepts_json
def check_task_status(task_id):
    return jsonify(worker.check_task_status(task_id))