Support pagination params for flavor list

Missing 'marker' and 'limit' params for `openstack flavor list` shell
command. It would be nice to have this when there are many flavors.

Closes-bug: #1505874
Change-Id: I088ac5d24f0d7595f5cbce14f063e296a449eb26
This commit is contained in:
liyingjun 2015-10-14 11:05:02 +08:00
parent 69be668534
commit 9471115a9a
3 changed files with 37 additions and 6 deletions

View File

@ -91,6 +91,8 @@ List flavors
os flavor list
[--public | --private | --all]
[--long]
[--marker <marker>]
[--limit <limit>]
.. option:: --public
@ -108,6 +110,14 @@ List flavors
List additional fields in output
.. option:: --marker <marker>
The last flavor ID of the previous page
.. option:: --limit <limit>
Maximum number of flavors to display
flavor show
-----------

View File

@ -181,6 +181,15 @@ class ListFlavor(lister.Lister):
action='store_true',
default=False,
help='List additional fields in output')
parser.add_argument(
'--marker',
metavar="<marker>",
help='The last flavor ID of the previous page')
parser.add_argument(
'--limit',
type=int,
metavar="<limit>",
help='Maximum number of flavors to display')
return parser
def take_action(self, parsed_args):
@ -202,7 +211,9 @@ class ListFlavor(lister.Lister):
# and flavors from their own projects only.
is_public = None if parsed_args.all else parsed_args.public
data = compute_client.flavors.list(is_public=is_public)
data = compute_client.flavors.list(is_public=is_public,
marker=parsed_args.marker,
limit=parsed_args.limit)
if parsed_args.long:
columns = columns + (

View File

@ -76,7 +76,9 @@ class TestFlavorList(TestFlavor):
# Set expected values
kwargs = {
'is_public': True
'is_public': True,
'limit': None,
'marker': None
}
self.flavors_mock.list.assert_called_with(
@ -119,7 +121,9 @@ class TestFlavorList(TestFlavor):
# Set expected values
kwargs = {
'is_public': None
'is_public': None,
'limit': None,
'marker': None
}
self.flavors_mock.list.assert_called_with(
@ -162,7 +166,9 @@ class TestFlavorList(TestFlavor):
# Set expected values
kwargs = {
'is_public': False
'is_public': False,
'limit': None,
'marker': None
}
self.flavors_mock.list.assert_called_with(
@ -205,7 +211,9 @@ class TestFlavorList(TestFlavor):
# Set expected values
kwargs = {
'is_public': True
'is_public': True,
'limit': None,
'marker': None
}
self.flavors_mock.list.assert_called_with(
@ -248,7 +256,9 @@ class TestFlavorList(TestFlavor):
# Set expected values
kwargs = {
'is_public': True
'is_public': True,
'limit': None,
'marker': None
}
self.flavors_mock.list.assert_called_with(