summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/compute
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2021-03-04 18:34:00 +0000
committerStephen Finucane <sfinucan@redhat.com>2021-03-05 12:44:52 +0000
commit7c1d6f769c4f0d2afe61410fefd8bc8f26a22980 (patch)
treea1fa4c2b0d7525266cefb906b57d14e6dd8315e8 /openstackclient/tests/unit/compute
parenta507fb50f8b98b026be88de41f1bac49bafe19bf (diff)
downloadpython-openstackclient-7c1d6f769c4f0d2afe61410fefd8bc8f26a22980.tar.gz
compute: Add functional tests for --block-device
This mostly reuses the existing tests for '--block-device-mapping', which can hopefully be removed at some point in the future. This highlights two issues with the implementation of this option. Firstly, the 'boot_index' parameter is not required so don't mandate it. Secondly, and more significantly, we were defaulting the destination type for the 'image' source type to 'local'. Nova only allows you to attach a single image to local mapping [1], which means this default would only make sense if you were expecting users to use the '--block-device' option exclusively and omit the '--image' option. This is the *less common* case so this is a bad default. Default instead to a destination type of 'volume' like everything else, and require users specifying '--block-device' alone to pass 'destination_type=local' explicitly. [1] https://github.com/openstack/nova/blob/c8a6f8d2e/nova/block_device.py#L193-L206 Change-Id: I1718be965f57c3bbdb8a14f3cfac967dd4c55b4d Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Diffstat (limited to 'openstackclient/tests/unit/compute')
-rw-r--r--openstackclient/tests/unit/compute/v2/test_server.py28
1 files changed, 6 insertions, 22 deletions
diff --git a/openstackclient/tests/unit/compute/v2/test_server.py b/openstackclient/tests/unit/compute/v2/test_server.py
index ced5d458..9666c5fd 100644
--- a/openstackclient/tests/unit/compute/v2/test_server.py
+++ b/openstackclient/tests/unit/compute/v2/test_server.py
@@ -2029,7 +2029,7 @@ class TestServerCreate(TestServer):
self.assertEqual(self.datalist(), data)
def test_server_create_with_block_device(self):
- block_device = f'uuid={self.volume.id},source_type=volume,boot_index=1'
+ block_device = f'uuid={self.volume.id},source_type=volume'
arglist = [
'--image', 'image1',
'--flavor', self.flavor.id,
@@ -2043,7 +2043,6 @@ class TestServerCreate(TestServer):
{
'uuid': self.volume.id,
'source_type': 'volume',
- 'boot_index': '1',
},
]),
('server_name', self.new_server.name),
@@ -2069,7 +2068,6 @@ class TestServerCreate(TestServer):
'uuid': self.volume.id,
'source_type': 'volume',
'destination_type': 'volume',
- 'boot_index': 1,
}],
'nics': [],
'scheduler_hints': {},
@@ -2171,20 +2169,6 @@ class TestServerCreate(TestServer):
self.assertEqual(self.columns, columns)
self.assertEqual(self.datalist(), data)
- def test_server_create_with_block_device_no_boot_index(self):
- block_device = \
- f'uuid={self.volume.name},source_type=volume'
- arglist = [
- '--image', 'image1',
- '--flavor', self.flavor.id,
- '--block-device', block_device,
- self.new_server.name,
- ]
- self.assertRaises(
- argparse.ArgumentTypeError,
- self.check_parser,
- self.cmd, arglist, [])
-
def test_server_create_with_block_device_invalid_boot_index(self):
block_device = \
f'uuid={self.volume.name},source_type=volume,boot_index=foo'
@@ -2201,7 +2185,7 @@ class TestServerCreate(TestServer):
self.assertIn('The boot_index key of --block-device ', str(ex))
def test_server_create_with_block_device_invalid_source_type(self):
- block_device = f'uuid={self.volume.name},source_type=foo,boot_index=1'
+ block_device = f'uuid={self.volume.name},source_type=foo'
arglist = [
'--image', 'image1',
'--flavor', self.flavor.id,
@@ -2216,7 +2200,7 @@ class TestServerCreate(TestServer):
def test_server_create_with_block_device_invalid_destination_type(self):
block_device = \
- f'uuid={self.volume.name},destination_type=foo,boot_index=1'
+ f'uuid={self.volume.name},destination_type=foo'
arglist = [
'--image', 'image1',
'--flavor', self.flavor.id,
@@ -2231,7 +2215,7 @@ class TestServerCreate(TestServer):
def test_server_create_with_block_device_invalid_shutdown(self):
block_device = \
- f'uuid={self.volume.name},delete_on_termination=foo,boot_index=1'
+ f'uuid={self.volume.name},delete_on_termination=foo'
arglist = [
'--image', 'image1',
'--flavor', self.flavor.id,
@@ -2250,7 +2234,7 @@ class TestServerCreate(TestServer):
'2.41')
block_device = \
- f'uuid={self.volume.name},tag=foo,boot_index=1'
+ f'uuid={self.volume.name},tag=foo'
arglist = [
'--image', 'image1',
'--flavor', self.flavor.id,
@@ -2269,7 +2253,7 @@ class TestServerCreate(TestServer):
self.app.client_manager.compute.api_version = api_versions.APIVersion(
'2.66')
- block_device = f'uuid={self.volume.name},volume_type=foo,boot_index=1'
+ block_device = f'uuid={self.volume.name},volume_type=foo'
arglist = [
'--image', 'image1',
'--flavor', self.flavor.id,