Skip to content

Commit 4f79def

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Allow users to list all images"
2 parents ec95b58 + 34d1e0c commit 4f79def

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

openstackclient/image/v2/image.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,13 @@ def get_parser(self, prog_name):
575575
default=False,
576576
help=_("List only shared images"),
577577
)
578+
public_group.add_argument(
579+
"--all",
580+
dest="all",
581+
action="store_true",
582+
default=False,
583+
help=_("List all images"),
584+
)
578585
parser.add_argument(
579586
'--property',
580587
metavar='<key=value>',
@@ -675,6 +682,8 @@ def take_action(self, parsed_args):
675682
kwargs['visibility'] = 'community'
676683
if parsed_args.shared:
677684
kwargs['visibility'] = 'shared'
685+
if parsed_args.all:
686+
kwargs['visibility'] = 'all'
678687
if parsed_args.limit:
679688
kwargs['limit'] = parsed_args.limit
680689
if parsed_args.marker:

openstackclient/tests/unit/image/v2/test_image.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ def test_image_list_no_options(self):
486486
('private', False),
487487
('community', False),
488488
('shared', False),
489+
('all', False),
489490
('long', False),
490491
]
491492
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -510,6 +511,7 @@ def test_image_list_public_option(self):
510511
('private', False),
511512
('community', False),
512513
('shared', False),
514+
('all', False),
513515
('long', False),
514516
]
515517
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -534,6 +536,7 @@ def test_image_list_private_option(self):
534536
('private', True),
535537
('community', False),
536538
('shared', False),
539+
('all', False),
537540
('long', False),
538541
]
539542
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -558,6 +561,7 @@ def test_image_list_community_option(self):
558561
('private', False),
559562
('community', True),
560563
('shared', False),
564+
('all', False),
561565
('long', False),
562566
]
563567
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -582,6 +586,7 @@ def test_image_list_shared_option(self):
582586
('private', False),
583587
('community', False),
584588
('shared', True),
589+
('all', False),
585590
('long', False),
586591
]
587592
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -597,6 +602,31 @@ def test_image_list_shared_option(self):
597602
self.assertEqual(self.columns, columns)
598603
self.assertCountEqual(self.datalist, tuple(data))
599604

605+
def test_image_list_all_option(self):
606+
arglist = [
607+
'--all',
608+
]
609+
verifylist = [
610+
('public', False),
611+
('private', False),
612+
('community', False),
613+
('shared', False),
614+
('all', True),
615+
('long', False),
616+
]
617+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
618+
619+
# In base command class Lister in cliff, abstract method take_action()
620+
# returns a tuple containing the column names and an iterable
621+
# containing the data to be listed.
622+
columns, data = self.cmd.take_action(parsed_args)
623+
self.client.images.assert_called_with(
624+
visibility='all',
625+
)
626+
627+
self.assertEqual(self.columns, columns)
628+
self.assertCountEqual(self.datalist, tuple(data))
629+
600630
def test_image_list_shared_member_status_option(self):
601631
arglist = [
602632
'--shared',
@@ -607,6 +637,7 @@ def test_image_list_shared_member_status_option(self):
607637
('private', False),
608638
('community', False),
609639
('shared', True),
640+
('all', False),
610641
('long', False),
611642
('member_status', 'all')
612643
]
@@ -634,6 +665,7 @@ def test_image_list_shared_member_status_lower(self):
634665
('private', False),
635666
('community', False),
636667
('shared', True),
668+
('all', False),
637669
('long', False),
638670
('member_status', 'all')
639671
]

0 commit comments

Comments
 (0)