boot: error out if no images match the property from --image-with
We may fail to get a image when setting --image-with meta_key=meta_value. We should error out, rather than sending a request then waiting for the errors from the remote side. Change-Id: I54a645a533e39b069e50fdee6893f8b0cced494c Signed-off-by: Chen Hanxiao <chenhx@certusnet.com.cn>
This commit is contained in:
parent
6287384456
commit
852bd46805
|
@ -157,6 +157,11 @@ class ShellTest(utils.TestCase):
|
||||||
}},
|
}},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_boot_image_with_error_out_no_match(self):
|
||||||
|
cmd = ("boot --flavor 1"
|
||||||
|
" --image-with fake_key=fake_value some-server")
|
||||||
|
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
|
||||||
|
|
||||||
def test_boot_key(self):
|
def test_boot_key(self):
|
||||||
self.run_command('boot --flavor 1 --image %s --key-name 1 some-server'
|
self.run_command('boot --flavor 1 --image %s --key-name 1 some-server'
|
||||||
% FAKE_UUID_1)
|
% FAKE_UUID_1)
|
||||||
|
|
|
@ -409,6 +409,9 @@ def _boot(cs, args):
|
||||||
emit_duplicated_image_with_warning(images, args.image_with)
|
emit_duplicated_image_with_warning(images, args.image_with)
|
||||||
if images:
|
if images:
|
||||||
image = images[0]
|
image = images[0]
|
||||||
|
else:
|
||||||
|
raise exceptions.CommandError(_("No images match the property "
|
||||||
|
"expected by --image-with"))
|
||||||
|
|
||||||
min_count = 1
|
min_count = 1
|
||||||
max_count = 1
|
max_count = 1
|
||||||
|
|
Loading…
Reference in New Issue