Fix the count error in zaqarclient

now count number didn't show in the result. Fix this bug.

Change-Id: I87788bf4b992e36119e8432d76ccaf66328cce42
This commit is contained in:
wanghao 2020-02-24 18:00:54 +08:00
parent 6e9a5b59fe
commit 4abbe7b451
2 changed files with 21 additions and 2 deletions

View File

@ -88,9 +88,10 @@ class ListQueues(command.Lister):
columns.extend(["Metadata_Dict", "Href"]) columns.extend(["Metadata_Dict", "Href"])
if parsed_args.with_count is not None and parsed_args.with_count: if parsed_args.with_count is not None and parsed_args.with_count:
kwargs["with_count"] = parsed_args.with_count kwargs["with_count"] = parsed_args.with_count
columns.extend(["Count"])
data = client.queues(**kwargs) data, count = client.queues(**kwargs)
if count:
print("Queues in total: %s" % count)
columns = tuple(columns) columns = tuple(columns)
return (columns, (utils.get_item_properties(s, columns) for s in data)) return (columns, (utils.get_item_properties(s, columns) for s in data))

View File

@ -56,6 +56,24 @@ class Client(client.Client):
""" """
return queues.Queue(self, ref, **kwargs) return queues.Queue(self, ref, **kwargs)
def queues(self, **params):
"""Gets a list of queues from the server
:returns: A list of queues
:rtype: `list`
"""
req, trans = self._request_and_transport()
queue_list = core.queue_list(trans, req, **params)
count = None
if params.get("with_count"):
count = queue_list.get("count", None)
return iterator._Iterator(self, queue_list, 'queues',
self.queues_module.create_object(self)),\
count
@decorators.version(min_version=2) @decorators.version(min_version=2)
def subscription(self, queue_name, **kwargs): def subscription(self, queue_name, **kwargs):
"""Returns a subscription instance """Returns a subscription instance