예제 #1
0
 def get_from_store(image_meta):
     try:
         location = image_meta['location']
         image_data, image_size = get_from_backend(location)
         image_meta["size"] = image_size or image_meta["size"]
     except exception.NotFound, e:
         raise HTTPNotFound(explanation="%s" % e)
예제 #2
0
    def fetch_image_into_cache(self, image_id):
        ctx = registry.get_client_context(self.conf, is_admin=True, show_deleted=True)
        try:
            image_meta = registry.get_image_metadata(ctx, image_id)
            if image_meta["status"] != "active":
                logger.warn(_("Image '%s' is not active. Not caching."), image_id)
                return False

        except exception.NotFound:
            logger.warn(_("No metadata found for image '%s'"), image_id)
            return False

        image_data, image_size = get_from_backend(image_meta["location"])
        logger.debug(_("Caching image '%s'"), image_id)
        self.cache.cache_image_iter(image_id, image_data)
        return True
예제 #3
0
    def fetch_image_into_cache(self, image_id):
        ctx = registry.get_client_context(self.conf,
                                          is_admin=True, show_deleted=True)
        try:
            image_meta = registry.get_image_metadata(ctx, image_id)
            if image_meta['status'] != 'active':
                logger.warn(_("Image '%s' is not active. Not caching."),
                            image_id)
                return False

        except exception.NotFound:
            logger.warn(_("No metadata found for image '%s'"), image_id)
            return False

        image_data, image_size = get_from_backend(image_meta['location'])
        logger.debug(_("Caching image '%s'"), image_id)
        self.cache.cache_image_iter(image_id, image_data)
        return True