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
This commit is contained in:
zhu.boxiang
2020-12-17 11:03:11 +08:00
parent d92f15a09e
commit 14bc1360e0

View File

@@ -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: