Skip to content

Commit d7ad229

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Support pagination params for flavor list"
2 parents 3ad2f85 + 9471115 commit d7ad229

3 files changed

Lines changed: 37 additions & 6 deletions

File tree

doc/source/command-objects/flavor.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ List flavors
9191
os flavor list
9292
[--public | --private | --all]
9393
[--long]
94+
[--marker <marker>]
95+
[--limit <limit>]
9496
9597
.. option:: --public
9698

@@ -108,6 +110,14 @@ List flavors
108110

109111
List additional fields in output
110112

113+
.. option:: --marker <marker>
114+
115+
The last flavor ID of the previous page
116+
117+
.. option:: --limit <limit>
118+
119+
Maximum number of flavors to display
120+
111121
flavor show
112122
-----------
113123

openstackclient/compute/v2/flavor.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,15 @@ def get_parser(self, prog_name):
181181
action='store_true',
182182
default=False,
183183
help='List additional fields in output')
184+
parser.add_argument(
185+
'--marker',
186+
metavar="<marker>",
187+
help='The last flavor ID of the previous page')
188+
parser.add_argument(
189+
'--limit',
190+
type=int,
191+
metavar="<limit>",
192+
help='Maximum number of flavors to display')
184193
return parser
185194

186195
def take_action(self, parsed_args):
@@ -202,7 +211,9 @@ def take_action(self, parsed_args):
202211
# and flavors from their own projects only.
203212
is_public = None if parsed_args.all else parsed_args.public
204213

205-
data = compute_client.flavors.list(is_public=is_public)
214+
data = compute_client.flavors.list(is_public=is_public,
215+
marker=parsed_args.marker,
216+
limit=parsed_args.limit)
206217

207218
if parsed_args.long:
208219
columns = columns + (

openstackclient/tests/compute/v2/test_flavor.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ def test_flavor_list_no_options(self):
7676

7777
# Set expected values
7878
kwargs = {
79-
'is_public': True
79+
'is_public': True,
80+
'limit': None,
81+
'marker': None
8082
}
8183

8284
self.flavors_mock.list.assert_called_with(
@@ -119,7 +121,9 @@ def test_flavor_list_all_flavors(self):
119121

120122
# Set expected values
121123
kwargs = {
122-
'is_public': None
124+
'is_public': None,
125+
'limit': None,
126+
'marker': None
123127
}
124128

125129
self.flavors_mock.list.assert_called_with(
@@ -162,7 +166,9 @@ def test_flavor_list_private_flavors(self):
162166

163167
# Set expected values
164168
kwargs = {
165-
'is_public': False
169+
'is_public': False,
170+
'limit': None,
171+
'marker': None
166172
}
167173

168174
self.flavors_mock.list.assert_called_with(
@@ -205,7 +211,9 @@ def test_flavor_list_public_flavors(self):
205211

206212
# Set expected values
207213
kwargs = {
208-
'is_public': True
214+
'is_public': True,
215+
'limit': None,
216+
'marker': None
209217
}
210218

211219
self.flavors_mock.list.assert_called_with(
@@ -248,7 +256,9 @@ def test_flavor_list_long(self):
248256

249257
# Set expected values
250258
kwargs = {
251-
'is_public': True
259+
'is_public': True,
260+
'limit': None,
261+
'marker': None
252262
}
253263

254264
self.flavors_mock.list.assert_called_with(

0 commit comments

Comments
 (0)