Add pagination to v2 image-list

* Use a recursive generator function to iterate over the image
  container. The presence of next links are indicators to
  continue pagination while their value drives the location of
  the next page.
* A user can pass in --page-size on the command line, or page_size
  when using the controller directly, to control how many images
  are requested with each subsequent paginated request. Default page
  size is 20.
* Add a flag (strict_url_check) for the FakeAPI class to control
  whether it chops off query params when trying to match a request
  to a fixture.
* Related to bp glance-client-v2.

Change-Id: Ib98e912a7af0bb570b4fd738733edd9b837d1a12
This commit is contained in:
Brian Waldon
2012-07-14 03:06:03 +00:00
parent 95a7f9dffe
commit d88d8fc462
4 changed files with 65 additions and 9 deletions
+6 -1
View File
@@ -17,9 +17,14 @@ from glanceclient.common import utils
from glanceclient import exc
@utils.arg('--page-size', metavar='<SIZE>', default=None, type=int,
help='Number of images to request in each paginated request.')
def do_image_list(gc, args):
"""List images."""
images = gc.images.list()
kwargs = {}
if args.page_size is not None:
kwargs['page_size'] = args.page_size
images = gc.images.list(**kwargs)
columns = ['ID', 'Name']
utils.print_list(images, columns)