summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Podoliaka <rpodolyaka@mirantis.com>2014-08-29 11:54:38 +0300
committerRoman Podoliaka <rpodolyaka@mirantis.com>2014-08-29 12:56:10 +0300
commit148fd1bb124fa80f70a8983242dc979a34acceab (patch)
tree7cd09295470e420273bf578be09dbb200589bb34
parent76d6148c51227100f00a22e8a622e6ae505c45d1 (diff)
downloadnova-148fd1bb124fa80f70a8983242dc979a34acceab.tar.gz
Fix NoopQuotasDriver.get_settable_quotas()
get_settable_quotas() always failed with KeyError. While this driver is not really useful, we still want it to be working. Closes-Bug: #1363014 Change-Id: Ia6986453338cee05f28ff081c6bb1279072c3d80
-rw-r--r--nova/quota.py2
-rw-r--r--nova/tests/test_quota.py15
2 files changed, 16 insertions, 1 deletions
diff --git a/nova/quota.py b/nova/quota.py
index b98282ecb1..a2d435647e 100644
--- a/nova/quota.py
+++ b/nova/quota.py
@@ -778,7 +778,7 @@ class NoopQuotaDriver(object):
"""
quotas = {}
for resource in resources.values():
- quotas[resource.name].update(minimum=0, maximum=-1)
+ quotas[resource.name] = {'minimum': 0, 'maximum': -1}
return quotas
def limit_check(self, context, resources, values, project_id=None,
diff --git a/nova/tests/test_quota.py b/nova/tests/test_quota.py
index b00ed7e9e1..063d979b94 100644
--- a/nova/tests/test_quota.py
+++ b/nova/tests/test_quota.py
@@ -2562,12 +2562,14 @@ class NoopQuotaDriverTestCase(test.TestCase):
self.expected_with_usages = {}
self.expected_without_usages = {}
self.expected_without_dict = {}
+ self.expected_settable_quotas = {}
for r in quota.QUOTAS._resources:
self.expected_with_usages[r] = dict(limit=-1,
in_use=-1,
reserved=-1)
self.expected_without_usages[r] = dict(limit=-1)
self.expected_without_dict[r] = -1
+ self.expected_settable_quotas[r] = dict(minimum=0, maximum=-1)
self.driver = quota.NoopQuotaDriver()
@@ -2631,3 +2633,16 @@ class NoopQuotaDriverTestCase(test.TestCase):
'fake_user',
usages=False)
self.assertEqual(self.expected_without_usages, result)
+
+ def test_get_settable_quotas_with_user(self):
+ result = self.driver.get_settable_quotas(None,
+ quota.QUOTAS._resources,
+ 'test_project',
+ 'fake_user')
+ self.assertEqual(self.expected_settable_quotas, result)
+
+ def test_get_settable_quotas_without_user(self):
+ result = self.driver.get_settable_quotas(None,
+ quota.QUOTAS._resources,
+ 'test_project')
+ self.assertEqual(self.expected_settable_quotas, result)