'Clean the image cache files in cache of space crunch.'

def _clean_image_cache(self):

    try:
        LOG.debug('Image    cache    cleaning    in    progress.')
        thres_size_perc_start = self.configuration.thres_avl_size_perc_start
        thres_size_perc_stop = self.configuration.thres_avl_size_perc_stop
        for share in getattr(self, '_mounted_shares', []):
            try:
                (total_size, total_avl) = self._get_capacity_info(share)
                avl_percent = int(((float(total_avl) / total_size) * 100))
                if (avl_percent <= thres_size_perc_start):
                    LOG.info('Cleaning    cache    for    share    %s.', share)
                    eligible_files = self._find_old_cache_files(share)
                    threshold_size = int(((thres_size_perc_stop * total_size) / 100))
                    bytes_to_free = int((threshold_size - total_avl))
                    LOG.debug('Files    to    be    queued    for    deletion    %s', eligible_files)
                    self._delete_files_till_bytes_free(eligible_files, share, bytes_to_free)
                else:
                    continue
            except Exception as e:
                LOG.warning('Exception    during    cache    cleaning    %(share)s.    Message    -    %(ex)s', {'share': share, 'ex': e})
                continue
    finally:
        LOG.debug('Image    cache    cleaning    done.')
        self.cleaning = False
