From 9471115a9a516049684755d7582338c83b3ca1f5 Mon Sep 17 00:00:00 2001 From: liyingjun Date: Wed, 14 Oct 2015 11:05:02 +0800 Subject: 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 --- openstackclient/compute/v2/flavor.py | 13 ++++++++++++- openstackclient/tests/compute/v2/test_flavor.py | 20 +++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) (limited to 'openstackclient') diff --git a/openstackclient/compute/v2/flavor.py b/openstackclient/compute/v2/flavor.py index 3458cf79..7474580b 100644 --- a/openstackclient/compute/v2/flavor.py +++ b/openstackclient/compute/v2/flavor.py @@ -181,6 +181,15 @@ class ListFlavor(lister.Lister): action='store_true', default=False, help='List additional fields in output') + parser.add_argument( + '--marker', + metavar="", + help='The last flavor ID of the previous page') + parser.add_argument( + '--limit', + type=int, + metavar="", + 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 + ( diff --git a/openstackclient/tests/compute/v2/test_flavor.py b/openstackclient/tests/compute/v2/test_flavor.py index 19be8124..523104f0 100644 --- a/openstackclient/tests/compute/v2/test_flavor.py +++ b/openstackclient/tests/compute/v2/test_flavor.py @@ -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( -- cgit v1.2.1