Skip to content

Instantly share code, notes, and snippets.

@kim0
Created February 9, 2015 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kim0/e9d442661295e5bac503 to your computer and use it in GitHub Desktop.
Save kim0/e9d442661295e5bac503 to your computer and use it in GitHub Desktop.
# Import Salt libs
import salt.utils
import salt.utils.decorators as decorators
import salt.modules.cmdmod as salt_cmd
log = logging.getLogger(__name__)
# Function alias to set mapping. Filled
# in later on.
__func_alias__ = {}
def __virtual__():
'''
Makes sure that ZFS is available.
'''
if _check_zfs():
return 'zfs'
return False
@decorators.memoize
def _check_zfs():
'''
Looks to see if zfs is present on the system.
'''
kernel_module_chk = {
'FreeBSD' : 'ls /tmp',
}
cmd = kernel_module_chk.get(__salt__['grains.get']('kernel'),'')
if cmd and __salt__['cmd.retcode'](cmd) == 0:
# Get the path to the zfs binary.
return salt.utils.which('zfs')
else:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment