Add a helper method to Image to parse ancestor string.
This commit is contained in:
parent
cd8b45e25b
commit
1d8b72235a
6 changed files with 33 additions and 32 deletions
|
@ -397,9 +397,7 @@ def get_repo_image_by_storage_checksum(namespace, repository_name, storage_check
|
|||
def get_image_layers(image):
|
||||
""" Returns a list of the full layers of an image, including itself (if specified), sorted
|
||||
from base image outward. """
|
||||
ancestors = image.ancestors.split('/')[1:-1]
|
||||
image_ids = [ancestor_id for ancestor_id in ancestors if ancestor_id]
|
||||
image_ids.append(str(image.id))
|
||||
image_ids = image.ancestor_id_list() + [image.id]
|
||||
|
||||
query = (ImageStoragePlacement
|
||||
.select(ImageStoragePlacement, Image, ImageStorage, ImageStorageLocation)
|
||||
|
@ -410,7 +408,7 @@ def get_image_layers(image):
|
|||
.where(Image.id << image_ids))
|
||||
|
||||
image_list = list(invert_placement_query_results(query))
|
||||
image_list.sort(key=lambda image: image_ids.index(str(image.id)))
|
||||
image_list.sort(key=lambda img: image_ids.index(img.id))
|
||||
return image_list
|
||||
|
||||
|
||||
|
|
Reference in a new issue