@@ -263,6 +263,18 @@ def get_parser(self, prog_name):
263263 default = False ,
264264 help = _ ("List all flavors, whether public or private" )
265265 )
266+ parser .add_argument (
267+ '--min-disk' ,
268+ type = int ,
269+ metavar = '<min-disk>' ,
270+ help = _ ('Filters the flavors by a minimum disk space, in GiB.' ),
271+ )
272+ parser .add_argument (
273+ '--min-ram' ,
274+ type = int ,
275+ metavar = '<min-ram>' ,
276+ help = _ ('Filters the flavors by a minimum RAM, in MiB.' ),
277+ )
266278 parser .add_argument (
267279 '--long' ,
268280 action = 'store_true' ,
@@ -277,8 +289,13 @@ def get_parser(self, prog_name):
277289 parser .add_argument (
278290 '--limit' ,
279291 type = int ,
280- metavar = "<num-flavors>" ,
281- help = _ ("Maximum number of flavors to display" )
292+ metavar = '<num-flavors>' ,
293+ help = _ (
294+ 'Maximum number of flavors to display. This is also '
295+ 'configurable on the server. The actual limit used will be '
296+ 'the lower of the user-supplied value and the server '
297+ 'configuration-derived value'
298+ ),
282299 )
283300 return parser
284301
@@ -293,15 +310,24 @@ def take_action(self, parsed_args):
293310 query_attrs = {
294311 'is_public' : is_public
295312 }
313+
296314 if parsed_args .marker :
297315 query_attrs ['marker' ] = parsed_args .marker
316+
298317 if parsed_args .limit :
299318 query_attrs ['limit' ] = parsed_args .limit
319+
300320 if parsed_args .limit or parsed_args .marker :
301321 # User passed explicit pagination request, switch off SDK
302322 # pagination
303323 query_attrs ['paginated' ] = False
304324
325+ if parsed_args .min_disk :
326+ query_attrs ['min_disk' ] = parsed_args .min_disk
327+
328+ if parsed_args .min_ram :
329+ query_attrs ['min_ram' ] = parsed_args .min_ram
330+
305331 data = list (compute_client .flavors (** query_attrs ))
306332 # Even if server supports 2.61 some policy might stop it sending us
307333 # extra_specs. So try to fetch them if they are absent
@@ -341,10 +367,13 @@ def take_action(self, parsed_args):
341367 "Properties" ,
342368 )
343369
344- return (column_headers ,
345- (utils .get_item_properties (
346- s , columns , formatters = _formatters ,
347- ) for s in data ))
370+ return (
371+ column_headers ,
372+ (
373+ utils .get_item_properties (s , columns , formatters = _formatters )
374+ for s in data
375+ ),
376+ )
348377
349378
350379class SetFlavor (command .Command ):
@@ -378,13 +407,13 @@ def get_parser(self, prog_name):
378407 help = _ ('Set flavor access to project (name or ID) '
379408 '(admin only)' ),
380409 )
410+ identity_common .add_project_domain_option_to_parser (parser )
381411 parser .add_argument (
382412 '--description' ,
383413 metavar = '<description>' ,
384414 help = _ ("Set description for the flavor.(Supported by API "
385415 "versions '2.55' - '2.latest'" )
386416 )
387- identity_common .add_project_domain_option_to_parser (parser )
388417
389418 return parser
390419
0 commit comments