Support "server list" searching by both image name and ID.
Nova API only supports list servers searching by image ID. In OSC, we can support both image name and ID by mapping the name to ID. This patch also fix the inconsistent doc in .py and .rst files. Closes-Bug: 1521492 Change-Id: I70613843f82d74732bd32a457cd4a31aba57825f
This commit is contained in:
parent
0069a01967
commit
106f928cb6
@ -220,7 +220,7 @@ List servers
|
||||
|
||||
.. option:: --image <image>
|
||||
|
||||
Search by image ID
|
||||
Search by image (name or ID)
|
||||
|
||||
.. option:: --host <hostname>
|
||||
|
||||
|
@ -717,7 +717,7 @@ class ListServer(lister.Lister):
|
||||
parser.add_argument(
|
||||
'--image',
|
||||
metavar='<image>',
|
||||
help=_('Search by image'),
|
||||
help=_('Search by image (name or ID)'),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--host',
|
||||
@ -796,6 +796,13 @@ class ListServer(lister.Lister):
|
||||
flavor_id = utils.find_resource(compute_client.flavors,
|
||||
parsed_args.flavor).id
|
||||
|
||||
# Nova only supports list servers searching by image ID. So if a
|
||||
# image name is given, map it to ID.
|
||||
image_id = None
|
||||
if parsed_args.image:
|
||||
image_id = utils.find_resource(compute_client.images,
|
||||
parsed_args.image).id
|
||||
|
||||
search_opts = {
|
||||
'reservation_id': parsed_args.reservation_id,
|
||||
'ip': parsed_args.ip,
|
||||
@ -804,7 +811,7 @@ class ListServer(lister.Lister):
|
||||
'instance_name': parsed_args.instance_name,
|
||||
'status': parsed_args.status,
|
||||
'flavor': flavor_id,
|
||||
'image': parsed_args.image,
|
||||
'image': image_id,
|
||||
'host': parsed_args.host,
|
||||
'tenant_id': project_id,
|
||||
'all_tenants': parsed_args.all_projects,
|
||||
|
Loading…
x
Reference in New Issue
Block a user