From 0e2f625dd724923904dbfbece0baa69e33dbcb22 Mon Sep 17 00:00:00 2001 From: Fei Long Wang Date: Sat, 23 Jan 2016 23:47:50 +1300 Subject: [PATCH] Fix wrong api version type The api version from openstack client is a string, not a number. So we need to convert it to the right type before comparing it with a version number. Closes-Bug: 1534378 Change-Id: I55f149b90028f89bb7ff0878a7450df981524026 --- zaqarclient/queues/cli.py | 5 +++++ zaqarclient/queues/v1/queues.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/zaqarclient/queues/cli.py b/zaqarclient/queues/cli.py index 914e5b5c..87273f6b 100644 --- a/zaqarclient/queues/cli.py +++ b/zaqarclient/queues/cli.py @@ -32,6 +32,11 @@ API_VERSIONS = { def make_client(instance): """Returns an queues service client.""" version = instance._api_version[API_NAME] + try: + version = int(version) + except ValueError: + version = float(version) + queues_client = utils.get_client_class( API_NAME, version, diff --git a/zaqarclient/queues/v1/queues.py b/zaqarclient/queues/v1/queues.py index 09891e7e..a45a1fe2 100644 --- a/zaqarclient/queues/v1/queues.py +++ b/zaqarclient/queues/v1/queues.py @@ -71,7 +71,7 @@ class Queue(object): right after it was called. """ req, trans = self.client._request_and_transport() - if force_create or float(self.client.api_version) < 1.1: + if force_create or self.client.api_version < 1.1: core.queue_create(trans, req, self._name) def metadata(self, new_meta=None, force_reload=False): @@ -95,7 +95,7 @@ class Queue(object): # NOTE(jeffrey4l): Ensure that metadata is cleared when the new_meta # is a empty dict. if new_meta is not None: - if float(self.client.api_version) < 1.1: + if self.client.api_version < 1.1: core.queue_set_metadata(trans, req, self._name, new_meta) else: core.queue_create(trans, req, self._name, metadata=new_meta)