summaryrefslogtreecommitdiffstats
path: root/nova/quota.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-10-31 17:40:52 +0000
committerGerrit Code Review <review@openstack.org>2012-10-31 17:40:52 +0000
commit3ae5c861dc9e8c2fb2d46f83bfc475817626bf9c (patch)
tree2dc36f657c4f80daa991aaac43e983810e229d0f /nova/quota.py
parent3157a42744a58083278146279de52416f2d84a4a (diff)
parentdaf78cfb970af42242466c7edb082bdb7bbbb118 (diff)
downloadnova-3ae5c861dc9e8c2fb2d46f83bfc475817626bf9c.tar.gz
nova-3ae5c861dc9e8c2fb2d46f83bfc475817626bf9c.tar.xz
nova-3ae5c861dc9e8c2fb2d46f83bfc475817626bf9c.zip
Merge "Add call to reset quota usage"
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