diff options
| author | Brian Lamar <brian.lamar@rackspace.com> | 2012-08-15 14:39:39 -0400 |
|---|---|---|
| committer | Brian Lamar <brian.lamar@rackspace.com> | 2012-08-15 14:50:11 -0400 |
| commit | d64876424e87b3a7f76a9bf4d29fdacbc5ad4bc4 (patch) | |
| tree | 18714adff091abc444654bdb9be16a4ce485d0d7 /glanceclient | |
| parent | a5b8165d7de5edd15a616e2ff97c1f8b72b53e8c (diff) | |
| download | python-glanceclient-0.4.2.tar.gz | |
Ensure v1 'limit' query parameter works correctly.0.4.2
The tests were present but were not asserting list results.
page_size was overriding the absolute limit so limits were
not working if they were less than the page_size.
Fixes bug 1037233
Change-Id: If102824212e3846bc65d3f7928cf7aa2e48aaa63
Diffstat (limited to 'glanceclient')
| -rw-r--r-- | glanceclient/v1/images.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/glanceclient/v1/images.py b/glanceclient/v1/images.py index a4b759a..b41b314 100644 --- a/glanceclient/v1/images.py +++ b/glanceclient/v1/images.py @@ -123,18 +123,20 @@ class ImageManager(base.Manager): structure of an image object :rtype: list of :class:`Image` """ - limit = kwargs.get('limit') + absolute_limit = kwargs.get('limit') def paginate(qp, seen=0): url = '/v1/images/detail?%s' % urllib.urlencode(qp) images = self._list(url, "images") for image in images: seen += 1 + if absolute_limit is not None and seen > absolute_limit: + return yield image page_size = qp.get('limit') if (page_size and len(images) == page_size and - (limit is None or 0 < seen < limit)): + (absolute_limit is None or 0 < seen < absolute_limit)): qp['marker'] = image.id for image in paginate(qp, seen): yield image |
