summaryrefslogtreecommitdiffstats
path: root/nova/quota.py
diff options
context:
space:
mode:
Diffstat (limited to 'nova/quota.py')
-rw-r--r--nova/quota.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/nova/quota.py b/nova/quota.py
index d3ba0aa02..fa0b813de 100644
--- a/nova/quota.py
+++ b/nova/quota.py
@@ -357,6 +357,35 @@ class DbQuotaDriver(object):
db.reservation_rollback(context, reservations)
+ def usage_reset(self, 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).
+
+ :param context: The request context, for access checks.
+ :param resources: A list of the resource names for which the
+ usage must be reset.
+ """
+
+ # We need an elevated context for the calls to
+ # quota_usage_update()
+ elevated = context.elevated()
+
+ for resource in resources:
+ try:
+ # Reset the usage to -1, which will force it to be
+ # refreshed
+ db.quota_usage_update(elevated, context.project_id,
+ resource, in_use=-1)
+ except exception.QuotaUsageNotFound:
+ # That means it'll be refreshed anyway
+ pass
+
def destroy_all_by_project(self, context, project_id):
"""
Destroy all quotas, usages, and reservations associated with a
@@ -734,6 +763,23 @@ class QuotaEngine(object):
LOG.exception(_("Failed to roll back reservations "
"%(reservations)s") % locals())
+ def usage_reset(self, 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).
+
+ :param context: The request context, for access checks.
+ :param resources: A list of the resource names for which the
+ usage must be reset.
+ """
+
+ self._driver.usage_reset(context, resources)
+
def destroy_all_by_project(self, context, project_id):
"""
Destroy all quotas, usages, and reservations associated with a