File tree Expand file tree Collapse file tree
doc/source/command-objects Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -168,6 +168,7 @@ List available images
168168 [--long]
169169 [--sort < key> [:< direction> ]]
170170 [--limit < limit> ]
171+ [--marker < marker> ]
171172
172173.. option:: --public
173174
@@ -200,6 +201,11 @@ List available images
200201
201202 Maximum number of images to display.
202203
204+ .. option:: --marker < marker>
205+
206+ The last image (name or ID) of the previous page. Display list of images
207+ after marker. Display all images if not specified.
208+
203209image save
204210----------
205211
Original file line number Diff line number Diff line change @@ -437,6 +437,14 @@ def get_parser(self, prog_name):
437437 type = int ,
438438 help = "Maximum number of images to display." ,
439439 )
440+ parser .add_argument (
441+ '--marker' ,
442+ metavar = '<marker>' ,
443+ default = None ,
444+ help = "The last image (name or ID) of the previous page. Display "
445+ "list of images after marker. Display all images if not "
446+ "specified."
447+ )
440448 return parser
441449
442450 def take_action (self , parsed_args ):
@@ -451,6 +459,9 @@ def take_action(self, parsed_args):
451459 kwargs ['shared' ] = True
452460 if parsed_args .limit :
453461 kwargs ['limit' ] = parsed_args .limit
462+ if parsed_args .marker :
463+ kwargs ['marker' ] = utils .find_resource (image_client .images ,
464+ parsed_args .marker ).id
454465
455466 if parsed_args .long :
456467 columns = (
Original file line number Diff line number Diff line change @@ -672,6 +672,27 @@ def test_image_list_limit_option(self):
672672 self .assertEqual (self .columns , columns )
673673 self .assertEqual (len (self .datalist ), len (tuple (data )))
674674
675+ @mock .patch ('openstackclient.common.utils.find_resource' )
676+ def test_image_list_marker_option (self , fr_mock ):
677+ # tangchen: Since image_fakes.IMAGE is a dict, it cannot offer a .id
678+ # operation. Will fix this by using FakeImage class instead
679+ # of IMAGE dict.
680+ fr_mock .return_value = mock .Mock ()
681+ fr_mock .return_value .id = image_fakes .image_id
682+
683+ arglist = [
684+ '--marker' , image_fakes .image_name ,
685+ ]
686+ verifylist = [
687+ ('marker' , image_fakes .image_name ),
688+ ]
689+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
690+
691+ columns , data = self .cmd .take_action (parsed_args )
692+ self .api_mock .image_list .assert_called_with (
693+ marker = image_fakes .image_id ,
694+ )
695+
675696
676697class TestRemoveProjectImage (TestImage ):
677698
Original file line number Diff line number Diff line change @@ -4,3 +4,6 @@ features:
44 Add ``--limit`` option to ``image list`` to limit the number of images
55 in output.
66 [Bug `1540988 <https://bugs.launchpad.net/bugs/1540988>`_]
7+ - |
8+ Add ``--marker`` option to ``image list`` to handle paginate requests.
9+ [Bug `1540988 <https://bugs.launchpad.net/bugs/1540988>`_]
You can’t perform that action at this time.
0 commit comments