Verify image exists when passed for server creation

If the image doesn't exist, we should fail and raise the error clearly. Fixes #18921
This commit is contained in:
Mike Perez 2016-12-22 22:27:38 +00:00
parent 1da6a67c50
commit 6d32dba3c3

View file

@ -447,6 +447,9 @@ def _create_server(module, cloud):
if not module.params['boot_volume']: if not module.params['boot_volume']:
image_id = cloud.get_image_id( image_id = cloud.get_image_id(
module.params['image'], module.params['image_exclude']) module.params['image'], module.params['image_exclude'])
if not image_id:
module.fail_json(msg="Could not find image %s" %
module.params['image'])
if flavor: if flavor:
flavor_dict = cloud.get_flavor(flavor) flavor_dict = cloud.get_flavor(flavor)