Fix queue stats for v1.1 and above versions

Now in the cli of queue status v1, it's using queue.exists() to
check the existance. However, the queue.exists isn't supported
in v1.1 and above. But the queue stats should be support for
all the versions. As a result, user will see errors like
'Unavailable on versions >= 1.1'. This patches fixes it.

Closes-Bug: #1534427

Change-Id: Iaf738af4eca2419c6eba0a410b1f7e45c9720f54
This commit is contained in:
Fei Long Wang
2016-01-15 16:52:07 +13:00
parent f933dc8131
commit 0103f39ff5

View File

@@ -20,6 +20,7 @@ from cliff import lister
from cliff import show
from openstackclient.common import utils
from zaqarclient.transport import errors
def _get_client(obj, parsed_args):
@@ -202,11 +203,13 @@ class GetQueueStats(show.ShowOne):
queue_name = parsed_args.queue_name
queue = client.queue(queue_name, auto_create=False)
if not queue.exists():
try:
stats = queue.stats
except errors.ResourceNotFound:
raise RuntimeError('Queue(%s) does not exist.' % queue_name)
columns = ("Stats",)
data = dict(stats=queue.stats)
data = dict(stats=stats)
return columns, utils.get_dict_properties(data, columns)