From 2dddfbe67ca162369ca0afe405c8c5ad5feeb0b8 Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Thu, 24 Mar 2016 08:45:00 -0400 Subject: [PATCH] Add shade version check to os_flavor_facts The range_search() API was added to the shade library in version 1.5.0 so let's check for that and let the user know they need to upgrade if they try to use it. --- .../modules/extras/cloud/openstack/os_flavor_facts.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ansible/modules/extras/cloud/openstack/os_flavor_facts.py b/lib/ansible/modules/extras/cloud/openstack/os_flavor_facts.py index 3795abd08d..05a3782be7 100644 --- a/lib/ansible/modules/extras/cloud/openstack/os_flavor_facts.py +++ b/lib/ansible/modules/extras/cloud/openstack/os_flavor_facts.py @@ -23,6 +23,9 @@ try: except ImportError: HAS_SHADE = False +from distutils.version import StrictVersion + + DOCUMENTATION = ''' --- module: os_flavor_facts @@ -200,6 +203,9 @@ def main(): if ram: filters['ram'] = ram if filters: + # Range search added in 1.5.0 + if StrictVersion(shade.__version__) < StrictVersion('1.5.0'): + module.fail_json(msg="Shade >= 1.5.0 needed for this functionality") flavors = cloud.range_search(flavors, filters) if limit is not None: