def subvolume_deleted(name, device, commit=False, __dest=None):
    '''
    Makes sure that a btrfs subvolume is removed.

    name
        Name of the subvolume to remove

    device
        Device where to remove the subvolume

    commit
        Wait until the transaction is over

    '''
    ret = {
        'name': name,
        'result': False,
        'changes': {},
        'comment': [],
    }

    path = os.path.join(__dest, name)

    exists = __salt__['btrfs.subvolume_exists'](path)
    if not exists:
        ret['comment'].append('Subvolume {} already missing'.format(name))

    if __opts__['test']:
        ret['result'] = None
        if exists:
            ret['comment'].append('Subvolume {} will be removed'.format(name))
        return ret

    # If commit is set, we wait until all is over
    commit = 'after' if commit else None

    if not exists:
        try:
            __salt__['btrfs.subvolume_delete'](path, commit=commit)
        except CommandExecutionError:
            ret['comment'].append('Error removing subvolume {}'.format(name))
            return ret

        ret['changes'][name] = 'Removed subvolume {}'.format(name)

    ret['result'] = True
    return ret
def subvolume_deleted ( name , device , commit = False , __dest = None ) : ret = { 'name' : name , 'result' : False , 'changes' : { } , 'comment' : [ ] , } path = os . path . join ( __dest , name ) exists = __salt__ [ 'btrfs.subvolume_exists' ] ( path ) if not exists : ret [ 'comment' ] . append ( 'Subvolume {} already missing' . format ( name ) ) if __opts__ [ 'test' ] : ret [ 'result' ] = None if exists : ret [ 'comment' ] . append ( 'Subvolume {} will be removed' . format ( name ) ) return ret commit = 'after' if commit else None if not exists : try : __salt__ [ 'btrfs.subvolume_delete' ] ( path , commit = commit ) except CommandExecutionError : ret [ 'comment' ] . append ( 'Error removing subvolume {}' . format ( name ) ) return ret ret [ 'changes' ] [ name ] = 'Removed subvolume {}' . format ( name ) ret [ 'result' ] = True return ret
Makes sure that a btrfs subvolume is removed.

    name
        Name of the subvolume to remove

    device
        Device where to remove the subvolume

    commit
        Wait until the transaction is over