Merge "Validate shutdown value of --block-device"
This commit is contained in:
commit
b154a4828b
novaclient
@ -464,6 +464,13 @@ class ShellTest(utils.TestCase):
|
||||
}},
|
||||
)
|
||||
|
||||
def test_boot_bdms_v2_invalid_shutdown_value(self):
|
||||
self.assertRaises(exceptions.CommandError, self.run_command,
|
||||
('boot --flavor 1 --image 1 --block-device '
|
||||
'id=fake-id,source=volume,dest=volume,device=vda,'
|
||||
'size=1,format=ext4,type=disk,shutdown=foobar '
|
||||
'some-server'))
|
||||
|
||||
def test_boot_metadata(self):
|
||||
self.run_command('boot --image 1 --flavor 1 --meta foo=bar=pants'
|
||||
' --meta spam=eggs some-server ')
|
||||
|
@ -126,6 +126,12 @@ def _parse_block_device_mapping_v2(args, image):
|
||||
# default for local block devices when not specified.
|
||||
if 'delete_on_termination' in bdm_dict:
|
||||
action = bdm_dict['delete_on_termination']
|
||||
if action not in ['remove', 'preserve']:
|
||||
raise exceptions.CommandError(
|
||||
_("The value of shutdown key of --block-device shall be "
|
||||
"either 'remove' or 'preserve' but it was '%(action)s'")
|
||||
% {'action': action})
|
||||
|
||||
bdm_dict['delete_on_termination'] = (action == 'remove')
|
||||
elif bdm_dict.get('destination_type') == 'local':
|
||||
bdm_dict['delete_on_termination'] = True
|
||||
|
Loading…
x
Reference in New Issue
Block a user