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.
This commit is contained in:
Victor Costan 2015-09-04 20:46:26 -04:00 committed by Matt Clay
parent df713192b4
commit 2f11d96d49

View file

@ -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)