summaryrefslogtreecommitdiff
path: root/openstackclient/compute
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/compute
parent5b42583cb194f6ca64c88d22d359babd49c20311 (diff)
parent91277e7e51849d197554b633a579c92116a5afc4 (diff)
downloadpython-openstackclient-8248efa8d9f264bdeb267d3eb666d87edf9b7574.tar.gz
Merge "compute: Allow users to manually specify bootable volumes"
Diffstat (limited to 'openstackclient/compute')
-rw-r--r--openstackclient/compute/v2/server.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py
index 5b97814b..7afacb3e 100644
--- a/openstackclient/compute/v2/server.py
+++ b/openstackclient/compute/v2/server.py
@@ -913,9 +913,7 @@ class CreateServer(command.ShowOne):
required=True,
help=_('Create server with this flavor (name or ID)'),
)
- disk_group = parser.add_mutually_exclusive_group(
- required=True,
- )
+ disk_group = parser.add_mutually_exclusive_group()
disk_group.add_argument(
'--image',
metavar='<image>',
@@ -1473,14 +1471,14 @@ class CreateServer(command.ShowOne):
if volume:
block_device_mapping_v2 = [{
'uuid': volume,
- 'boot_index': '0',
+ 'boot_index': 0,
'source_type': 'volume',
'destination_type': 'volume'
}]
elif snapshot:
block_device_mapping_v2 = [{
'uuid': snapshot,
- 'boot_index': '0',
+ 'boot_index': 0,
'source_type': 'snapshot',
'destination_type': 'volume',
'delete_on_termination': False
@@ -1489,7 +1487,7 @@ class CreateServer(command.ShowOne):
# Tell nova to create a root volume from the image provided.
block_device_mapping_v2 = [{
'uuid': image.id,
- 'boot_index': '0',
+ 'boot_index': 0,
'source_type': 'image',
'destination_type': 'volume',
'volume_size': parsed_args.boot_from_volume
@@ -1626,6 +1624,15 @@ class CreateServer(command.ShowOne):
block_device_mapping_v2.append(mapping)
+ if not image and not any(
+ [bdm.get('boot_index') == 0 for bdm in block_device_mapping_v2]
+ ):
+ msg = _(
+ 'An image (--image, --image-property) or bootable volume '
+ '(--volume, --snapshot, --block-device) is required'
+ )
+ raise exceptions.CommandError(msg)
+
nics = parsed_args.nics
if 'auto' in nics or 'none' in nics: