This Page

The quantum.db.quota_db Module

class quantum.db.quota_db.DbQuotaDriver

Bases: object

Driver to perform necessary checks to enforce quotas and obtain quota information. The default driver utilizes the local database.

static delete_tenant_quota(context, tenant_id)

Delete the quota entries for a given tenant_id.

Atfer deletion, this tenant will use default quota values in conf.

static get_all_quotas(context, resources)

Given a list of resources, retrieve the quotas for the all tenants.

Parameters:
  • context – The request context, for access checks.
  • resources – A dictionary of the registered resource keys.
Return quotas:

list of dict of tenant_id:, resourcekey1:

resourcekey2: ...

static get_tenant_quotas(context, resources, tenant_id)

Given a list of resources, retrieve the quotas for the given tenant.

Parameters:
  • context – The request context, for access checks.
  • resources – A dictionary of the registered resource keys.
  • tenant_id – The ID of the tenant to return quotas for.
Return dict:

from resource name to dict of name and limit

limit_check(context, tenant_id, resources, values)

Check simple quota limits.

For limits–those quotas for which there is no usage synchronization function–this method checks that a set of proposed values are permitted by the limit restriction.

This method will raise a QuotaResourceUnknown exception if a given resource is unknown or if it is not a simple limit resource.

If any of the proposed values is over the defined quota, an OverQuota exception will be raised with the sorted list of the resources which are too high. Otherwise, the method returns nothing.

Parameters:
  • context – The request context, for access checks.
  • tenant_id – The tenant_id to check the quota.
  • resources – A dictionary of the registered resources.
  • values – A dictionary of the values to check against the quota.
static update_quota_limit(context, tenant_id, resource, limit)
class quantum.db.quota_db.Quota(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, quantum.db.models_v2.HasId

Represent a single quota override for a tenant.

If there is no row for a given tenant id and resource, then the default for the quota class is used.

id
limit
resource
tenant_id