From 21e4c87bdeb78ef5c5a251ae9e671efd1b5e3102 Mon Sep 17 00:00:00 2001 From: Sven Wegener Date: Fri, 12 Jan 2018 14:19:11 +0100 Subject: [PATCH] image/v2: support multiple property filters Change-Id: I8ba40cb8ca647ec24b80c2824bb64e84430535d4 Signed-off-by: Sven Wegener --- openstackclient/image/v2/image.py | 18 +++++++++--------- ...r-multiple-properties-03c51d43131ee3b6.yaml | 6 ++++++ 2 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 releasenotes/notes/image-list-filter-multiple-properties-03c51d43131ee3b6.yaml diff --git a/openstackclient/image/v2/image.py b/openstackclient/image/v2/image.py index 1e67692a54..06eebe984c 100644 --- a/openstackclient/image/v2/image.py +++ b/openstackclient/image/v2/image.py @@ -515,7 +515,8 @@ class ListImage(command.Lister): '--property', metavar='', action=parseractions.KeyValueAction, - help=_('Filter output based on property'), + help=_('Filter output based on property ' + '(repeat option to filter on multiple properties)'), ) parser.add_argument( '--name', @@ -643,14 +644,13 @@ class ListImage(command.Lister): marker = page[-1]['id'] if parsed_args.property: - # NOTE(dtroyer): coerce to a list to subscript it in py3 - attr, value = list(parsed_args.property.items())[0] - api_utils.simple_filter( - data, - attr=attr, - value=value, - property_field='properties', - ) + for attr, value in parsed_args.property.items(): + api_utils.simple_filter( + data, + attr=attr, + value=value, + property_field='properties', + ) data = utils.sort_items(data, parsed_args.sort, str) diff --git a/releasenotes/notes/image-list-filter-multiple-properties-03c51d43131ee3b6.yaml b/releasenotes/notes/image-list-filter-multiple-properties-03c51d43131ee3b6.yaml new file mode 100644 index 0000000000..294f43810e --- /dev/null +++ b/releasenotes/notes/image-list-filter-multiple-properties-03c51d43131ee3b6.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + The ``image list`` command now properly filters images on multiple + ``--property`` options. + [Bug `2004290 `_]