Quiet down minion startup

__salt__['cmd.run'] needs to be quiet when running inside the
grains so add a quiet flag to salt.modules.cmd._run and use it.

NOTE: This also quiets down the INFO messages displayed when
      running a command such as: salt-call -g
This commit is contained in:
Jeff Schroeder 2011-12-27 14:50:52 -08:00
parent 9cbb0485fe
commit 4314abd546
2 changed files with 12 additions and 4 deletions

View File

@ -23,7 +23,7 @@ import salt.utils
# Solve the Chicken and egg problem where grains need to run before any
# of the modules are loaded and are generally available for any usage.
import salt.modules.cmd
__salt__ = {'cmd.run': salt.modules.cmd.run}
__salt__ = {'cmd.run': salt.modules.cmd._run_quiet}
def _kernel():

View File

@ -22,16 +22,17 @@ DEFAULT_CWD = os.path.expanduser('~')
__outputter__ = {
'run': 'txt',
}
# TODO: Add a way to quiet down the logging here when salt-call -g is ran
def _run(cmd,
cwd=DEFAULT_CWD,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE):
stderr=subprocess.PIPE,
quiet=False):
'''
Do the DRY thing and only call subprocess.Popen() once
'''
ret = {}
log.info('Executing command {0} in directory {1}'.format(cmd, cwd))
if not quiet:
log.info('Executing command {0} in directory {1}'.format(cmd, cwd))
proc = subprocess.Popen(cmd,
cwd=cwd,
shell=True,
@ -47,6 +48,13 @@ def _run(cmd,
return ret
def _run_quiet(cmd, cwd=DEFAULT_CWD):
'''
Helper for running commands quietly for minion startup
'''
return _run(cmd, cwd, stderr=subprocess.STDOUT, quiet=True)['stdout']
def run(cmd, cwd=DEFAULT_CWD):
'''
Execute the passed command and return the output as a string