From 14bc1360e05a8eeabe463426d9578131fce75c6f Mon Sep 17 00:00:00 2001 From: "zhu.boxiang" Date: Thu, 17 Dec 2020 11:03:11 +0800 Subject: Fix list resources when use limit and with-count When we use with-count query param, we will get the count of resources. While the _list function return two different result, one is just list, another is tuple with list and int. So we must to handle the items which return from _list function. Closes-bug: #1908474 Change-Id: If8e31a637cf098cca60d8a10e9835ef66a3e66bc --- cinderclient/base.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cinderclient/base.py b/cinderclient/base.py index 40ce381..60bd410 100644 --- a/cinderclient/base.py +++ b/cinderclient/base.py @@ -125,6 +125,12 @@ class Manager(common_base.HookableMixin): # till there is no more items. items = self._list(next, response_key, obj_class, None, limit, items) + # If we use '--with-count' to get the resource count, + # the _list function will return the tuple result with + # (resources, count). + # So here, we must check the items' type then to do return. + if isinstance(items, tuple): + items = items[0] if "count" in body: return common_base.ListWithMeta(items, resp), body['count'] else: -- cgit v1.2.1