Take a look at this line: https://github.com/openstack/python-zaqarclient/blob/stable/liberty/zaqarclient/queues/v1/queues.py#L46
If self.client.api_version has string type, even if it has value "1", the condition will evaluate to True, which is wrong.
For example, when I run CLI command:
$ openstack queue stats my-lovely-queue --os-queues-api-version=1 --debug
self.client.api_version ends up having string type and the exception is wrongly raised:
(python-zaqarclient27)yell@yelly:~/Sync/Repos/python-zaqarclient$ openstack queue stats my-lovely-queue --os-queues-api-version=1 --debug
START with options: ['queue', 'stats', 'my-lovely-queue', '--os-queues-api-version=1', '--debug']
options: Namespace(access_token_endpoint='', auth_type='', auth_url='http://127.0.0.1:35357/v2.0', cacert='', client_id='', client_secret='***', cloud='', debug=True, default_domain='default', deferred_help=False, domain_id='', domain_name='', endpoint='', identity_provider='', identity_provider_url='', insecure=None, interface='', log_file=None, os_compute_api_version='', os_identity_api_version='', os_image_api_version='', os_network_api_version='', os_object_api_version='', os_project_id=None, os_project_name=None, os_queues_api_version='1', os_volume_api_version='', password='***', project_domain_id='', project_domain_name='', project_id='', project_name='admin', protocol='', region_name='', scope='', service_provider_endpoint='', timing=False, token='***', trust_id='', url='', user_domain_id='', user_domain_name='', user_id='', username='admin', verbose_level=3, verify=None)
defaults: {u'auth_type': 'password', u'compute_api_version': u'2', 'key': None, u'database_api_version': u'1.0', 'api_timeout': None, u'baremetal_api_version': u'1', 'cacert': None, u'image_api_use_tasks': False, u'floating_ip_source': u'neutron', u'orchestration_api_version': u'1', u'interface': None, u'network_api_version': u'2', u'image_format': u'qcow2', u'image_api_version': u'2', u'metering_api_version': u'2', 'verify': True, u'identity_api_version': u'2.0', u'volume_api_version': u'1', 'cert': None, u'secgroup_source': u'neutron', u'container_api_version': u'1', u'dns_api_version': u'2', u'object_store_api_version': u'1', u'disable_vendor_agent': {}}
cloud cfg: {'auth_type': 'password', u'compute_api_version': u'2', 'key': None, u'database_api_version': u'1.0', u'metering_api_version': u'2', u'network_api_version': u'2', u'image_format': u'qcow2', u'image_api_version': u'2', 'verify': True, u'dns_api_version': u'2', u'object_store_api_version': u'1', 'verbose_level': 3, 'region_name': '', 'api_timeout': None, u'baremetal_api_version': u'1', 'queues_api_version': '1', 'auth': {'username': 'admin', 'project_name': 'admin', 'password': '***', 'auth_url': 'http://127.0.0.1:35357/v2.0'}, 'default_domain': 'default', 'debug': True, u'image_api_use_tasks': False, u'floating_ip_source': u'neutron', u'orchestration_api_version': u'1', 'timing': False, 'cacert': None, 'deferred_help': False, u'identity_api_version': u'2.0', u'volume_api_version': u'1', 'cert': None, u'secgroup_source': u'neutron', u'container_api_version': u'1', u'interface': None, u'disable_vendor_agent': {}}
compute API version 2, cmd group openstack.compute.v2
network API version 2, cmd group openstack.network.v2
image API version 2, cmd group openstack.image.v2
volume API version 1, cmd group openstack.volume.v1
identity API version 2.0, cmd group openstack.identity.v2
object_store API version 1, cmd group openstack.object_store.v1
messaging API version 1, cmd group openstack.messaging.v1
command: queue stats -> zaqarclient.queues.v1.cli.GetQueueStats
Auth plugin password selected
auth_type: password
Using auth plugin: password
Using parameters {'username': 'admin', 'password': '***', 'project_name': 'admin', 'auth_url': 'http://127.0.0.1:35357/v2.0'}
Get auth_ref
REQ: curl -g -i -X GET http://127.0.0.1:35357/v2.0 -H "Accept: application/json" -H "User-Agent: python-openstackclient"
Starting new HTTP connection (1): 127.0.0.1
"GET /v2.0 HTTP/1.1" 200 336
RESP: [200] Content-Length: 336 Vary: X-Auth-Token Connection: keep-alive Date: Thu, 14 Jan 2016 23:25:21 GMT Content-Type: application/json X-Openstack-Request-Id: req-f5f06b65-97d9-458e-9540-38bc86201a8e
RESP BODY: {"version": {"status": "stable", "updated": "2014-04-17T00:00:00Z", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v2.0+json"}], "id": "v2.0", "links": [{"href": "http://127.0.0.1:35357/v2.0/", "rel": "self"}, {"href": "http://docs.openstack.org/", "type": "text/html", "rel": "describedby"}]}}
Making authentication request to http://127.0.0.1:35357/v2.0/tokens
"POST /v2.0/tokens HTTP/1.1" 200 3342
take_action(Namespace(columns=[], formatter='table', max_width=0, noindent=False, prefix='', queue_name='my-lovely-queue', variables=[]))
Making authentication request to http://127.0.0.1:35357/v2.0/tokens
"POST /v2.0/tokens HTTP/1.1" 200 3342
Instantiating queues service client: <class 'zaqarclient.queues.v1.client.Client'>
Unavailable on versions >= 1.1
Traceback (most recent call last):
File "/home/yell/Python/envs/python-zaqarclient27/local/lib/python2.7/site-packages/cliff/app.py", line 374, in run_subcommand
result = cmd.run(parsed_args)
File "/home/yell/Python/envs/python-zaqarclient27/local/lib/python2.7/site-packages/cliff/display.py", line 92, in run
column_names, data = self.take_action(parsed_args)
File "/home/yell/Sync/Repos/python-zaqarclient/zaqarclient/queues/v1/cli.py", line 205, in take_action
if not queue.exists():
File "/home/yell/Sync/Repos/python-zaqarclient/zaqarclient/queues/v1/queues.py", line 60, in exists
raise errors.InvalidOperation("Unavailable on versions >= 1.1")
InvalidOperation: Unavailable on versions >= 1.1
clean_up GetQueueStats: Unavailable on versions >= 1.1
Traceback (most recent call last):
File "/home/yell/Python/envs/python-zaqarclient27/local/lib/python2.7/site-packages/openstackclient/shell.py", line 113, in run
ret_val = super(OpenStackShell, self).run(argv)
File "/home/yell/Python/envs/python-zaqarclient27/local/lib/python2.7/site-packages/cliff/app.py", line 255, in run
result = self.run_subcommand(remainder)
File "/home/yell/Python/envs/python-zaqarclient27/local/lib/python2.7/site-packages/cliff/app.py", line 374, in run_subcommand
result = cmd.run(parsed_args)
File "/home/yell/Python/envs/python-zaqarclient27/local/lib/python2.7/site-packages/cliff/display.py", line 92, in run
column_names, data = self.take_action(parsed_args)
File "/home/yell/Sync/Repos/python-zaqarclient/zaqarclient/queues/v1/cli.py", line 205, in take_action
if not queue.exists():
File "/home/yell/Sync/Repos/python-zaqarclient/zaqarclient/queues/v1/queues.py", line 60, in exists
raise errors.InvalidOperation("Unavailable on versions >= 1.1")
InvalidOperation: Unavailable on versions >= 1.1
END return value: 1
(python-zaqarclient27)yell@yelly:~/Sync/Repos/python-zaqarclient$
There are many places in the code like this. Either we fix them all by explicitly converting api_version to float or do such conversion on upper levels.
Fix proposed to branch: master /review. openstack. org/267906
Review: https:/