Example #1
0
def run_with_quotas(tenant_id, deltas, f):
    """ Quota wrapper """

    from reddwarf.quota.quota import QUOTAS as quota_engine
    reservations = quota_engine.reserve(tenant_id, **deltas)
    result = None
    try:
        result = f()
    except:
        quota_engine.rollback(reservations)
        raise
    else:
        quota_engine.commit(reservations)
    return result
Example #2
0
def run_with_quotas(tenant_id, deltas, f):
    """ Quota wrapper """

    from reddwarf.quota.quota import QUOTAS as quota_engine
    reservations = quota_engine.reserve(tenant_id, **deltas)
    result = None
    try:
        result = f()
    except:
        quota_engine.rollback(reservations)
        raise
    else:
        quota_engine.commit(reservations)
    return result
Example #3
0
    def index(self, req, tenant_id):
        """
        Return all absolute and rate limit information.
        """
        quotas = QUOTAS.get_all_quotas_by_tenant(tenant_id)
        abs_limits = dict((k, v['hard_limit']) for k, v in quotas.items())
        rate_limits = req.environ.get("reddwarf.limits", [])

        return wsgi.Result(views.LimitViews(abs_limits,
                                            rate_limits).data(), 200)
Example #4
0
 def show(self, req, tenant_id, id):
     """Return all quotas for this tenant."""
     LOG.info(_("req : '%s'\n\n") % req)
     LOG.info(_("Indexing quota info for tenant '%s'") % id)
     quotas = quota_engine.get_all_quotas_by_tenant(id)
     return wsgi.Result(views.QuotaView(quotas).data(), 200)