From 755f0a35083d7cc6bde0810090b716e567af3b6b Mon Sep 17 00:00:00 2001 From: pengdake <19921207pq@gmail.com> Date: Fri, 2 Feb 2018 22:55:39 +0800 Subject: [PATCH] Update zunclient about image_search Add parameter to supporting search image accurately Change-Id: I72630689913a5d656b98f350453de3a4e3e5660f Signed-off-by: pengdake <19921207pq@gmail.com> --- zunclient/osc/v1/images.py | 6 ++++++ zunclient/v1/images.py | 2 +- zunclient/v1/images_shell.py | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/zunclient/osc/v1/images.py b/zunclient/osc/v1/images.py index 2ca76b99..1a99605c 100644 --- a/zunclient/osc/v1/images.py +++ b/zunclient/osc/v1/images.py @@ -107,6 +107,11 @@ class SearchImage(command.Lister): 'image_name', metavar='', help='Name of the image') + parser.add_argument( + '--exact-match', + default=False, + action='store_true', + help='exact match image name') return parser def take_action(self, parsed_args): @@ -114,6 +119,7 @@ class SearchImage(command.Lister): opts = {} opts['image_driver'] = parsed_args.image_driver opts['image'] = parsed_args.image_name + opts['exact_match'] = parsed_args.exact_match opts = zun_utils.remove_null_parms(**opts) images = client.images.search_image(**opts) columns = ('ID', 'Name', 'Tags', 'Status', 'Size', 'Metadata') diff --git a/zunclient/v1/images.py b/zunclient/v1/images.py index 9dd19959..931e6213 100644 --- a/zunclient/v1/images.py +++ b/zunclient/v1/images.py @@ -16,7 +16,7 @@ from zunclient import exceptions PULL_ATTRIBUTES = ['repo'] -IMAGE_SEARCH_ATTRIBUTES = ['image', 'image_driver'] +IMAGE_SEARCH_ATTRIBUTES = ['image', 'image_driver', 'exact_match'] class Image(base.Resource): diff --git a/zunclient/v1/images_shell.py b/zunclient/v1/images_shell.py index 90c9f19f..a3dcac5f 100644 --- a/zunclient/v1/images_shell.py +++ b/zunclient/v1/images_shell.py @@ -73,11 +73,16 @@ def do_image_show(cs, args): metavar='', choices=['glance', 'docker'], help='Name of the image driver (glance, docker)') +@utils.arg('--exact-match', + default=False, + action='store_true', + help='exact match image name') def do_image_search(cs, args): """Print list of available images from repository based on user query.""" opts = {} opts['image'] = args.image opts['image_driver'] = args.image_driver + opts['exact_match'] = args.exact_match images = cs.images.search_image(**opts) columns = ('ID', 'Name', 'Tags', 'Status', 'Size', 'Metadata') utils.print_list(images, columns,