diff --git a/cinderclient/tests/v1/test_shell.py b/cinderclient/tests/v1/test_shell.py index 0fc7bae07..a79c413bf 100644 --- a/cinderclient/tests/v1/test_shell.py +++ b/cinderclient/tests/v1/test_shell.py @@ -127,7 +127,7 @@ class ShellTest(utils.TestCase): 'status=available&volume_id=1234') def test_rename(self): - # basic rename with positional agruments + # basic rename with positional arguments self.run_command('rename 1234 new-name') expected = {'volume': {'display_name': 'new-name'}} self.assert_called('PUT', '/volumes/1234', body=expected) @@ -143,12 +143,12 @@ class ShellTest(utils.TestCase): 'display_description': 'new-description', }} self.assert_called('PUT', '/volumes/1234', body=expected) - # noop, the only all will be the lookup - self.run_command('rename 1234') - self.assert_called('GET', '/volumes/1234') + + # Call rename with no arguments + self.assertRaises(SystemExit, self.run_command, 'rename') def test_rename_snapshot(self): - # basic rename with positional agruments + # basic rename with positional arguments self.run_command('snapshot-rename 1234 new-name') expected = {'snapshot': {'display_name': 'new-name'}} self.assert_called('PUT', '/snapshots/1234', body=expected) @@ -165,9 +165,9 @@ class ShellTest(utils.TestCase): 'display_description': 'new-description', }} self.assert_called('PUT', '/snapshots/1234', body=expected) - # noop, the only all will be the lookup - self.run_command('snapshot-rename 1234') - self.assert_called('GET', '/snapshots/1234') + + # Call snapshot-rename with no arguments + self.assertRaises(SystemExit, self.run_command, 'snapshot-rename') def test_set_metadata_set(self): self.run_command('metadata 1234 set key1=val1 key2=val2') diff --git a/cinderclient/tests/v2/test_shell.py b/cinderclient/tests/v2/test_shell.py index 74437b5dc..f18e39d5c 100644 --- a/cinderclient/tests/v2/test_shell.py +++ b/cinderclient/tests/v2/test_shell.py @@ -105,7 +105,7 @@ class ShellTest(utils.TestCase): 'status=available&volume_id=1234') def test_rename(self): - # basic rename with positional agruments + # basic rename with positional arguments self.run_command('rename 1234 new-name') expected = {'volume': {'name': 'new-name'}} self.assert_called('PUT', '/volumes/1234', body=expected) @@ -121,12 +121,12 @@ class ShellTest(utils.TestCase): 'description': 'new-description', }} self.assert_called('PUT', '/volumes/1234', body=expected) - # noop, the only all will be the lookup - self.run_command('rename 1234') - self.assert_called('GET', '/volumes/1234') + + # Call rename with no arguments + self.assertRaises(SystemExit, self.run_command, 'rename') def test_rename_snapshot(self): - # basic rename with positional agruments + # basic rename with positional arguments self.run_command('snapshot-rename 1234 new-name') expected = {'snapshot': {'name': 'new-name'}} self.assert_called('PUT', '/snapshots/1234', body=expected) @@ -143,9 +143,9 @@ class ShellTest(utils.TestCase): 'description': 'new-description', }} self.assert_called('PUT', '/snapshots/1234', body=expected) - # noop, the only all will be the lookup - self.run_command('snapshot-rename 1234') - self.assert_called('GET', '/snapshots/1234') + + # Call snapshot-rename with no arguments + self.assertRaises(SystemExit, self.run_command, 'snapshot-rename') def test_set_metadata_set(self): self.run_command('metadata 1234 set key1=val1 key2=val2') diff --git a/cinderclient/v1/shell.py b/cinderclient/v1/shell.py index 2370560c9..b11782477 100644 --- a/cinderclient/v1/shell.py +++ b/cinderclient/v1/shell.py @@ -323,6 +323,11 @@ def do_rename(cs, args): kwargs['display_name'] = args.display_name if args.display_description is not None: kwargs['display_description'] = args.display_description + + if not any(kwargs): + msg = 'Must supply either display-name or display-description.' + raise exceptions.ClientException(code=1, message=msg) + utils.find_volume(cs, args.volume).update(**kwargs) @@ -467,6 +472,11 @@ def do_snapshot_rename(cs, args): kwargs['display_name'] = args.display_name if args.display_description is not None: kwargs['display_description'] = args.display_description + + if not any(kwargs): + msg = 'Must supply either display-name or display-description.' + raise exceptions.ClientException(code=1, message=msg) + _find_volume_snapshot(cs, args.snapshot).update(**kwargs) diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py index 7b1fa4cc5..18a6bbb70 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -362,6 +362,10 @@ def do_rename(cs, args): elif args.description is not None: kwargs['description'] = args.description + if not any(kwargs): + msg = 'Must supply either name or description.' + raise exceptions.ClientException(code=1, message=msg) + utils.find_volume(cs, args.volume).update(**kwargs) @@ -527,6 +531,10 @@ def do_snapshot_rename(cs, args): elif args.display_description is not None: kwargs['description'] = args.display_description + if not any(kwargs): + msg = 'Must supply either name or description.' + raise exceptions.ClientException(code=1, message=msg) + _find_volume_snapshot(cs, args.snapshot).update(**kwargs)