def index(): """ main index page """ kvmdash.jinja_env.filters['formatage'] = format_ts_as_age c = get_storage_api(STORAGE_CLASS) stor = c() raw_hosts = stor.get_all_hosts() guests = stor.get_all_guests() hosts = calculate_host_resources(raw_hosts, guests) return render_template("index.html", title = 'kvmdash', now = int(time.time()), age_threshold = AGE_THRESHOLD_SEC, hosts = hosts, guests = guests)
def clientapi_host(hostname): """ client GET or PUT host data by hostname """ c = get_storage_api(STORAGE_CLASS) stor = c() if request.method == "GET": data = stor.get_host(hostname) if data is None: abort(404) return jsonify(data) # implicit 200 elif request.method == "PUT": if request.content_length > MAX_UPLOAD_LEN: abort(413) if not request.json or not "name" in request.json: abort(400) result = stor.store_host(hostname, request.json) if not result: abort(500) return jsonify(request.json), 201 abort(405) # method not allowed
def clientapi_host(hostname): """ client GET or PUT host data by hostname """ c = get_storage_api(STORAGE_CLASS) stor = c() if request.method == 'GET': data = stor.get_host(hostname) if data is None: abort(404) return jsonify(data) # implicit 200 elif request.method == 'PUT': if request.content_length > MAX_UPLOAD_LEN: abort(413) if not request.json or not 'name' in request.json: abort(400) result = stor.store_host(hostname, request.json) if not result: abort(500) return jsonify(request.json), 201 abort(405) # method not allowed