image/v2: support multiple property filters

Change-Id: I8ba40cb8ca647ec24b80c2824bb64e84430535d4
Signed-off-by: Sven Wegener <sven.wegener@inovex.de>
This commit is contained in:
Sven Wegener 2018-01-12 14:19:11 +01:00
parent 1894a3cb17
commit 21e4c87bde
No known key found for this signature in database
GPG Key ID: 198234340AB5DB1C
2 changed files with 15 additions and 9 deletions

View File

@ -515,7 +515,8 @@ class ListImage(command.Lister):
'--property',
metavar='<key=value>',
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)

View File

@ -0,0 +1,6 @@
---
features:
- |
The ``image list`` command now properly filters images on multiple
``--property`` options.
[Bug `2004290 <https://storyboard.openstack.org/#!/story/2004290>`_]