'Verify if we have a cache volume that we want.
If we don\'t, create one.
If we do, check if it\'s been updated:
* If so, delete it and recreate a new volume
* If not, we are good.
If it\'s out of date, delete it and create a new one.
After the function returns, there should be a cache volume available,
ready for cloning.'

def _verify_cache_volume(self, context, img_meta, img_service, cachevol_props):

    lcfg = self.configuration
    cache_dir = ('%s/' % lcfg.zfssa_cache_directory)
    cache_vol_obj = Volume()
    cache_vol_obj.provider_location = ((self.mount_path + '/') + cache_dir)
    cache_vol_obj._name_id = cachevol_props['id']
    cachevol_name = (cache_dir + cache_vol_obj.name)
    LOG.debug('Verifying    cache    volume    %s:', cachevol_name)
    try:
        cache_vol = self.zfssa.get_volume(cachevol_name)
    except exception.VolumeNotFound:
        LOG.debug('Cache    volume    not    found.    Creating    one...')
        return self._create_cache_volume(context, img_meta, img_service, cachevol_props)
    if ((cache_vol['updated_at'] != cachevol_props['updated_at']) or (cache_vol['image_id'] != cachevol_props['image_id'])):
        if (cache_vol['numclones'] > 0):
            exception_msg = (_('Cannot    delete    cache    volume:    %(cachevol_name)s.    It    was    updated    at    %(updated_at)s    and    currently    has    %(numclones)d    volume    instances.'), {'cachevol_name': cachevol_name, 'updated_at': cachevol_props['updated_at'], 'numclones': cache_vol['numclones']})
            LOG.error(exception_msg)
            raise exception.VolumeBackendAPIException(data=exception_msg)
        super(ZFSSANFSDriver, self).delete_volume(cache_vol_obj)
        return self._create_cache_volume(context, img_meta, img_service, cachevol_props)
    return cachevol_name
