From cd12c37092f56b483dccea51e103f9c5a90a79a6 Mon Sep 17 00:00:00 2001 From: Kurtis Velarde Date: Mon, 16 Jul 2012 18:04:13 -0700 Subject: [PATCH] Adding better virtual def and version --- salt/modules/poudriere.py | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/salt/modules/poudriere.py b/salt/modules/poudriere.py index 5eb2e4ff88..d267659ed5 100644 --- a/salt/modules/poudriere.py +++ b/salt/modules/poudriere.py @@ -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)