Merge "volume: Add missing 'volume list --offset' parameter"
This commit is contained in:
commit
2c89812714
@ -858,9 +858,10 @@ class TestVolumeList(TestVolume):
|
|||||||
), )
|
), )
|
||||||
self.assertCountEqual(datalist, tuple(data))
|
self.assertCountEqual(datalist, tuple(data))
|
||||||
|
|
||||||
def test_volume_list_with_limit(self):
|
def test_volume_list_with_limit_and_offset(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--limit', '2',
|
'--limit', '2',
|
||||||
|
'--offset', '5',
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('long', False),
|
('long', False),
|
||||||
@ -868,6 +869,7 @@ class TestVolumeList(TestVolume):
|
|||||||
('name', None),
|
('name', None),
|
||||||
('status', None),
|
('status', None),
|
||||||
('limit', 2),
|
('limit', 2),
|
||||||
|
('offset', 5),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
@ -876,9 +878,11 @@ class TestVolumeList(TestVolume):
|
|||||||
self.volumes_mock.list.assert_called_once_with(
|
self.volumes_mock.list.assert_called_once_with(
|
||||||
limit=2,
|
limit=2,
|
||||||
search_opts={
|
search_opts={
|
||||||
|
'offset': 5,
|
||||||
'status': None,
|
'status': None,
|
||||||
'display_name': None,
|
'display_name': None,
|
||||||
'all_tenants': False, }
|
'all_tenants': False,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertCountEqual(self.datalist, tuple(data))
|
self.assertCountEqual(self.datalist, tuple(data))
|
||||||
|
@ -327,6 +327,13 @@ class ListVolume(command.Lister):
|
|||||||
default=False,
|
default=False,
|
||||||
help=_('List additional fields in output'),
|
help=_('List additional fields in output'),
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--offset',
|
||||||
|
type=int,
|
||||||
|
action=parseractions.NonNegativeAction,
|
||||||
|
metavar='<offset>',
|
||||||
|
help=_('Index from which to start listing volumes'),
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--limit',
|
'--limit',
|
||||||
type=int,
|
type=int,
|
||||||
@ -395,6 +402,9 @@ class ListVolume(command.Lister):
|
|||||||
'status': parsed_args.status,
|
'status': parsed_args.status,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if parsed_args.offset:
|
||||||
|
search_opts['offset'] = parsed_args.offset
|
||||||
|
|
||||||
data = volume_client.volumes.list(
|
data = volume_client.volumes.list(
|
||||||
search_opts=search_opts,
|
search_opts=search_opts,
|
||||||
limit=parsed_args.limit,
|
limit=parsed_args.limit,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user