From 2ae37e7845c6acfb03cd0dadf2225bfaf82dc8e6 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. --- cloud/openstack/os_server.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cloud/openstack/os_server.py b/cloud/openstack/os_server.py index 90cc7282d04..1fe1a7b65a3 100644 --- a/cloud/openstack/os_server.py +++ b/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)