Merge "Fix "server create"command with --boot-from-volume"
This commit is contained in:
commit
0fb1cae1a8
@ -1602,6 +1602,12 @@ class CreateServer(command.ShowOne):
|
|||||||
]
|
]
|
||||||
elif parsed_args.boot_from_volume:
|
elif parsed_args.boot_from_volume:
|
||||||
# Tell nova to create a root volume from the image provided.
|
# Tell nova to create a root volume from the image provided.
|
||||||
|
if not image:
|
||||||
|
msg = _(
|
||||||
|
"An image (--image or --image-property) is required "
|
||||||
|
"to support --boot-from-volume option"
|
||||||
|
)
|
||||||
|
raise exceptions.CommandError(msg)
|
||||||
block_device_mapping_v2 = [
|
block_device_mapping_v2 = [
|
||||||
{
|
{
|
||||||
'uuid': image.id,
|
'uuid': image.id,
|
||||||
|
@ -3414,6 +3414,34 @@ class TestServerCreate(TestServer):
|
|||||||
'--volume is not allowed with --boot-from-volume', str(ex)
|
'--volume is not allowed with --boot-from-volume', str(ex)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_server_create_boot_from_volume_no_image(self):
|
||||||
|
# Test --boot-from-volume option without --image or
|
||||||
|
# --image-property.
|
||||||
|
arglist = [
|
||||||
|
'--flavor',
|
||||||
|
self.flavor.id,
|
||||||
|
'--boot-from-volume',
|
||||||
|
'1',
|
||||||
|
self.new_server.name,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('flavor', self.flavor.id),
|
||||||
|
('boot_from_volume', 1),
|
||||||
|
('config_drive', False),
|
||||||
|
('server_name', self.new_server.name),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
ex = self.assertRaises(
|
||||||
|
exceptions.CommandError, self.cmd.take_action, parsed_args
|
||||||
|
)
|
||||||
|
# Assert it is the error we expect.
|
||||||
|
self.assertIn(
|
||||||
|
'An image (--image or --image-property) is required '
|
||||||
|
'to support --boot-from-volume option',
|
||||||
|
str(ex),
|
||||||
|
)
|
||||||
|
|
||||||
def test_server_create_image_property(self):
|
def test_server_create_image_property(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--image-property',
|
'--image-property',
|
||||||
|
Loading…
Reference in New Issue
Block a user