Example #1
0
def render_base(request, baseid):
    try:
        auth = Auth.objects.get(id=baseid)

        logging.debug("Displaying auth %s" , (auth))

        parent = auth

        while parent.base == None:
            parent = parent.parent
            logging.debug("Recurse auth %s" , (parent.id))

        logging.debug("final auth %s" , (auth.id))
        base = parent.base

        if utils.is_service(base):
            return render_service_auth(request, auth)

    except Auth.DoesNotExist:
        logging.info("Request to browse '%s' , \
            ID does not relate to a auth object." , baseid)

    _dict = {}
    _dict["error"] = "Error displaying the auth with id='%s' " % baseid
    resp = render_to_response('error.html', append_dict(_dict, request), \
                context_instance=RequestContext(request))
    resp.status_code = 404
    return resp
Example #2
0
def reportusage(base):
    from models import HostingContainer, DataService
    toreport = []

    if utils.is_container(base):
        toreport =  [base]

    if utils.is_service(base):
        container = HostingContainer.objects.get(dataservice=base)
        toreport =  [container,base]

    if utils.is_mfile(base):
        service   = DataService.objects.get(mfile=base)
        toreport =  [service.container,service,base]

    for ob in toreport:
        ob.reportnum += 1
        ob.save()
Example #3
0
def service_info():
    secret = request.form.get('secret', '') or request.args.get('secret', '')
    service_ = request.form.get('service', '') or request.args.get('service', '')

    if service_:
        if not is_service(service_):
            return jsonify(Error.INVALID_SERVICE)

        srv = Service.query.filter_by(public=service_).first()
        if not srv:
            return jsonify(Error.SERVICE_NOTFOUND)
        return jsonify({"service": srv.as_dict()})

    if secret:
        if not is_secret(secret):
            return jsonify(Error.INVALID_SECRET)

        srv = Service.query.filter_by(secret=secret).first()
        if not srv:
            return jsonify(Error.SERVICE_NOTFOUND)
        return jsonify({"service": srv.as_dict()})

    return jsonify(Error.ARGUMENT_MISSING('service'))
Example #4
0
def service_info():
    secret = request.form.get('secret', '') or request.args.get('secret', '')
    service_ = request.form.get('service', '') or request.args.get(
        'service', '')

    if service_:
        if not is_service(service_):
            return Error.INVALID_SERVICE

        srv = Service.query.filter_by(public=service_).first()
        if not srv:
            return Error.SERVICE_NOTFOUND
        return jsonify({"service": srv.as_dict()})

    if secret:
        if not is_secret(secret):
            return Error.INVALID_SECRET

        srv = Service.query.filter_by(secret=secret).first()
        if not srv:
            return Error.SERVICE_NOTFOUND
        return jsonify({"service": srv.as_dict()})

    return Error.ARGUMENT_MISSING('service')