_modules/tmp_extfs.py
author Paul Tonelli <paul.tonelli@logilab.fr>
Wed, 13 Mar 2013 17:22:44 +0100
changeset 73 dae7b424b347
child 80 8b298d36c41b
permissions -rw-r--r--
code refactoring, begin to move parts of tmp_state resize state to tmp_extfs (module), should work *** corrections

# -*- coding: utf-8 -*-
# author: Paul Tonelli <ptonelli@logilab.fr>

import logging

log = logging.getLogger(__name__)

def resize(name, size='', options=''):
    return __salt__['cmd.run_all']('resize2fs -f '+ options + ' ' + name + ' '
            + size)

def fsck(name, options=''):
    return __salt__['cmd.run_all']('e2fsck -n -f ' + name)

def _has_enough_free_space(fs, space):
    info = os.statvfs(fs)
    free_space = (info.f_bavail * info.f_frsize)
    if free_space > space:
        return True
    return False