Adding better virtual def and version

This commit is contained in:
Kurtis Velarde 2012-07-16 18:04:13 -07:00
parent 3e1f080978
commit cd12c37092

View File

@ -1,18 +1,18 @@
'''
Support for poudriere
Requires zfs and mkfile
'''
import os
import logging
import salt.utils
log = logging.getLogger(__name__)
def __virtual__():
'''
Module load on freebsd only
Module load on freebsd only and if poudriere installed
'''
if __grains__['os'] == 'FreeBSD':
if __grains__['os'] == 'FreeBSD' and salt.utils.which('poudriere'):
return 'poudriere'
else:
return False
@ -75,6 +75,18 @@ def parse_config(config_file=config_file):
return 'Could not find {0} on file system'.format(config_file)
def version():
'''
Return poudriere version
CLI Example::
salt '*' poudriere.version
'''
cmd = "poudriere version"
return __salt__['cmd.run'](cmd)
def list_jails():
'''
Return a list of current jails managed by poudriere
@ -169,8 +181,16 @@ def create_ports_tree():
def bulk_build(jail, pkg_file, keep=False):
'''bulk build on jail'''
'''
Run bulk build on poudriere server.
Return number of pkg builds, failures, and errors, on error dump to cli
CLI Example::
salt -N buildbox_group poudriere.bulk_build 90amd64 /root/pkg_list
'''
# make sure `pkg file` and jail is on file system
if not os.path.isfile(pkg_file):
return 'Could not find file {0} on filesystem'.format(pkg_file)