From 08b2752080d4a80cab2b7c7ca9549e77d63c49ca Mon Sep 17 00:00:00 2001 From: John Batty Date: Thu, 13 Nov 2014 13:26:20 +0000 Subject: [PATCH] Fix get_flavor_id() when flavor_ram is specified Without this fix, _get_flavor_id() fails to find a matching flavor if both: * the flavor_ram parameter is specified * the first flavor in the list does not match. The bug is simply that the module.fail_json() call lies within the loop iterating through the flavors. This call should only be made if the loop completes and no matching flavors have been found. --- cloud/openstack/nova_compute.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/openstack/nova_compute.py b/cloud/openstack/nova_compute.py index 97488ea2e61..2b21ef86610 100644 --- a/cloud/openstack/nova_compute.py +++ b/cloud/openstack/nova_compute.py @@ -405,7 +405,7 @@ def _get_flavor_id(module, nova): if (flavor.ram >= module.params['flavor_ram'] and (not module.params['flavor_include'] or module.params['flavor_include'] in flavor.name)): return flavor.id - module.fail_json(msg = "Error finding flavor with %sMB of RAM" % module.params['flavor_ram']) + module.fail_json(msg = "Error finding flavor with %sMB of RAM" % module.params['flavor_ram']) return module.params['flavor_id']