summaryrefslogtreecommitdiff
path: root/openstackclient/tests
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-12-05 12:59:46 +0000
committerGerrit Code Review <review@openstack.org>2022-12-05 12:59:46 +0000
commit8248efa8d9f264bdeb267d3eb666d87edf9b7574 (patch)
tree139a82c4c2d65177b5a93669fa95306a0cbbc3db /openstackclient/tests
parent5b42583cb194f6ca64c88d22d359babd49c20311 (diff)
parent91277e7e51849d197554b633a579c92116a5afc4 (diff)
downloadpython-openstackclient-8248efa8d9f264bdeb267d3eb666d87edf9b7574.tar.gz
Merge "compute: Allow users to manually specify bootable volumes"
Diffstat (limited to 'openstackclient/tests')
-rw-r--r--openstackclient/tests/unit/compute/v2/test_server.py44
1 files changed, 38 insertions, 6 deletions
diff --git a/openstackclient/tests/unit/compute/v2/test_server.py b/openstackclient/tests/unit/compute/v2/test_server.py
index bd7ea27c..d7e84ba3 100644
--- a/openstackclient/tests/unit/compute/v2/test_server.py
+++ b/openstackclient/tests/unit/compute/v2/test_server.py
@@ -2470,7 +2470,7 @@ class TestServerCreate(TestServer):
'admin_pass': None,
'block_device_mapping_v2': [{
'uuid': self.volume.id,
- 'boot_index': '0',
+ 'boot_index': 0,
'source_type': 'volume',
'destination_type': 'volume',
}],
@@ -2521,7 +2521,7 @@ class TestServerCreate(TestServer):
'admin_pass': None,
'block_device_mapping_v2': [{
'uuid': self.snapshot.id,
- 'boot_index': '0',
+ 'boot_index': 0,
'source_type': 'snapshot',
'destination_type': 'volume',
'delete_on_termination': False,
@@ -2544,20 +2544,20 @@ 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'
+ block_device = f'uuid={self.volume.id},source_type=volume,boot_index=0'
arglist = [
- '--image', 'image1',
'--flavor', self.flavor.id,
'--block-device', block_device,
self.new_server.name,
]
verifylist = [
- ('image', 'image1'),
+ ('image', None),
('flavor', self.flavor.id),
('block_devices', [
{
'uuid': self.volume.id,
'source_type': 'volume',
+ 'boot_index': '0',
},
]),
('server_name', self.new_server.name),
@@ -2584,6 +2584,7 @@ class TestServerCreate(TestServer):
'uuid': self.volume.id,
'source_type': 'volume',
'destination_type': 'volume',
+ 'boot_index': 0,
},
],
'nics': [],
@@ -2593,7 +2594,7 @@ class TestServerCreate(TestServer):
# ServerManager.create(name, image, flavor, **kwargs)
self.servers_mock.create.assert_called_with(
self.new_server.name,
- self.image,
+ None,
self.flavor,
**kwargs
)
@@ -3521,6 +3522,37 @@ class TestServerCreate(TestServer):
self.assertEqual(self.columns, columns)
self.assertEqual(self.datalist(), data)
+ def test_server_create_no_boot_device(self):
+ block_device = f'uuid={self.volume.id},source_type=volume,boot_index=1'
+ arglist = [
+ '--block-device', block_device,
+ '--flavor', self.flavor.id,
+ self.new_server.name,
+ ]
+ verifylist = [
+ ('image', None),
+ ('flavor', self.flavor.id),
+ ('block_devices', [
+ {
+ 'uuid': self.volume.id,
+ 'source_type': 'volume',
+ 'boot_index': '1',
+ },
+ ]),
+ ('server_name', self.new_server.name),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+ exc = self.assertRaises(
+ exceptions.CommandError,
+ self.cmd.take_action,
+ parsed_args,
+ )
+ self.assertIn(
+ 'An image (--image, --image-property) or bootable volume '
+ '(--volume, --snapshot, --block-device) is required',
+ str(exc),
+ )
+
def test_server_create_with_swap(self):
arglist = [
'--image', 'image1',