Example #1
0
def grapher(request, graph_type, hostname):
    hostname = decrypt(uenc(hostname))
    fname = uenc(os.path.join(settings.RRD_PREFIX, hostname))
    if not os.path.isdir(fname):
        raise faults.ItemNotFound("No such instance")

    outfname = uenc(os.path.join(settings.GRAPH_PREFIX, hostname))
    draw_func = available_graph_types[graph_type]

    response = HttpResponse(draw_func(fname, outfname), status=200, content_type="image/png")
    response.override_serialization = True

    return response
Example #2
0
def grapher(request, graph_type, hostname):
    hostname = decrypt(uenc(hostname))
    fname = uenc(os.path.join(settings.RRD_PREFIX, hostname))
    if not os.path.isdir(fname):
        raise faults.ItemNotFound('No such instance')

    outfname = uenc(os.path.join(settings.GRAPH_PREFIX, hostname))
    draw_func = available_graph_types[graph_type]

    response = HttpResponse(draw_func(fname, outfname),
                            status=200,
                            content_type="image/png")
    response.override_serialization = True

    return response
Example #3
0
def grapher(request, graph_type, hostname):
    try:
        hostname = decrypt(smart_str(hostname))
    except (ValueError, TypeError):
        raise faults.BadRequest("Invalid encrypted virtual server name")
    fname = smart_str(os.path.join(settings.RRD_PREFIX, hostname))
    if not os.path.isdir(fname):
        raise faults.ItemNotFound('No such instance')

    outfname = smart_str(os.path.join(settings.GRAPH_PREFIX, hostname))
    draw_func = available_graph_types[graph_type]

    response = HttpResponse(draw_func(fname, outfname),
                            status=200, content_type="image/png")
    response.override_serialization = True

    return response