def revert_snapshot(name, snapshot=None, cleanup=False):
    ret = dict()
    domain = _get_domain(name)
    snapshots = domain.listAllSnapshots()

    _snapshots = list()
    for snap_obj in snapshots:
        _snapshots.append({'idx': _parse_snapshot_description(snap_obj, unix_time=True)['created'], 'ptr': snap_obj})
    snapshots = [w_ptr['ptr'] for w_ptr in sorted(_snapshots, key=lambda item: item['idx'], reverse=True)]
    del _snapshots

    if not snapshots:
        raise CommandExecutionError('No snapshots found')
    elif len(snapshots) == 1:
        raise CommandExecutionError('Cannot revert to itself: only one snapshot is available.')

    snap = None
    for p_snap in snapshots:
        if not snapshot:
            if p_snap.isCurrent() and snapshots[snapshots.index(p_snap) + 1:]:
                snap = snapshots[snapshots.index(p_snap) + 1:][0]
                break
        elif p_snap.getName() == snapshot:
            snap = p_snap
            break

    if not snap:
        raise CommandExecutionError(
            snapshot and 'Snapshot "{0}" not found'.format(snapshot) or 'No more previous snapshots available')
    elif snap.isCurrent():
        raise CommandExecutionError('Cannot revert to the currently running snapshot.')

    domain.revertToSnapshot(snap)
    ret['reverted'] = snap.getName()

    if cleanup:
        delete = list()
        for p_snap in snapshots:
            if p_snap.getName() != snap.getName():
                delete.append(p_snap.getName())
                p_snap.delete()
            else:
                break
        ret['deleted'] = delete
    else:
        ret['deleted'] = 'N/A'

    return ret


# Deprecated aliases
Moderation queue should display non-public, non-removed comments.
dataset/ETHPy150Open saltstack/salt/salt/modules/virt.py/revert_snapshot--crossover with--dataset/ETHPy150Open dcramer/django-compositepks/tests/regressiontests/comment_tests/tests/moderation_view_tests.py/ModerationQueueTests.testModerationQueueContents