Skip to content

Commit

Permalink
Set the lower limit of api_version for volume_type
Browse files Browse the repository at this point in the history
In boot server API, the volume_type is supported by microversion 2.67.
Therefore, the lower limit of the volume_type should be added to the CLI
command, otherwise an exception will occur.

Co-Authored-By: Eric Xie <[email protected]>

Closes-Bug: #1829854
Change-Id: Ie909c16568b017ca0acc802194140da7bece76c5
(cherry picked from commit 7b9d300)
  • Loading branch information
1049965823 committed May 23, 2019
1 parent a787f27 commit ef842ca
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions novaclient/tests/unit/v2/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,34 @@ def test_boot_bdms_v2_invalid_shutdown_value(self):
'size=1,format=ext4,type=disk,shutdown=foobar '
'some-server' % FAKE_UUID_1))

def test_boot_from_volume_with_volume_type_latest_microversion(self):
self.run_command(
'boot --flavor 1 --block-device id=%s,source=image,dest=volume,'
'size=1,bootindex=0,shutdown=remove,tag=foo,volume_type=lvm '
'bfv-server' % FAKE_UUID_1, api_version='2.latest')
self.assert_called_anytime(
'POST', '/servers',
{'server': {
'flavorRef': '1',
'name': 'bfv-server',
'block_device_mapping_v2': [
{
'uuid': FAKE_UUID_1,
'source_type': 'image',
'destination_type': 'volume',
'volume_size': '1',
'delete_on_termination': True,
'tag': 'foo',
'boot_index': '0',
'volume_type': 'lvm'
},
],
'networks': 'auto',
'imageRef': '',
'min_count': 1,
'max_count': 1,
}})

def test_boot_from_volume_with_volume_type_old_microversion(self):
ex = self.assertRaises(
exceptions.CommandError, self.run_command,
Expand Down
2 changes: 1 addition & 1 deletion novaclient/v2/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def _parse_block_device_mapping_v2(cs, args, image):
'delete_on_termination': False}
bdm.append(bdm_dict)

supports_volume_type = cs.api_version == api_versions.APIVersion('2.67')
supports_volume_type = cs.api_version >= api_versions.APIVersion('2.67')

for device_spec in args.block_device:
spec_dict = _parse_device_spec(device_spec)
Expand Down

0 comments on commit ef842ca

Please sign in to comment.