Update 'unlimited' quota value to '-1' in db

Updates quota value to -1 in db rather than None
if the user specify the quota limit as "unlimited".

Fixes bug 979087
Change-Id: I0ec412189ad9630c4a875655294c1e77886108f5
(cherry picked from commit 98f782f818)
This commit is contained in:
vijaya-erukala 2012-09-18 13:18:38 +05:30 committed by Vishvananda Ishaya
parent a6e9a9664b
commit 4802d1b5c3
2 changed files with 19 additions and 1 deletions

View File

@ -227,7 +227,7 @@ class ProjectCommands(object):
ctxt = context.get_admin_context()
if key:
if value.lower() == 'unlimited':
value = None
value = -1
try:
db.quota_update(ctxt, project_id, key, value)
except exception.ProjectQuotaNotFound:

View File

@ -349,3 +349,21 @@ class InstanceTypeCommandsTestCase(test.TestCase):
self.unset_key(self.instance_type_name, "k1")
self.unset_key(self.instance_type_name, "k3")
class ProjectCommandsTestCase(test.TestCase):
def setUp(self):
super(ProjectCommandsTestCase, self).setUp()
self.commands = nova_manage.ProjectCommands()
def test_quota(self):
output = StringIO.StringIO()
sys.stdout = output
self.commands.quota(project_id='admin',
key='volumes',
value='unlimited',
)
sys.stdout = sys.__stdout__
result = output.getvalue()
self.assertEquals(('volumes: unlimited' in result), True)