Esempio n. 1
0
def get_region_status_health(region, period):
    health_client = client.get_client("health")
    api_endpoint = "/api/v1/region/{region}/health/{period}".format(
        region=region, period=period)

    result, code = health_client.get(api_endpoint)
    return (flask.jsonify(result), code)
Esempio n. 2
0
def get_regions(detailed):
    regions = {}

    for service_name in CONF["services"].keys():
        if service_name == "infra":
            continue  # TODO(boris-42): This should not be checked here.
        service_client = client.get_client(service_name)

        resp, code = service_client.get("/api/v1/regions")
        if code != 200:
            # FIXME ADD LOGS HERE
            continue
        for r in resp:
            regions.setdefault(r, {"services": []})
            regions[r]["services"].append(service_name)

    if not detailed:
        return flask.jsonify({"regions": list(regions.keys())})
    return flask.jsonify({"regions": regions})
Esempio n. 3
0
def get_status_helper(period, region=None):
    result = {}
    key_map = {
        "health": {
            "key": "health",
            "arg": "fci"
        },
        "availability": {
            "key": "availability",
            "arg": "availability"
        }
    }

    for service_name in ["health", "availability"]:
        if service_name not in CONF["services"]:
            continue

        service_client = client.get_client(service_name)

        if region:
            uri = "/api/v1/region/%s/%s/%s" % (region, service_name, period)
        else:
            uri = "/api/v1/%s/%s" % (service_name, period)

        resp, code = service_client.get(uri)
        if code != 200:
            # FIXME ADD LOGS HERE
            continue

        for r, value in resp[key_map[service_name]["key"]].items():
            result.setdefault(
                r, {
                    "sla": None,
                    "availability": None,
                    "health": None,
                    "performance": None
                })

            result[r][service_name] = value[key_map[service_name]["arg"]]
    return {"period": period, "status": result}
Esempio n. 4
0
def get_status_availability(period):
    ct = client.get_client("availability")
    api_endpoint = "/api/v1/availability/{period}".format(period=period)
    resp, code = ct.get(api_endpoint)
    return flask.jsonify(resp), code
Esempio n. 5
0
def get_status_health(period):
    health_client = client.get_client("health")
    api_endpoint = "/api/v1/health/{}".format(period)

    result, code = health_client.get(api_endpoint)
    return flask.jsonify(result), code
Esempio n. 6
0
def get_issues_all_regions(period):
    c = client.get_client("security")
    body, status = c.get("/api/v1/security/issues/%s" % period)
    return flask.jsonify(body), status
Esempio n. 7
0
def get_issues(region, period):
    c = client.get_client("security")
    body, status = c.get("/api/v1/region/%s/security/issues/%s" %
                         (region, period))
    return flask.jsonify(body), status