diff --git a/troveclient/tests/test_v1_shell.py b/troveclient/tests/test_v1_shell.py index 660b7890..58c9d4cb 100644 --- a/troveclient/tests/test_v1_shell.py +++ b/troveclient/tests/test_v1_shell.py @@ -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( diff --git a/troveclient/v1/shell.py b/troveclient/v1/shell.py index 712aa830..7fef8cbf 100644 --- a/troveclient/v1/shell.py +++ b/troveclient/v1/shell.py @@ -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