Revert cmdmod refactor

This commit is contained in:
Mike Place 2014-10-06 10:46:12 -06:00
parent e0d5bbda57
commit 4ecacb166b
2 changed files with 107 additions and 2 deletions

View File

@ -20,10 +20,12 @@ from salt.exceptions import LoaderError
from salt.template import check_render_pipe_str
from salt.utils.decorators import Depends
import salt.utils.cmd
# 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.cmdmod
__salt__ = {
'cmd.run': salt.utils.cmd.run_quiet
'cmd.run': salt.modules.cmdmod._run_quiet
}
log = logging.getLogger(__name__)

View File

@ -463,6 +463,68 @@ def _run(cmd,
return ret
def _run_quiet(cmd,
cwd=None,
stdin=None,
runas=None,
shell=DEFAULT_SHELL,
python_shell=True,
env=None,
template=None,
umask=None,
timeout=None,
reset_system_locale=True,
saltenv='base'):
'''
Helper for running commands quietly for minion startup
'''
return _run(cmd,
runas=runas,
cwd=cwd,
stdin=stdin,
stderr=subprocess.STDOUT,
output_loglevel='quiet',
shell=shell,
python_shell=python_shell,
env=env,
template=template,
umask=umask,
timeout=timeout,
reset_system_locale=reset_system_locale,
saltenv=saltenv)['stdout']
def _run_all_quiet(cmd,
cwd=None,
stdin=None,
runas=None,
shell=DEFAULT_SHELL,
python_shell=True,
env=None,
template=None,
umask=None,
timeout=None,
reset_system_locale=True,
saltenv='base'):
'''
Helper for running commands quietly for minion startup.
Returns a dict of return data
'''
return _run(cmd,
runas=runas,
cwd=cwd,
stdin=stdin,
shell=shell,
python_shell=python_shell,
env=env,
output_loglevel='quiet',
template=template,
umask=umask,
timeout=timeout,
reset_system_locale=reset_system_locale,
saltenv=saltenv)
def run(cmd,
cwd=None,
stdin=None,
@ -900,6 +962,47 @@ def retcode(cmd,
return ret['retcode']
def _retcode_quiet(cmd,
cwd=None,
stdin=None,
runas=None,
shell=DEFAULT_SHELL,
python_shell=True,
env=None,
clean_env=False,
template=None,
umask=None,
output_loglevel='quiet',
quiet=True,
timeout=None,
reset_system_locale=True,
ignore_retcode=False,
saltenv='base',
use_vt=False,
**kwargs):
'''
Helper for running commands quietly for minion startup.
Returns same as retcode
'''
return retcode(cmd,
cwd=cwd,
stdin=stdin,
runas=runas,
shell=shell,
python_shell=python_shell,
env=env,
clean_env=clean_env,
template=template,
umask=umask,
output_loglevel=output_loglevel,
timeout=timeout,
reset_system_locale=reset_system_locale,
ignore_retcode=ignore_retcode,
saltenv=saltenv,
use_vt=use_vt,
**kwargs)
def script(source,
args=None,
cwd=None,