summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-06-20 15:19:59 +0000
committerGerrit Code Review <review@openstack.org>2022-06-20 15:19:59 +0000
commit4f79def9aa356ab7df2fdb4546585d49e0116bc8 (patch)
treeacd291b108972c3ba2ed63dfd5ea3ce9cb5a8efb
parentec95b58482ae0853998c06dfd335db2456997644 (diff)
parent34d1e0c7eb8f4b613ca1f8e672a5367a4078a44a (diff)
downloadpython-openstackclient-4f79def9aa356ab7df2fdb4546585d49e0116bc8.tar.gz
Merge "Allow users to list all images"
-rw-r--r--openstackclient/image/v2/image.py9
-rw-r--r--openstackclient/tests/unit/image/v2/test_image.py32
2 files changed, 41 insertions, 0 deletions
diff --git a/openstackclient/image/v2/image.py b/openstackclient/image/v2/image.py
index 117d7a89..2f2f64ed 100644
--- a/openstackclient/image/v2/image.py
+++ b/openstackclient/image/v2/image.py
@@ -575,6 +575,13 @@ class ListImage(command.Lister):
default=False,
help=_("List only shared images"),
)
+ public_group.add_argument(
+ "--all",
+ dest="all",
+ action="store_true",
+ default=False,
+ help=_("List all images"),
+ )
parser.add_argument(
'--property',
metavar='<key=value>',
@@ -675,6 +682,8 @@ class ListImage(command.Lister):
kwargs['visibility'] = 'community'
if parsed_args.shared:
kwargs['visibility'] = 'shared'
+ if parsed_args.all:
+ kwargs['visibility'] = 'all'
if parsed_args.limit:
kwargs['limit'] = parsed_args.limit
if parsed_args.marker:
diff --git a/openstackclient/tests/unit/image/v2/test_image.py b/openstackclient/tests/unit/image/v2/test_image.py
index d563bf50..444717a7 100644
--- a/openstackclient/tests/unit/image/v2/test_image.py
+++ b/openstackclient/tests/unit/image/v2/test_image.py
@@ -486,6 +486,7 @@ class TestImageList(TestImage):
('private', False),
('community', False),
('shared', False),
+ ('all', False),
('long', False),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -510,6 +511,7 @@ class TestImageList(TestImage):
('private', False),
('community', False),
('shared', False),
+ ('all', False),
('long', False),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -534,6 +536,7 @@ class TestImageList(TestImage):
('private', True),
('community', False),
('shared', False),
+ ('all', False),
('long', False),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -558,6 +561,7 @@ class TestImageList(TestImage):
('private', False),
('community', True),
('shared', False),
+ ('all', False),
('long', False),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -582,6 +586,7 @@ class TestImageList(TestImage):
('private', False),
('community', False),
('shared', True),
+ ('all', False),
('long', False),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -597,6 +602,31 @@ class TestImageList(TestImage):
self.assertEqual(self.columns, columns)
self.assertCountEqual(self.datalist, tuple(data))
+ def test_image_list_all_option(self):
+ arglist = [
+ '--all',
+ ]
+ verifylist = [
+ ('public', False),
+ ('private', False),
+ ('community', False),
+ ('shared', False),
+ ('all', True),
+ ('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.client.images.assert_called_with(
+ visibility='all',
+ )
+
+ self.assertEqual(self.columns, columns)
+ self.assertCountEqual(self.datalist, tuple(data))
+
def test_image_list_shared_member_status_option(self):
arglist = [
'--shared',
@@ -607,6 +637,7 @@ class TestImageList(TestImage):
('private', False),
('community', False),
('shared', True),
+ ('all', False),
('long', False),
('member_status', 'all')
]
@@ -634,6 +665,7 @@ class TestImageList(TestImage):
('private', False),
('community', False),
('shared', True),
+ ('all', False),
('long', False),
('member_status', 'all')
]