diff --git a/cinderclient/tests/unit/v2/test_shell.py b/cinderclient/tests/unit/v2/test_shell.py index 07f44eb..0e2421a 100644 --- a/cinderclient/tests/unit/v2/test_shell.py +++ b/cinderclient/tests/unit/v2/test_shell.py @@ -334,6 +334,13 @@ class ShellTest(utils.TestCase): def test_create_size_required_if_not_snapshot_or_clone(self): self.assertRaises(SystemExit, self.run_command, 'create') + def test_create_size_zero_if_not_snapshot_or_clone(self): + expected = {'volume': {'status': 'creating', + 'size': 0}} + self.run_command('create 0') + self.assert_called_anytime('POST', '/volumes', partial_body=expected) + self.assert_called('GET', '/volumes/1234') + def test_show(self): self.run_command('show 1234') self.assert_called('GET', '/volumes/1234') diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py index 3c13636..463f43d 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -261,8 +261,8 @@ def do_show(cs, args): class CheckSizeArgForCreate(argparse.Action): def __call__(self, parser, args, values, option_string=None): - if (values or args.snapshot_id or args.source_volid - or args.source_replica) is None: + if ((args.snapshot_id or args.source_volid or args.source_replica) + is None and values is None): parser.error('Size is a required parameter if snapshot ' 'or source volume is not specified.') setattr(args, self.dest, values)