def refresh_rack_map(): service = request.args.get("service") rack = request.args.get("rack") # double check to make sure rack can provide the specific service rack_form = RackForm() if rack not in rack_form.all_services_dict[service]["clusters"]: log.error( "Someone try to hack the service [service: '{0}' on rack: '{1}'] provided by Rack Diagram. Just ignore it." .format(service, rack)) return redirect("/inventory/rack") myfetch = FetchClusterInfo(g.user.id) map_progress = myfetch.get_map_progress(service) map_progress.set_refresh_map() map_progress.set_send_http_request() result = { "result": "failure", "reason": { "status": "failure", "text": "Read DB Error" } } result_dict = myfetch.start_refresh_map(service, rack) if result_dict["result"]: result["result"] = "success" elif result_dict["fresh"]: result["reason"]["status"] = "success" result["reason"]["text"] = "Data is already newest" return json.dumps(result)
def rack_map_progress_status(): service = request.args.get("service") result = {"text": "", "value": 0, "next": ""} myfetch = FetchClusterInfo(g.user.id) map_progress = myfetch.get_map_progress(service) if map_progress: result = map_progress.get_status() #log.debug("progress status: {0}".format(result)) if result["next"] == "loading map": result["data"] = map_progress.get_data("map_data") return json.dumps(result)
def rack_map_progress_status(): service = request.args.get("service") result = {"text": "", "value": 0, "next": ""} myfetch = FetchClusterInfo(g.user.id) map_progress = myfetch.get_map_progress(service) if map_progress: result = map_progress.get_status() # log.debug("progress status: {0}".format(result)) if result["next"] == "loading map": result["data"] = map_progress.get_data("map_data") return json.dumps(result)
def gen_rack_map(): service = request.args.get("service") rack = request.args.get("rack") # double check to make sure rack can provide the specific service rack_form = RackForm() if rack not in rack_form.all_services_dict[service]["clusters"]: log.error("Someone try to hack the service [service: '{0}' on rack: '{1}'] provided by Rack Diagram. Just ignore it.".format(service, rack)) return redirect("/inventory/rack") myfetch = FetchClusterInfo(g.user.id) map_progress = myfetch.get_map_progress(service) map_progress.set_load_map() map_progress.set_send_http_request() result = {"result": "failure", "reason": {"status": "failure", "text": "Read DB Error"}} if myfetch.start_gen_map(service, rack): result["result"] = "success" return json.dumps(result)