summaryrefslogtreecommitdiff
path: root/glanceclient/v2/shell.py
diff options
context:
space:
mode:
authorFlavio Percoco <flaper87@gmail.com>2015-01-27 14:20:27 +0100
committerFlavio Percoco <fpercoco@redhat.com>2015-01-29 10:37:55 +0000
commit93c9bc1fe0ae3f5c95395e7a883fdffcc79d7151 (patch)
tree144bd39ac84421b72484f204baeef6b3be45d64b /glanceclient/v2/shell.py
parent363b17085195e6f38c8b7cf3ac3398f5f3806305 (diff)
downloadpython-glanceclient-93c9bc1fe0ae3f5c95395e7a883fdffcc79d7151.tar.gz
Add a `--limit` parameter to list operations
In v2, we use the link header during paginations to know when there are more images available in the server that could be returned in the same request. This way, it's possible to iterate over the generator returned by list and consume the images in the server. However, it's currently not possible to tell glanceclient the exact number of images we want, which basically means that it'll *always* go through the whole list of images in the server unless the limit is implemented by the consumer. DocImpact Change-Id: I9f65a40d4eafda6320e5c7d94d03fcd1bbc93e33 Closes-bug: #1415035
Diffstat (limited to 'glanceclient/v2/shell.py')
-rw-r--r--glanceclient/v2/shell.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/glanceclient/v2/shell.py b/glanceclient/v2/shell.py
index 4da2d99..a49d291 100644
--- a/glanceclient/v2/shell.py
+++ b/glanceclient/v2/shell.py
@@ -107,6 +107,8 @@ def do_image_update(gc, args):
utils.print_image(image)
+@utils.arg('--limit', metavar='<LIMIT>', default=None, type=int,
+ help='Maximum number of images to get.')
@utils.arg('--page-size', metavar='<SIZE>', default=None, type=int,
help='Number of images to request in each paginated request.')
@utils.arg('--visibility', metavar='<VISIBILITY>',
@@ -135,6 +137,8 @@ def do_image_list(gc, args):
filters = dict([item for item in filter_items if item[1] is not None])
kwargs = {'filters': filters}
+ if args.limit is not None:
+ kwargs['limit'] = args.page_size
if args.page_size is not None:
kwargs['page_size'] = args.page_size