Allow users to list all images
Add a "--all" option to "openstack image list", which allows the user to list all of the images. Story: 2010071 Change-Id: I56a2e4846d0380d07803305fb830d1a43dfd71b3
This commit is contained in:
parent
ed304992eb
commit
34d1e0c7eb
@ -575,6 +575,13 @@ class ListImage(command.Lister):
|
|||||||
default=False,
|
default=False,
|
||||||
help=_("List only shared images"),
|
help=_("List only shared images"),
|
||||||
)
|
)
|
||||||
|
public_group.add_argument(
|
||||||
|
"--all",
|
||||||
|
dest="all",
|
||||||
|
action="store_true",
|
||||||
|
default=False,
|
||||||
|
help=_("List all images"),
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--property',
|
'--property',
|
||||||
metavar='<key=value>',
|
metavar='<key=value>',
|
||||||
@ -675,6 +682,8 @@ class ListImage(command.Lister):
|
|||||||
kwargs['visibility'] = 'community'
|
kwargs['visibility'] = 'community'
|
||||||
if parsed_args.shared:
|
if parsed_args.shared:
|
||||||
kwargs['visibility'] = 'shared'
|
kwargs['visibility'] = 'shared'
|
||||||
|
if parsed_args.all:
|
||||||
|
kwargs['visibility'] = 'all'
|
||||||
if parsed_args.limit:
|
if parsed_args.limit:
|
||||||
kwargs['limit'] = parsed_args.limit
|
kwargs['limit'] = parsed_args.limit
|
||||||
if parsed_args.marker:
|
if parsed_args.marker:
|
||||||
|
@ -486,6 +486,7 @@ class TestImageList(TestImage):
|
|||||||
('private', False),
|
('private', False),
|
||||||
('community', False),
|
('community', False),
|
||||||
('shared', False),
|
('shared', False),
|
||||||
|
('all', False),
|
||||||
('long', False),
|
('long', False),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
@ -510,6 +511,7 @@ class TestImageList(TestImage):
|
|||||||
('private', False),
|
('private', False),
|
||||||
('community', False),
|
('community', False),
|
||||||
('shared', False),
|
('shared', False),
|
||||||
|
('all', False),
|
||||||
('long', False),
|
('long', False),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
@ -534,6 +536,7 @@ class TestImageList(TestImage):
|
|||||||
('private', True),
|
('private', True),
|
||||||
('community', False),
|
('community', False),
|
||||||
('shared', False),
|
('shared', False),
|
||||||
|
('all', False),
|
||||||
('long', False),
|
('long', False),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
@ -558,6 +561,7 @@ class TestImageList(TestImage):
|
|||||||
('private', False),
|
('private', False),
|
||||||
('community', True),
|
('community', True),
|
||||||
('shared', False),
|
('shared', False),
|
||||||
|
('all', False),
|
||||||
('long', False),
|
('long', False),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
@ -582,6 +586,7 @@ class TestImageList(TestImage):
|
|||||||
('private', False),
|
('private', False),
|
||||||
('community', False),
|
('community', False),
|
||||||
('shared', True),
|
('shared', True),
|
||||||
|
('all', False),
|
||||||
('long', False),
|
('long', False),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
@ -597,6 +602,31 @@ class TestImageList(TestImage):
|
|||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertCountEqual(self.datalist, tuple(data))
|
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):
|
def test_image_list_shared_member_status_option(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--shared',
|
'--shared',
|
||||||
@ -607,6 +637,7 @@ class TestImageList(TestImage):
|
|||||||
('private', False),
|
('private', False),
|
||||||
('community', False),
|
('community', False),
|
||||||
('shared', True),
|
('shared', True),
|
||||||
|
('all', False),
|
||||||
('long', False),
|
('long', False),
|
||||||
('member_status', 'all')
|
('member_status', 'all')
|
||||||
]
|
]
|
||||||
@ -634,6 +665,7 @@ class TestImageList(TestImage):
|
|||||||
('private', False),
|
('private', False),
|
||||||
('community', False),
|
('community', False),
|
||||||
('shared', True),
|
('shared', True),
|
||||||
|
('all', False),
|
||||||
('long', False),
|
('long', False),
|
||||||
('member_status', 'all')
|
('member_status', 'all')
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user