summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Waldon <bcwaldon@gmail.com>2012-07-04 15:24:08 -0700
committerBrian Waldon <bcwaldon@gmail.com>2012-07-04 15:24:08 -0700
commite7db533bc0222f912ec0405e101e3dafbd49ece3 (patch)
treeb0a4aa8a915d9e3592ce14edf4554f29771b1204
parent9aad246f0e97942bdfd58b755855af3b8453734a (diff)
downloadpython-glanceclient-e7db533bc0222f912ec0405e101e3dafbd49ece3.tar.gz
Expand v1 image-list filters
Add comparison filters for the v1 image-list command: --name, --status, --container-format, --disk-format. Related to bp glance-client-parity. Change-Id: I27377764ea5543a4bef593f0a731b09a914a9265
-rw-r--r--glanceclient/v1/shell.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/glanceclient/v1/shell.py b/glanceclient/v1/shell.py
index 68c11f3..4052b45 100644
--- a/glanceclient/v1/shell.py
+++ b/glanceclient/v1/shell.py
@@ -20,17 +20,24 @@ from glanceclient.common import utils
import glanceclient.v1.images
+@utils.arg('--name', metavar='<NAME>',
+ help='Filter images to those that have this name.')
+@utils.arg('--status', metavar='<STATUS>',
+ help='Filter images to those that have this status.')
+@utils.arg('--container-format', metavar='<CONTAINER_FORMAT>',
+ help='Filter images to those that have this container format.')
+@utils.arg('--disk-format', metavar='<DISK_FORMAT>',
+ help='Filter images to those that have this disk format.')
@utils.arg('--size-min', metavar='<SIZE>',
help='Filter images to those with a size greater than this.')
@utils.arg('--size-max', metavar='<SIZE>',
help='Filter images to those with a size less than this.')
def do_image_list(gc, args):
"""List images."""
- filters = [
- ('size_min', args.size_min),
- ('size_max', args.size_max),
- ]
- filters = dict(filter(lambda f: f[1] is not None, filters))
+ filter_keys = ['name', 'status', 'container_format', 'disk_format',
+ 'size_min', 'size_max']
+ filter_items = [(key, getattr(args, key)) for key in filter_keys]
+ filters = dict([item for item in filter_items if item[1] is not None])
images = gc.images.list(filters=filters)
columns = ['ID', 'Name', 'Disk Format', 'Container Format',
'Size', 'Status']