Skip to content

Commit 0fb1cae

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Fix "server create"command with --boot-from-volume"
2 parents 98fbc56 + 89e5d67 commit 0fb1cae

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

openstackclient/compute/v2/server.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,6 +1602,12 @@ def _match_image(image_api, wanted_properties):
16021602
]
16031603
elif parsed_args.boot_from_volume:
16041604
# Tell nova to create a root volume from the image provided.
1605+
if not image:
1606+
msg = _(
1607+
"An image (--image or --image-property) is required "
1608+
"to support --boot-from-volume option"
1609+
)
1610+
raise exceptions.CommandError(msg)
16051611
block_device_mapping_v2 = [
16061612
{
16071613
'uuid': image.id,

openstackclient/tests/unit/compute/v2/test_server.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3414,6 +3414,34 @@ def test_server_create_volume_boot_from_volume_conflict(self):
34143414
'--volume is not allowed with --boot-from-volume', str(ex)
34153415
)
34163416

3417+
def test_server_create_boot_from_volume_no_image(self):
3418+
# Test --boot-from-volume option without --image or
3419+
# --image-property.
3420+
arglist = [
3421+
'--flavor',
3422+
self.flavor.id,
3423+
'--boot-from-volume',
3424+
'1',
3425+
self.new_server.name,
3426+
]
3427+
verifylist = [
3428+
('flavor', self.flavor.id),
3429+
('boot_from_volume', 1),
3430+
('config_drive', False),
3431+
('server_name', self.new_server.name),
3432+
]
3433+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
3434+
3435+
ex = self.assertRaises(
3436+
exceptions.CommandError, self.cmd.take_action, parsed_args
3437+
)
3438+
# Assert it is the error we expect.
3439+
self.assertIn(
3440+
'An image (--image or --image-property) is required '
3441+
'to support --boot-from-volume option',
3442+
str(ex),
3443+
)
3444+
34173445
def test_server_create_image_property(self):
34183446
arglist = [
34193447
'--image-property',

0 commit comments

Comments
 (0)