Exemple #1
0
    def show(self, req, tenant_id, id):
        """Return all quotas for this tenant."""
        LOG.info(_("Indexing quota info for tenant '%(id)s'\n"
                   "req : '%(req)s'\n\n") % {
                       "id": id, "req": req})

        quotas = quota_engine.get_all_quotas_by_tenant(id)
        return wsgi.Result(views.QuotaView(quotas).data(), 200)
Exemple #2
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("trove.limits", [])

        return wsgi.Result(views.LimitViews(abs_limits,
                                            rate_limits).data(), 200)
Exemple #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 = {k: v['hard_limit'] for k, v in quotas.items()}
        rate_limits = req.environ.get("trove.limits", [])

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

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

        usages = quota_engine.get_all_quota_usages_by_tenant(id)
        limits = quota_engine.get_all_quotas_by_tenant(id)
        map(lambda r: setattr(usages[r], "limit", limits[r].hard_limit),
            usages.keys())
        return wsgi.Result(views.QuotaUsageView(usages).data(), 200)
Exemple #6
0
    def index(self, req, tenant_id):
        """
        Return all absolute and rate limit information.
        """
        context = req.environ[wsgi.CONTEXT_KEY]
        policy.authorize_on_tenant(context, 'limits:index')
        quotas = QUOTAS.get_all_quotas_by_tenant(tenant_id)
        abs_limits = {k: v['hard_limit'] for k, v in quotas.items()}
        rate_limits = req.environ.get("trove.limits", [])

        return wsgi.Result(views.LimitViews(abs_limits,
                                            rate_limits).data(), 200)
Exemple #7
0
    def show(self, req, tenant_id, id):
        """Return all quotas for this tenant."""
        LOG.info(
            _("Indexing quota info for tenant '%(id)s'\n"
              "req : '%(req)s'\n\n"), {
                  "id": id,
                  "req": req
              })

        usages = quota_engine.get_all_quota_usages_by_tenant(id)
        limits = quota_engine.get_all_quotas_by_tenant(id)
        map(lambda r: setattr(usages[r], "limit", limits[r].hard_limit),
            usages.keys())
        return wsgi.Result(views.QuotaUsageView(usages).data(), 200)
Exemple #8
0
    def show(self, req, tenant_id, id):
        """Return all quotas for this tenant.

        Regular tenant can get his own resource quota.
        Admin user can get quota for any tenant.
        """
        LOG.info(
            "Indexing quota info for tenant '%(id)s'\n"
            "req : '%(req)s'\n\n", {
                "id": id,
                "req": req
            })

        context = req.environ[wsgi.CONTEXT_KEY]
        if id != tenant_id and not context.is_admin:
            raise exception.TroveOperationAuthError(tenant_id=tenant_id)

        usages = quota_engine.get_all_quota_usages_by_tenant(id)
        limits = quota_engine.get_all_quotas_by_tenant(id)
        for key in usages.keys():
            setattr(usages[key], "limit", limits[key].hard_limit)
        return wsgi.Result(views.QuotaUsageView(usages).data(), 200)
Exemple #9
0
 def publish_quota_notifications(self, context):
     nova_client = remote.create_nova_client(self.admin_context)
     for tenant in nova_client.tenants.list():
         for quota in QUOTAS.get_all_quotas_by_tenant(tenant.id):
             usage = QUOTAS.get_quota_usage(quota)
             DBaaSQuotas(self.admin_context, quota, usage).notify()
 def publish_quota_notifications(self, context):
     nova_client = remote.create_nova_client(self.admin_context)
     for tenant in nova_client.tenants.list():
         for quota in QUOTAS.get_all_quotas_by_tenant(tenant.id):
             usage = QUOTAS.get_quota_usage(quota)
             DBaaSQuotas(self.admin_context, quota, usage).notify()