Add API and UI support for displaying image locations

This commit is contained in:
Joseph Schorr 2014-06-24 18:48:42 -04:00
parent da12b940a9
commit 76165b5d2b
16 changed files with 248 additions and 7 deletions

View file

@ -1098,13 +1098,32 @@ def set_image_metadata(docker_image_id, namespace_name, repository_name,
def get_repository_images(namespace_name, repository_name):
return (Image
.select(Image, ImageStorage)
.join(Repository)
.switch(Image)
location_list = list((ImageStoragePlacement
.select(ImageStoragePlacement, Image, ImageStorage, ImageStorageLocation)
.join(ImageStorageLocation)
.switch(ImageStoragePlacement)
.join(ImageStorage, JOIN_LEFT_OUTER)
.join(Image)
.join(Repository)
.where(Repository.name == repository_name,
Repository.namespace == namespace_name))
Repository.namespace == namespace_name)))
images = {}
for location in location_list:
# Make sure we're always retrieving the same image object.
image = location.storage.image
image_id = image.docker_image_id
if not image_id in images:
images[image_id] = image
image.storage.locations = set()
else:
image = images[image_id]
# Add the location to the image's locations set.
image.storage.locations.add(location)
return images.values()
def list_repository_tags(namespace_name, repository_name):