From 2f11d96d49ea90de039162bc3062e980cccfb2c7 Mon Sep 17 00:00:00 2001 From: Victor Costan Date: Fri, 4 Sep 2015 20:46:26 -0400 Subject: [PATCH] os_server: nice error when flavor not found When we can't find the VM flavor that the user requests, this change replaces the non-descript stack trace with a clear error message. --- lib/ansible/modules/cloud/openstack/os_server.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ansible/modules/cloud/openstack/os_server.py b/lib/ansible/modules/cloud/openstack/os_server.py index ca70f4ab257..38a3b6f6462 100644 --- a/lib/ansible/modules/cloud/openstack/os_server.py +++ b/lib/ansible/modules/cloud/openstack/os_server.py @@ -287,8 +287,12 @@ def _create_server(module, cloud): if flavor: flavor_dict = cloud.get_flavor(flavor) + if not flavor_dict: + module.fail_json(msg="Could not find flavor %s" % flavor) else: flavor_dict = cloud.get_flavor_by_ram(flavor_ram, flavor_include) + if not flavor_dict: + module.fail_json(msg="Could not find any matching flavor") nics = _network_args(module, cloud)