Add possibility to filter images using member_status
In order to see image sharing membership it is required to additionally pass member_status filter to API. Otherwise only those with status 'all' will be returned. Thus adding possibility to see images shared with project to be approved or rejected. Change-Id: Ifd6e13e5a4ef09fbc29e76d464c93fbdbb178ae4
This commit is contained in:
parent
0a187905c0
commit
444a40c656
@ -209,6 +209,7 @@ List available images
|
||||
[--property <key=value>]
|
||||
[--name <name>]
|
||||
[--status <status>]
|
||||
[--member-status <member-status>]
|
||||
[--tag <tag>]
|
||||
[--long]
|
||||
[--sort <key>[:<direction>]]
|
||||
@ -251,6 +252,12 @@ List available images
|
||||
|
||||
*Image version 2 only*
|
||||
|
||||
.. option:: --member-status <member-status>
|
||||
|
||||
Filter images based on member status
|
||||
|
||||
*Image version 2 only*
|
||||
|
||||
.. option:: --tag <tag>
|
||||
|
||||
Filter images based on tag
|
||||
|
@ -37,6 +37,7 @@ DEFAULT_CONTAINER_FORMAT = 'bare'
|
||||
DEFAULT_DISK_FORMAT = 'raw'
|
||||
DISK_CHOICES = ["ami", "ari", "aki", "vhd", "vmdk", "raw", "qcow2", "vhdx",
|
||||
"vdi", "iso", "ploop"]
|
||||
MEMBER_STATUS_CHOICES = ["accepted", "pending", "rejected", "all"]
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -530,6 +531,16 @@ class ListImage(command.Lister):
|
||||
default=None,
|
||||
help=_("Filter images based on status.")
|
||||
)
|
||||
parser.add_argument(
|
||||
'--member-status',
|
||||
metavar='<member-status>',
|
||||
default=None,
|
||||
type=lambda s: s.lower(),
|
||||
choices=MEMBER_STATUS_CHOICES,
|
||||
help=(_("Filter images based on member status. "
|
||||
"The supported options are: %s. ") %
|
||||
', '.join(MEMBER_STATUS_CHOICES))
|
||||
)
|
||||
parser.add_argument(
|
||||
'--tag',
|
||||
metavar='<tag>',
|
||||
@ -595,6 +606,8 @@ class ListImage(command.Lister):
|
||||
kwargs['name'] = parsed_args.name
|
||||
if parsed_args.status:
|
||||
kwargs['status'] = parsed_args.status
|
||||
if parsed_args.member_status:
|
||||
kwargs['member_status'] = parsed_args.member_status
|
||||
if parsed_args.tag:
|
||||
kwargs['tag'] = parsed_args.tag
|
||||
if parsed_args.long:
|
||||
|
@ -644,6 +644,49 @@ class TestImageList(TestImage):
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.datalist, tuple(data))
|
||||
|
||||
def test_image_list_shared_member_status_option(self):
|
||||
arglist = [
|
||||
'--shared',
|
||||
'--member-status', 'all'
|
||||
]
|
||||
verifylist = [
|
||||
('public', False),
|
||||
('private', False),
|
||||
('community', False),
|
||||
('shared', True),
|
||||
('long', False),
|
||||
('member_status', 'all')
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
# In base command class Lister in cliff, abstract method take_action()
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.api_mock.image_list.assert_called_with(
|
||||
shared=True,
|
||||
member_status='all',
|
||||
marker=self._image.id,
|
||||
)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.datalist, tuple(data))
|
||||
|
||||
def test_image_list_shared_member_status_lower(self):
|
||||
arglist = [
|
||||
'--shared',
|
||||
'--member-status', 'ALl'
|
||||
]
|
||||
verifylist = [
|
||||
('public', False),
|
||||
('private', False),
|
||||
('community', False),
|
||||
('shared', True),
|
||||
('long', False),
|
||||
('member_status', 'all')
|
||||
]
|
||||
self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
def test_image_list_long_option(self):
|
||||
arglist = [
|
||||
'--long',
|
||||
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
features:
|
||||
- Add ``--member-status`` option to ``image list`` command.
|
Loading…
Reference in New Issue
Block a user