File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -858,16 +858,18 @@ def test_volume_list_long(self):
858858 ), )
859859 self .assertCountEqual (datalist , tuple (data ))
860860
861- def test_volume_list_with_limit (self ):
861+ def test_volume_list_with_limit_and_offset (self ):
862862 arglist = [
863863 '--limit' , '2' ,
864+ '--offset' , '5' ,
864865 ]
865866 verifylist = [
866867 ('long' , False ),
867868 ('all_projects' , False ),
868869 ('name' , None ),
869870 ('status' , None ),
870871 ('limit' , 2 ),
872+ ('offset' , 5 ),
871873 ]
872874 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
873875
@@ -876,9 +878,11 @@ def test_volume_list_with_limit(self):
876878 self .volumes_mock .list .assert_called_once_with (
877879 limit = 2 ,
878880 search_opts = {
881+ 'offset' : 5 ,
879882 'status' : None ,
880883 'display_name' : None ,
881- 'all_tenants' : False , }
884+ 'all_tenants' : False ,
885+ },
882886 )
883887 self .assertEqual (self .columns , columns )
884888 self .assertCountEqual (self .datalist , tuple (data ))
Original file line number Diff line number Diff line change @@ -327,6 +327,13 @@ def get_parser(self, prog_name):
327327 default = False ,
328328 help = _ ('List additional fields in output' ),
329329 )
330+ parser .add_argument (
331+ '--offset' ,
332+ type = int ,
333+ action = parseractions .NonNegativeAction ,
334+ metavar = '<offset>' ,
335+ help = _ ('Index from which to start listing volumes' ),
336+ )
330337 parser .add_argument (
331338 '--limit' ,
332339 type = int ,
@@ -395,6 +402,9 @@ def take_action(self, parsed_args):
395402 'status' : parsed_args .status ,
396403 }
397404
405+ if parsed_args .offset :
406+ search_opts ['offset' ] = parsed_args .offset
407+
398408 data = volume_client .volumes .list (
399409 search_opts = search_opts ,
400410 limit = parsed_args .limit ,
You can’t perform that action at this time.
0 commit comments