summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/nova-manage6
-rw-r--r--nova/tests/test_nova_manage.py5
2 files changed, 10 insertions, 1 deletions
diff --git a/bin/nova-manage b/bin/nova-manage
index 176273c720..5f3582081c 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -225,13 +225,17 @@ class ProjectCommands(object):
def quota(self, project_id, key=None, value=None):
"""Set or display quotas for project"""
ctxt = context.get_admin_context()
- if key:
+ project_quota = QUOTAS.get_project_quotas(ctxt, project_id)
+ if key and key in project_quota:
if value.lower() == 'unlimited':
value = -1
try:
db.quota_update(ctxt, project_id, key, value)
except exception.ProjectQuotaNotFound:
db.quota_create(ctxt, project_id, key, value)
+ else:
+ print "error: Invalid key %s supplied for update" % key
+ sys.exit(2)
project_quota = QUOTAS.get_project_quotas(ctxt, project_id)
for key, value in project_quota.iteritems():
if value['limit'] < 0 or value['limit'] is None:
diff --git a/nova/tests/test_nova_manage.py b/nova/tests/test_nova_manage.py
index 537aee2870..ec5d452a5c 100644
--- a/nova/tests/test_nova_manage.py
+++ b/nova/tests/test_nova_manage.py
@@ -367,3 +367,8 @@ class ProjectCommandsTestCase(test.TestCase):
sys.stdout = sys.__stdout__
result = output.getvalue()
self.assertEquals(('volumes: unlimited' in result), True)
+
+ def test_quota_update_invalid_key(self):
+ self.assertRaises(SystemExit,
+ self.commands.quota, 'admin', 'volumes1', '10'
+ )