boot: show warning if more than one match when setting --image-with
When setting --image-with meta_key=meta_value, we may got more than one results. We selected the first matched one silently. This patch prints a warning message for this scenario. Change-Id: I5be73fb61fb08d3abd0a509f3ac5cb6ea623c85a Signed-off-by: Chen Hanxiao <chenhx@certusnet.com.cn>
This commit is contained in:
parent
e386d5dbe5
commit
8084364413
@ -91,6 +91,15 @@ def emit_fixed_floating_deprecation_warning(command_name):
|
||||
command_name, file=sys.stderr)
|
||||
|
||||
|
||||
def emit_duplicated_image_with_warning(img, image_with):
|
||||
img_uuid_list = [str(image.id) for image in img]
|
||||
print(_('WARNING: Multiple matching images: %(img_uuid_list)s\n'
|
||||
'Using image: %(chosen_one)s') %
|
||||
{'img_uuid_list': img_uuid_list,
|
||||
'chosen_one': img_uuid_list[0]},
|
||||
file=sys.stderr)
|
||||
|
||||
|
||||
CLIENT_BDM2_KEYS = {
|
||||
'id': 'uuid',
|
||||
'source': 'source_type',
|
||||
@ -396,9 +405,9 @@ def _boot(cs, args):
|
||||
|
||||
if not image and args.image_with:
|
||||
images = _match_image(cs, args.image_with)
|
||||
if len(images) > 1:
|
||||
emit_duplicated_image_with_warning(images, args.image_with)
|
||||
if images:
|
||||
# TODO(harlowja): log a warning that we
|
||||
# are selecting the first of many?
|
||||
image = images[0]
|
||||
|
||||
min_count = 1
|
||||
|
Loading…
Reference in New Issue
Block a user