Add validation to --property-filter in v1 shell
Previously, using --property-filter with invalid arguments resulted in
a rather cryptic error message:
$ glance image-list --property-filter name
dictionary update sequence element #0 has length 1; 2 is required
Now, something which is human decipherable is printed:
$ glance image-list --property-filter name
Argument --property-filter requires properties in the format KEY=VALUE
Change-Id: I61d19894fd8864bdca2fa3f627da3c7eb1341c51
This commit is contained in:
@@ -80,6 +80,10 @@ def do_image_list(gc, args):
|
|||||||
|
|
||||||
if args.properties:
|
if args.properties:
|
||||||
property_filter_items = [p.split('=', 1) for p in args.properties]
|
property_filter_items = [p.split('=', 1) for p in args.properties]
|
||||||
|
if any(len(pair) != 2 for pair in property_filter_items):
|
||||||
|
utils.exit('Argument --property-filter requires properties in the'
|
||||||
|
' format KEY=VALUE')
|
||||||
|
|
||||||
filters['properties'] = dict(property_filter_items)
|
filters['properties'] = dict(property_filter_items)
|
||||||
|
|
||||||
kwargs = {'filters': filters}
|
kwargs = {'filters': filters}
|
||||||
|
|||||||
Reference in New Issue
Block a user