Error if arguments are not supplied for rename commands
This changes behavior from: $ cinder rename volume1 $ to $ cinder rename volume1 ERROR: Must supply either display-name or display-description. for both 'rename' and 'snapshot-rename'. Change-Id: I675a3b1428a7fe10653394c80e4a5a473e14c740
This commit is contained in:
@@ -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')
|
||||
|
@@ -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')
|
||||
|
@@ -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)
|
||||
|
||||
|
||||
|
@@ -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)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user