'Checks image existence and validates the image metadata.
Returns: image metadata or None'

def _get_image_metadata(self, context, image_id, size):

    if (image_id is None):
        return None
    image_meta = self.image_service.show(context, image_id)
    if (image_meta['status'] != 'active'):
        msg = (_('Image    %(image_id)s    is    not    active.') % {'image_id': image_id})
        raise exception.InvalidInput(reason=msg)
    image_size = utils.as_int(image_meta['size'], quiet=False)
    image_size_in_gb = (((image_size + GB) - 1) // GB)
    if (image_size_in_gb > size):
        msg = _('Size    of    specified    image    %(image_size)sGB    is    larger    than    volume    size    %(volume_size)sGB.')
        msg = (msg % {'image_size': image_size_in_gb, 'volume_size': size})
        raise exception.InvalidInput(reason=msg)
    min_disk = image_meta.get('min_disk', 0)
    if (size < min_disk):
        msg = _('Volume    size    %(volume_size)sGB    cannot    be    smaller    than    the    image    minDisk    size    %(min_disk)sGB.')
        msg = (msg % {'volume_size': size, 'min_disk': min_disk})
        raise exception.InvalidInput(reason=msg)
    return image_meta
