Quotas for instances, and floating ips.
-
class AbsoluteResource(name, flag=None)
Bases: nova.quota.BaseResource
Describe a non-reservable resource.
-
class BaseResource(name, flag=None)
Bases: object
Describe a single resource for quota checking.
-
default
Return the default value of the quota.
-
quota(driver, context, **kwargs)
Given a driver and context, obtain the quota for this
resource.
Parameters: |
- driver – A quota driver.
- context – The request context.
- project_id – The project to obtain the quota value for.
If not provided, it is taken from the
context. If it is given as None, no
project-specific quota will be searched
for.
- quota_class – The quota class corresponding to the
project, or for which the quota is to be
looked up. If not provided, it is taken
from the context. If it is given as None,
no quota class-specific quota will be
searched for. Note that the quota class
defaults to the value in the context,
which may not correspond to the project if
project_id is not the same as the one in
the context.
|
-
class CountableResource(name, count, flag=None)
Bases: nova.quota.AbsoluteResource
Describe a resource where the counts aren’t based solely on the
project ID.
-
class DbQuotaDriver
Bases: object
Driver to perform necessary checks to enforce quotas and obtain
quota information. The default driver utilizes the local
database.
-
commit(context, reservations, project_id=None)
Commit reservations.
Parameters: |
- context – The request context, for access checks.
- reservations – A list of the reservation UUIDs, as
returned by the reserve() method.
- project_id – Specify the project_id if current context
is admin and admin wants to impact on
common user’s tenant.
|
-
destroy_all_by_project(context, project_id)
Destroy all quotas, usages, and reservations associated with a
project.
Parameters: |
- context – The request context, for access checks.
- project_id – The ID of the project being deleted.
|
-
expire(context)
Expire reservations.
Explores all currently existing reservations and rolls back
any that have expired.
Parameters: | context – The request context, for access checks. |
-
get_by_class(context, quota_class, resource)
Get a specific quota by quota class.
-
get_by_project(context, project_id, resource)
Get a specific quota by project.
-
get_class_quotas(context, resources, quota_class, defaults=True)
Given a list of resources, retrieve the quotas for the given
quota class.
Parameters: |
- context – The request context, for access checks.
- resources – A dictionary of the registered resources.
- quota_class – The name of the quota class to return
quotas for.
- defaults – If True, the default value will be reported
if there is no specific value for the
resource.
|
-
get_defaults(context, resources)
Given a list of resources, retrieve the default quotas.
Parameters: |
- context – The request context, for access checks.
- resources – A dictionary of the registered resources.
|
-
get_project_quotas(context, resources, project_id, quota_class=None, defaults=True, usages=True)
Given a list of resources, retrieve the quotas for the given
project.
Parameters: |
- context – The request context, for access checks.
- resources – A dictionary of the registered resources.
- project_id – The ID of the project to return quotas for.
- quota_class – If project_id != context.project_id, the
quota class cannot be determined. This
parameter allows it to be specified. It
will be ignored if project_id ==
context.project_id.
- defaults – If True, the quota class value (or the
default value, if there is no value from the
quota class) will be reported if there is no
specific value for the resource.
- usages – If True, the current in_use and reserved counts
will also be returned.
|
-
limit_check(context, resources, values, project_id=None)
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.
- resources – A dictionary of the registered resources.
- values – A dictionary of the values to check against the
quota.
- project_id – Specify the project_id if current context
is admin and admin wants to impact on
common user’s tenant.
|
-
reserve(context, resources, deltas, expire=None, project_id=None)
Check quotas and reserve resources.
For counting quotas–those quotas for which there is a usage
synchronization function–this method checks quotas against
current usage and the desired deltas.
This method will raise a QuotaResourceUnknown exception if a
given resource is unknown or if it does not have a usage
synchronization function.
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 a
list of reservation UUIDs which were created.
Parameters: |
- context – The request context, for access checks.
- resources – A dictionary of the registered resources.
- deltas – A dictionary of the proposed delta changes.
- expire – An optional parameter specifying an expiration
time for the reservations. If it is a simple
number, it is interpreted as a number of
seconds and added to the current time; if it is
a datetime.timedelta object, it will also be
added to the current time. A datetime.datetime
object will be interpreted as the absolute
expiration time. If None is specified, the
default expiration time set by
–default-reservation-expire will be used (this
value will be treated as a number of seconds).
- project_id – Specify the project_id if current context
is admin and admin wants to impact on
common user’s tenant.
|
-
rollback(context, reservations, project_id=None)
Roll back reservations.
Parameters: |
- context – The request context, for access checks.
- reservations – A list of the reservation UUIDs, as
returned by the reserve() method.
- project_id – Specify the project_id if current context
is admin and admin wants to impact on
common user’s tenant.
|
-
usage_reset(context, resources)
Reset the usage records for a particular user on a list of
resources. This will force that user’s usage records to be
refreshed the next time a reservation is made.
Note: this does not affect the currently outstanding
reservations the user has; those reservations must be
committed or rolled back (or expired).
Parameters: |
- context – The request context, for access checks.
- resources – A list of the resource names for which the
usage must be reset.
|
-
class NoopQuotaDriver
Bases: object
Driver that turns quotas calls into no-ops and pretends that quotas
for all resources are unlimited. This can be used if you do not
wish to have any quota checking. For instance, with nova compute
cells, the parent cell should do quota checking, but the child cell
should not.
-
commit(context, reservations, project_id=None)
Commit reservations.
Parameters: |
- context – The request context, for access checks.
- reservations – A list of the reservation UUIDs, as
returned by the reserve() method.
- project_id – Specify the project_id if current context
is admin and admin wants to impact on
common user’s tenant.
|
-
destroy_all_by_project(context, project_id)
Destroy all quotas, usages, and reservations associated with a
project.
Parameters: |
- context – The request context, for access checks.
- project_id – The ID of the project being deleted.
|
-
expire(context)
Expire reservations.
Explores all currently existing reservations and rolls back
any that have expired.
Parameters: | context – The request context, for access checks. |
-
get_by_class(context, quota_class, resource)
Get a specific quota by quota class.
-
get_by_project(context, project_id, resource)
Get a specific quota by project.
-
get_class_quotas(context, resources, quota_class, defaults=True)
Given a list of resources, retrieve the quotas for the given
quota class.
Parameters: |
- context – The request context, for access checks.
- resources – A dictionary of the registered resources.
- quota_class – The name of the quota class to return
quotas for.
- defaults – If True, the default value will be reported
if there is no specific value for the
resource.
|
-
get_defaults(context, resources)
Given a list of resources, retrieve the default quotas.
Parameters: |
- context – The request context, for access checks.
- resources – A dictionary of the registered resources.
|
-
get_project_quotas(context, resources, project_id, quota_class=None, defaults=True, usages=True)
Given a list of resources, retrieve the quotas for the given
project.
Parameters: |
- context – The request context, for access checks.
- resources – A dictionary of the registered resources.
- project_id – The ID of the project to return quotas for.
- quota_class – If project_id != context.project_id, the
quota class cannot be determined. This
parameter allows it to be specified. It
will be ignored if project_id ==
context.project_id.
- defaults – If True, the quota class value (or the
default value, if there is no value from the
quota class) will be reported if there is no
specific value for the resource.
- usages – If True, the current in_use and reserved counts
will also be returned.
|
-
limit_check(context, resources, values, project_id=None)
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.
- resources – A dictionary of the registered resources.
- values – A dictionary of the values to check against the
quota.
- project_id – Specify the project_id if current context
is admin and admin wants to impact on
common user’s tenant.
|
-
reserve(context, resources, deltas, expire=None, project_id=None)
Check quotas and reserve resources.
For counting quotas–those quotas for which there is a usage
synchronization function–this method checks quotas against
current usage and the desired deltas.
This method will raise a QuotaResourceUnknown exception if a
given resource is unknown or if it does not have a usage
synchronization function.
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 a
list of reservation UUIDs which were created.
Parameters: |
- context – The request context, for access checks.
- resources – A dictionary of the registered resources.
- deltas – A dictionary of the proposed delta changes.
- expire – An optional parameter specifying an expiration
time for the reservations. If it is a simple
number, it is interpreted as a number of
seconds and added to the current time; if it is
a datetime.timedelta object, it will also be
added to the current time. A datetime.datetime
object will be interpreted as the absolute
expiration time. If None is specified, the
default expiration time set by
–default-reservation-expire will be used (this
value will be treated as a number of seconds).
- project_id – Specify the project_id if current context
is admin and admin wants to impact on
common user’s tenant.
|
-
rollback(context, reservations, project_id=None)
Roll back reservations.
Parameters: |
- context – The request context, for access checks.
- reservations – A list of the reservation UUIDs, as
returned by the reserve() method.
- project_id – Specify the project_id if current context
is admin and admin wants to impact on
common user’s tenant.
|
-
usage_reset(context, resources)
Reset the usage records for a particular user on a list of
resources. This will force that user’s usage records to be
refreshed the next time a reservation is made.
Note: this does not affect the currently outstanding
reservations the user has; those reservations must be
committed or rolled back (or expired).
Parameters: |
- context – The request context, for access checks.
- resources – A list of the resource names for which the
usage must be reset.
|
-
class QuotaEngine(quota_driver_class=None)
Bases: object
Represent the set of recognized quotas.
-
commit(context, reservations, project_id=None)
Commit reservations.
Parameters: |
- context – The request context, for access checks.
- reservations – A list of the reservation UUIDs, as
returned by the reserve() method.
- project_id – Specify the project_id if current context
is admin and admin wants to impact on
common user’s tenant.
|
-
count(context, resource, *args, **kwargs)
Count a resource.
For countable resources, invokes the count() function and
returns its result. Arguments following the context and
resource are passed directly to the count function declared by
the resource.
Parameters: |
- context – The request context, for access checks.
- resource – The name of the resource, as a string.
|
-
destroy_all_by_project(context, project_id)
Destroy all quotas, usages, and reservations associated with a
project.
Parameters: |
- context – The request context, for access checks.
- project_id – The ID of the project being deleted.
|
-
expire(context)
Expire reservations.
Explores all currently existing reservations and rolls back
any that have expired.
Parameters: | context – The request context, for access checks. |
-
get_by_class(context, quota_class, resource)
Get a specific quota by quota class.
-
get_by_project(context, project_id, resource)
Get a specific quota by project.
-
get_class_quotas(context, quota_class, defaults=True)
Retrieve the quotas for the given quota class.
Parameters: |
- context – The request context, for access checks.
- quota_class – The name of the quota class to return
quotas for.
- defaults – If True, the default value will be reported
if there is no specific value for the
resource.
|
-
get_defaults(context)
Retrieve the default quotas.
Parameters: | context – The request context, for access checks. |
-
get_project_quotas(context, project_id, quota_class=None, defaults=True, usages=True)
Retrieve the quotas for the given project.
Parameters: |
- context – The request context, for access checks.
- project_id – The ID of the project to return quotas for.
- quota_class – If project_id != context.project_id, the
quota class cannot be determined. This
parameter allows it to be specified.
- defaults – If True, the quota class value (or the
default value, if there is no value from the
quota class) will be reported if there is no
specific value for the resource.
- usages – If True, the current in_use and reserved counts
will also be returned.
|
-
limit_check(context, project_id=None, **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. The
values to check are given as keyword arguments, where the key
identifies the specific quota limit to check, and the value is
the proposed value.
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.
- project_id – Specify the project_id if current context
is admin and admin wants to impact on
common user’s tenant.
|
-
register_resource(resource)
Register a resource.
-
register_resources(resources)
Register a list of resources.
-
reserve(context, expire=None, project_id=None, **deltas)
Check quotas and reserve resources.
For counting quotas–those quotas for which there is a usage
synchronization function–this method checks quotas against
current usage and the desired deltas. The deltas are given as
keyword arguments, and current usage and other reservations
are factored into the quota check.
This method will raise a QuotaResourceUnknown exception if a
given resource is unknown or if it does not have a usage
synchronization function.
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 a
list of reservation UUIDs which were created.
Parameters: |
- context – The request context, for access checks.
- expire – An optional parameter specifying an expiration
time for the reservations. If it is a simple
number, it is interpreted as a number of
seconds and added to the current time; if it is
a datetime.timedelta object, it will also be
added to the current time. A datetime.datetime
object will be interpreted as the absolute
expiration time. If None is specified, the
default expiration time set by
–default-reservation-expire will be used (this
value will be treated as a number of seconds).
- project_id – Specify the project_id if current context
is admin and admin wants to impact on
common user’s tenant.
|
-
resources
-
rollback(context, reservations, project_id=None)
Roll back reservations.
Parameters: |
- context – The request context, for access checks.
- reservations – A list of the reservation UUIDs, as
returned by the reserve() method.
- project_id – Specify the project_id if current context
is admin and admin wants to impact on
common user’s tenant.
|
-
usage_reset(context, resources)
Reset the usage records for a particular user on a list of
resources. This will force that user’s usage records to be
refreshed the next time a reservation is made.
Note: this does not affect the currently outstanding
reservations the user has; those reservations must be
committed or rolled back (or expired).
Parameters: |
- context – The request context, for access checks.
- resources – A list of the resource names for which the
usage must be reset.
|
-
class ReservableResource(name, sync, flag=None)
Bases: nova.quota.BaseResource
Describe a reservable resource.