8989 check_container_engine ,
9090 find_container_engine ,
9191 normalize_container_id ,
92+ parsed_container_image_list ,
9293 parsed_container_mem_usage ,
9394 pull_command ,
9495 registry_login ,
@@ -477,16 +478,11 @@ def infer_local_ceph_image(ctx: CephadmContext, container_path: str) -> Optional
477478
478479 :return: The most recent local ceph image (already pulled)
479480 """
480- # '|' special character is used to separate the output fields into:
481- # - Repository@digest
482- # - Image Id
483- # - Image Tag
484- # - Image creation date
485- out , _ , _ = call_throws (ctx ,
486- [container_path , 'images' ,
487- '--filter' , 'label=ceph=True' ,
488- '--filter' , 'dangling=false' ,
489- '--format' , '{{.Repository}}@{{.Digest}}|{{.ID}}|{{.Tag}}|{{.CreatedAt}}' ])
481+ images = parsed_container_image_list (
482+ ctx ,
483+ filters = ['dangling=false' , 'label=ceph=True' ],
484+ container_path = container_path ,
485+ )
490486
491487 container_info = None
492488 daemon_name = ctx .name if ('name' in ctx and ctx .name and '.' in ctx .name ) else None
@@ -497,14 +493,12 @@ def infer_local_ceph_image(ctx: CephadmContext, container_path: str) -> Optional
497493 logger .debug (f"Using container info for daemon '{ daemon } '" )
498494 break
499495
500- for image in out .splitlines ():
501- if image and not image .isspace ():
502- (digest , image_id , tag , created_date ) = image .lstrip ().split ('|' )
503- if container_info is not None and image_id not in container_info .image_id :
504- continue
505- if digest and not digest .endswith ('@' ):
506- logger .info (f"Using ceph image with id '{ image_id } ' and tag '{ tag } ' created on { created_date } \n { digest } " )
507- return digest
496+ for image in images :
497+ if container_info is not None and image .image_id not in container_info .image_id :
498+ continue
499+ if image .digest :
500+ logger .info (f"Using ceph image with id '{ image .image_id } ' and tag '{ image .tag } ' created on { image .created } \n { image .name } " )
501+ return image .name
508502 if container_info is not None :
509503 logger .warning (f"Not using image '{ container_info .image_id } ' as it's not in list of non-dangling images with ceph=True label" )
510504 return None
0 commit comments