def _create_image_cache_volume_entry(self, ctx, volume_ref, image_id, image_meta):
    'Create a new image-volume and cache entry for it.\n\n        This assumes that the image has already been downloaded and stored\n        in the volume described by the volume_ref.\n        '
    image_volume = None
    try:
        if (not self.image_volume_cache.ensure_space(ctx, volume_ref['size'], volume_ref['host'])):
            LOG.warning(_LW('Unable to ensure space for image-volume in cache. Will skip creating entry for image %(image)s on host %(host)s.'), {'image': image_id, 'host': volume_ref['host']})
            return
        image_volume = self._clone_image_volume(ctx, volume_ref, image_meta)
        if (not image_volume):
            LOG.warning(_LW('Unable to clone image_volume for image %(image_id)s will not create cache entry.'), {'image_id': image_id})
            return
        self.image_volume_cache.create_cache_entry(ctx, image_volume, image_id, image_meta)
    except exception.CinderException as e:
        LOG.warning(_LW('Failed to create new image-volume cache entry. Error: %(exception)s'), {'exception': e})
        if image_volume:
            self.delete_volume(ctx, image_volume.id)
Create a new image-volume and cache entry for it.

This assumes that the image has already been downloaded and stored
in the volume described by the volume_ref.
def _create_image_cache_volume_entry(self, ctx, volume_ref, image_id, image_meta):
    'Create a new image-volume and cache entry for it.\n\n        This assumes that the image has already been downloaded and stored\n        in the volume described by the volume_ref.\n        '
    image_volume = None
    try:
        if (not self.image_volume_cache.ensure_space(ctx, volume_ref['size'], volume_ref['host'])):
            LOG.warning(_LW('Unable to ensure space for image-volume in cache. Will skip creating entry for image %(image)s on host %(host)s.'), {'image': image_id, 'host': volume_ref['host']})
            return
        image_volume = self._clone_image_volume(ctx, volume_ref, image_meta)
        if (not image_volume):
            LOG.warning(_LW('Unable to clone image_volume for image %(image_id)s will not create cache entry.'), {'image_id': image_id})
            return
        self.image_volume_cache.create_cache_entry(ctx, image_volume, image_id, image_meta)
    except exception.CinderException as e:
        LOG.warning(_LW('Failed to create new image-volume cache entry. Error: %(exception)s'), {'exception': e})
        if image_volume:
            self.delete_volume(ctx, image_volume.id)