Throw correct error on creation of size 0
When trying to create an instance of size 0 an error is thrown stating that the size was not specified, this is not correct because I did specify it. The problem is that args.size evaluates to False because size is 0. This patch checks for size being zero instead and throws the correct error message. Change-Id: If00e83ccd919429dcfac7621dbbd9daa49f8b416
This commit is contained in:
parent
e8b4f6c15b
commit
ca9be53870
|
@ -274,6 +274,10 @@ class ShellTest(utils.TestCase):
|
|||
self.run_command('cluster-force-delete cls-1234')
|
||||
self.assert_called('DELETE', '/clusters/cls-1234')
|
||||
|
||||
def test_boot_fail_with_size_0(self):
|
||||
self.assertRaises(exceptions.ValidationError, self.run_command,
|
||||
'create test-member-1 1 --size 0 --volume_type lvm')
|
||||
|
||||
def test_boot(self):
|
||||
self.run_command('create test-member-1 1 --size 1 --volume_type lvm')
|
||||
self.assert_called_anytime(
|
||||
|
|
|
@ -521,7 +521,11 @@ def do_create(cs, args):
|
|||
"""Creates a new instance."""
|
||||
flavor_id = _find_flavor(cs, args.flavor).id
|
||||
volume = None
|
||||
if args.size:
|
||||
if args.size is not None and args.size <= 0:
|
||||
raise exceptions.ValidationError(
|
||||
"Volume size '%s' must be an integer and greater than 0."
|
||||
% args.size)
|
||||
elif args.size:
|
||||
volume = {"size": args.size,
|
||||
"type": args.volume_type}
|
||||
restore_point = None
|
||||
|
|
Loading…
Reference in New Issue