Merge "Support pagination params for flavor list"

This commit is contained in:
Jenkins 2015-10-23 00:02:54 +00:00 committed by Gerrit Code Review
commit d7ad229d8a
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(