File tree Expand file tree Collapse file tree
doc/source/command-objects
openstackclient/compute/v2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ List servers
216216
217217.. option:: --flavor < flavor>
218218
219- Search by flavor ID
219+ Search by flavor (name or ID)
220220
221221.. option:: --image < image>
222222
Original file line number Diff line number Diff line change @@ -712,7 +712,7 @@ def get_parser(self, prog_name):
712712 parser .add_argument (
713713 '--flavor' ,
714714 metavar = '<flavor>' ,
715- help = _ ('Search by flavor' ),
715+ help = _ ('Search by flavor (name or ID) ' ),
716716 )
717717 parser .add_argument (
718718 '--image' ,
@@ -789,14 +789,21 @@ def take_action(self, parsed_args):
789789 parsed_args .user_domain ,
790790 ).id
791791
792+ # Nova only supports list servers searching by flavor ID. So if a
793+ # flavor name is given, map it to ID.
794+ flavor_id = None
795+ if parsed_args .flavor :
796+ flavor_id = utils .find_resource (compute_client .flavors ,
797+ parsed_args .flavor ).id
798+
792799 search_opts = {
793800 'reservation_id' : parsed_args .reservation_id ,
794801 'ip' : parsed_args .ip ,
795802 'ip6' : parsed_args .ip6 ,
796803 'name' : parsed_args .name ,
797804 'instance_name' : parsed_args .instance_name ,
798805 'status' : parsed_args .status ,
799- 'flavor' : parsed_args . flavor ,
806+ 'flavor' : flavor_id ,
800807 'image' : parsed_args .image ,
801808 'host' : parsed_args .host ,
802809 'tenant_id' : project_id ,
You can’t perform that action at this time.
0 commit comments