Moved quota headroom calculations into quota_reserve
Moved headroom calculations into quota_reserve and modified headroom calculations to take into account -ve quota limits (unlimited) on cores and ram. Updated test cases to generate OverQuota exceptions with new headroom parameter. Added new tests for 'unlimited' quotas to test_quota.py in QuotaIntegrationTestCase and DbQuotaDriverTestCase classes. Add Exception kwargs checking for OverQuota and QuotaError exceptions. Change-Id: I855b0cad495182c5c4ee42b2acf5eedd198557b5 Closes-Bug: #1224453 min_count ignored for instance create
This commit is contained in:
@@ -405,11 +405,22 @@ class DbQuotaDriver(object):
|
||||
# Check the quotas and construct a list of the resources that
|
||||
# would be put over limit by the desired values
|
||||
overs = [key for key, val in values.items()
|
||||
if (quotas[key] >= 0 and quotas[key] < val) or
|
||||
if quotas[key] >= 0 and quotas[key] < val or
|
||||
(user_quotas[key] >= 0 and user_quotas[key] < val)]
|
||||
if overs:
|
||||
headroom = {}
|
||||
# Check project_quotas:
|
||||
for key in quotas:
|
||||
if quotas[key] >= 0 and quotas[key] < val:
|
||||
headroom[key] = quotas[key]
|
||||
# Check user quotas:
|
||||
for key in user_quotas:
|
||||
if (user_quotas[key] >= 0 and user_quotas[key] < val and
|
||||
headroom.get(key) > user_quotas[key]):
|
||||
headroom[key] = user_quotas[key]
|
||||
|
||||
raise exception.OverQuota(overs=sorted(overs), quotas=quotas,
|
||||
usages={})
|
||||
usages={}, headroom=headroom)
|
||||
|
||||
def reserve(self, context, resources, deltas, expire=None,
|
||||
project_id=None, user_id=None):
|
||||
|
||||
Reference in New Issue
Block a user