From 1abc140ed7fabff1120dc45527f664aeac0dc4f6 Mon Sep 17 00:00:00 2001 From: Vincent Untz Date: Wed, 23 Mar 2016 11:03:24 +0100 Subject: [PATCH 2/9] fence_compute: Keep compatibility with python-novaclient <= 2.26.0 --- fence/agents/compute/fence_compute.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/fence/agents/compute/fence_compute.py b/fence/agents/compute/fence_compute.py index f024aa5..07639cc 100644 --- a/fence/agents/compute/fence_compute.py +++ b/fence/agents/compute/fence_compute.py @@ -412,7 +412,12 @@ def main(): run_delay(options) try: - from novaclient import client as nova_client + from distutils.version import LooseVersion + except ImportError: + fail_usage("distutils not found or not accessible") + + try: + import novaclient except ImportError: fail_usage("nova not found or not accessible") @@ -433,8 +438,12 @@ def main(): elif options["--action"] in ["monitor", "status"]: sys.exit(0) - # The first argument is the Nova client version - nova = nova_client.Client('2.11', + if LooseVersion(novaclient.__version__) <= LooseVersion('2.26.0') : + api_version = '2' + else: + api_version = '2.11' + + nova = novaclient.client.Client(api_version, options["--username"], options["--password"], options["--tenant-name"], -- 2.9.0