From 0a62f7f72560c4d942a0328853f337518add9bed Mon Sep 17 00:00:00 2001 From: Jake Moshenko Date: Wed, 18 Jun 2014 12:40:23 -0400 Subject: [PATCH] Add the ability to look up images which do not have a placement yet. --- config.py | 3 +++ data/model/legacy.py | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index 79866aaf2..7b4344f99 100644 --- a/config.py +++ b/config.py @@ -152,3 +152,6 @@ class DefaultConfig(object): } DISTRIBUTED_STORAGE_PREFERENCE = ['local_us'] + + # Remove me when all imagestorage objects have a location + DS_BACKFILL_LOCATION= 'local_us' diff --git a/data/model/legacy.py b/data/model/legacy.py index 0bbca5c9e..f2c1b9e61 100644 --- a/data/model/legacy.py +++ b/data/model/legacy.py @@ -857,7 +857,22 @@ def get_repo_image(namespace_name, repository_name, image_id): Image.docker_image_id == image_id))) if not location_list: - return None + # REMOVEME When all existing imagestorages have a placement + try: + logger.warning('Checking for image without placement') + no_placement = (Image.select(Image, ImageStorage) + .join(ImageStorage) + .switch(Image) + .join(Repository) + .where(Repository.name == repository_name, + Repository.namespace == namespace_name, + Image.docker_image_id == image_id) + .get()) + no_placement.storage.locations = {config.app_config['DS_BACKFILL_LOCATION']} + return no_placement + except Image.DoesNotExist: + logger.warning('Unable to find image') + return None location_names = {location.location.name for location in location_list}