Support --community in openstack image list
"--community" was added to "image create" and "image set" previously, but was missed in "image list". Change-Id: I959fdd7f67ae62c8326659ce52389228152ec019 Story: 2001925 Task: 14453
This commit is contained in:
parent
e4b8c31cd3
commit
860639a548
@ -205,7 +205,7 @@ List available images
|
|||||||
.. code:: bash
|
.. code:: bash
|
||||||
|
|
||||||
openstack image list
|
openstack image list
|
||||||
[--public | --private | --shared]
|
[--public | --private | --community | --shared]
|
||||||
[--property <key=value>]
|
[--property <key=value>]
|
||||||
[--name <name>]
|
[--name <name>]
|
||||||
[--status <status>]
|
[--status <status>]
|
||||||
@ -223,6 +223,12 @@ List available images
|
|||||||
|
|
||||||
List only private images
|
List only private images
|
||||||
|
|
||||||
|
.. option:: --community
|
||||||
|
|
||||||
|
List only community images
|
||||||
|
|
||||||
|
*Image version 2 only.*
|
||||||
|
|
||||||
.. option:: --shared
|
.. option:: --shared
|
||||||
|
|
||||||
List only shared images
|
List only shared images
|
||||||
|
@ -31,6 +31,7 @@ class APIv2(image_v1.APIv1):
|
|||||||
detailed=False,
|
detailed=False,
|
||||||
public=False,
|
public=False,
|
||||||
private=False,
|
private=False,
|
||||||
|
community=False,
|
||||||
shared=False,
|
shared=False,
|
||||||
**filter
|
**filter
|
||||||
):
|
):
|
||||||
@ -44,25 +45,29 @@ class APIv2(image_v1.APIv1):
|
|||||||
Return public images if True
|
Return public images if True
|
||||||
:param private:
|
:param private:
|
||||||
Return private images if True
|
Return private images if True
|
||||||
|
:param community:
|
||||||
|
Return commuity images if True
|
||||||
:param shared:
|
:param shared:
|
||||||
Return shared images if True
|
Return shared images if True
|
||||||
|
|
||||||
If public, private and shared are all True or all False then all
|
If public, private, community and shared are all True or all False
|
||||||
images are returned. All arguments False is equivalent to no filter
|
then all images are returned. All arguments False is equivalent to no
|
||||||
and all images are returned. All arguments True is a filter that
|
filter and all images are returned. All arguments True is a filter
|
||||||
includes all public, private and shared images which is the same set
|
that includes all public, private, community and shared images which
|
||||||
as all images.
|
is the same set as all images.
|
||||||
|
|
||||||
http://docs.openstack.org/api/openstack-image-service/2.0/content/list-images.html
|
http://docs.openstack.org/api/openstack-image-service/2.0/content/list-images.html
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not public and not private and not shared:
|
if not public and not private and not community and not shared:
|
||||||
# No filtering for all False
|
# No filtering for all False
|
||||||
filter.pop('visibility', None)
|
filter.pop('visibility', None)
|
||||||
elif public:
|
elif public:
|
||||||
filter['visibility'] = 'public'
|
filter['visibility'] = 'public'
|
||||||
elif private:
|
elif private:
|
||||||
filter['visibility'] = 'private'
|
filter['visibility'] = 'private'
|
||||||
|
elif community:
|
||||||
|
filter['visibility'] = 'community'
|
||||||
elif shared:
|
elif shared:
|
||||||
filter['visibility'] = 'shared'
|
filter['visibility'] = 'shared'
|
||||||
|
|
||||||
|
@ -439,6 +439,13 @@ class ListImage(command.Lister):
|
|||||||
default=False,
|
default=False,
|
||||||
help=_("List only private images"),
|
help=_("List only private images"),
|
||||||
)
|
)
|
||||||
|
public_group.add_argument(
|
||||||
|
"--community",
|
||||||
|
dest="community",
|
||||||
|
action="store_true",
|
||||||
|
default=False,
|
||||||
|
help=_("List only community images"),
|
||||||
|
)
|
||||||
public_group.add_argument(
|
public_group.add_argument(
|
||||||
"--shared",
|
"--shared",
|
||||||
dest="shared",
|
dest="shared",
|
||||||
@ -516,6 +523,8 @@ class ListImage(command.Lister):
|
|||||||
kwargs['public'] = True
|
kwargs['public'] = True
|
||||||
if parsed_args.private:
|
if parsed_args.private:
|
||||||
kwargs['private'] = True
|
kwargs['private'] = True
|
||||||
|
if parsed_args.community:
|
||||||
|
kwargs['community'] = True
|
||||||
if parsed_args.shared:
|
if parsed_args.shared:
|
||||||
kwargs['shared'] = True
|
kwargs['shared'] = True
|
||||||
if parsed_args.limit:
|
if parsed_args.limit:
|
||||||
|
@ -527,6 +527,7 @@ class TestImageList(TestImage):
|
|||||||
verifylist = [
|
verifylist = [
|
||||||
('public', False),
|
('public', False),
|
||||||
('private', False),
|
('private', False),
|
||||||
|
('community', False),
|
||||||
('shared', False),
|
('shared', False),
|
||||||
('long', False),
|
('long', False),
|
||||||
]
|
]
|
||||||
@ -550,6 +551,7 @@ class TestImageList(TestImage):
|
|||||||
verifylist = [
|
verifylist = [
|
||||||
('public', True),
|
('public', True),
|
||||||
('private', False),
|
('private', False),
|
||||||
|
('community', False),
|
||||||
('shared', False),
|
('shared', False),
|
||||||
('long', False),
|
('long', False),
|
||||||
]
|
]
|
||||||
@ -574,6 +576,7 @@ class TestImageList(TestImage):
|
|||||||
verifylist = [
|
verifylist = [
|
||||||
('public', False),
|
('public', False),
|
||||||
('private', True),
|
('private', True),
|
||||||
|
('community', False),
|
||||||
('shared', False),
|
('shared', False),
|
||||||
('long', False),
|
('long', False),
|
||||||
]
|
]
|
||||||
@ -591,6 +594,31 @@ class TestImageList(TestImage):
|
|||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(self.datalist, tuple(data))
|
self.assertEqual(self.datalist, tuple(data))
|
||||||
|
|
||||||
|
def test_image_list_community_option(self):
|
||||||
|
arglist = [
|
||||||
|
'--community',
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('public', False),
|
||||||
|
('private', False),
|
||||||
|
('community', True),
|
||||||
|
('shared', False),
|
||||||
|
('long', False),
|
||||||
|
]
|
||||||
|
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(
|
||||||
|
community=True,
|
||||||
|
marker=self._image.id,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(self.columns, columns)
|
||||||
|
self.assertEqual(self.datalist, tuple(data))
|
||||||
|
|
||||||
def test_image_list_shared_option(self):
|
def test_image_list_shared_option(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--shared',
|
'--shared',
|
||||||
@ -598,6 +626,7 @@ class TestImageList(TestImage):
|
|||||||
verifylist = [
|
verifylist = [
|
||||||
('public', False),
|
('public', False),
|
||||||
('private', False),
|
('private', False),
|
||||||
|
('community', False),
|
||||||
('shared', True),
|
('shared', True),
|
||||||
('long', False),
|
('long', False),
|
||||||
]
|
]
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- Add ``--community`` option to ``image list`` command.
|
||||||
|
[Bug `2001925 <https://storyboard.openstack.org/#!/story/2001925>`_]
|
Loading…
Reference in New Issue
Block a user