'Removes all cached image files above the cache\'s maximum
size. Returns a tuple containing the total number of cached
files removed and the total size of all pruned image files.'

def prune(self):

    max_size = CONF.image_cache_max_size
    current_size = self.driver.get_cache_size()
    if (max_size > current_size):
        LOG.debug('Image    cache    has    free    space,    skipping    prune...')
        return (0, 0)
    overage = (current_size - max_size)
    LOG.debug('Image    cache    currently    %(overage)d    bytes    over    max    size.    Starting    prune    to    max    size    of    %(max_size)d    ', {'overage': overage, 'max_size': max_size})
    total_bytes_pruned = 0
    total_files_pruned = 0
    entry = self.driver.get_least_recently_accessed()
    while (entry and (current_size > max_size)):
        (image_id, size) = entry
        LOG.debug("Pruning    '%(image_id)s'    to    free    %(size)d    bytes", {'image_id': image_id, 'size': size})
        self.driver.delete_cached_image(image_id)
        total_bytes_pruned = (total_bytes_pruned + size)
        total_files_pruned = (total_files_pruned + 1)
        current_size = (current_size - size)
        entry = self.driver.get_least_recently_accessed()
    LOG.debug('Pruning    finished    pruning.    Pruned    %(total_files_pruned)d    and    %(total_bytes_pruned)d.', {'total_files_pruned': total_files_pruned, 'total_bytes_pruned': total_bytes_pruned})
    return (total_files_pruned, total_bytes_pruned)
