diff --git a/cinderclient/tests/v1/test_shell.py b/cinderclient/tests/v1/test_shell.py index 014df945f..13c2a19e6 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 6f9a53fa2..4b7178a89 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 34b5353c4..b0a223e6d 100644 --- a/cinderclient/v1/shell.py +++ b/cinderclient/v1/shell.py @@ -317,6 +317,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) @@ -461,6 +466,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 f1e45c46d..bd4d54b0c 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -356,6 +356,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) @@ -522,6 +526,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)