Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate quiet kwarg in cmd.run state module #55573

Merged
merged 7 commits into from
Dec 21, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Deprecate quiet kwarg in cmd.run state module
  • Loading branch information
Ch3LL committed Dec 20, 2019
commit ae0daef4fc07f9adcf5f0904fb2c1d74548cb7c4
4 changes: 4 additions & 0 deletions doc/topics/releases/neon.rst
Original file line number Diff line number Diff line change
@@ -147,6 +147,10 @@ Module Deprecations
- :py:func:`dockermod.load <salt.modules.dockermod.load>`
- :py:func:`dockermod.tag <salt.modules.dockermod.tag_>`

- The cmd state module has removed the ``quiet`` kwarg from the
:py:func:`cmd.run <salt.modules.cmdmod.run>` function. Please
set ``output_loglevel`` to ``quiet`` instead.

State Deprecations
------------------

20 changes: 0 additions & 20 deletions salt/states/cmd.py
Original file line number Diff line number Diff line change
@@ -796,13 +796,6 @@ def run(name,

.. versionadded:: 2018.3.0

quiet
This option no longer has any functionality and will be removed, please
set ``output_loglevel`` to ``quiet`` to suppress logging of the
command.

.. deprecated:: 2014.1.0

timeout
If the command has not terminated after timeout seconds, send the
subprocess sigterm, and if sigterm is ignored, follow up with sigkill
@@ -868,18 +861,6 @@ def run(name,
'result': False,
'comment': ''}

if 'quiet' in kwargs:
quiet = kwargs.pop('quiet')
msg = (
'The \'quiet\' argument for cmd.run has been deprecated since '
'2014.1.0 and will be removed as of the Neon release. Please set '
'\'output_loglevel\' to \'quiet\' instead.'
)
salt.utils.versions.warn_until('Neon', msg)
ret.setdefault('warnings', []).append(msg)
else:
quiet = False

test_name = None
if not isinstance(stateful, list):
stateful = stateful is True
@@ -906,7 +887,6 @@ def run(name,
'umask': umask,
'output_loglevel': output_loglevel,
'hide_output': hide_output,
'quiet': quiet,
'success_retcodes': success_retcodes})

cret = mod_run_check(cmd_kwargs, onlyif, unless, creates)
9 changes: 9 additions & 0 deletions tests/integration/states/test_cmd.py
Original file line number Diff line number Diff line change
@@ -39,6 +39,15 @@ def test_run_simple(self):
ret = self.run_state('cmd.run', name=self.__cmd, cwd=tempfile.gettempdir())
self.assertSaltTrueReturn(ret)

def test_run_output_loglevel(self):
'''
cmd.run with output_loglevel=quiet
'''
ret = self.run_state('cmd.run', name=self.__cmd,
cwd=tempfile.gettempdir(),
output_loglevel='quiet')
self.assertSaltTrueReturn(ret)

def test_test_run_simple(self):
'''
cmd.run test interface
33 changes: 33 additions & 0 deletions tests/unit/modules/test_cmdmod.py
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.unit import TestCase, skipIf
from tests.support.runtests import RUNTIME_VARS
from tests.support.helpers import TestsLoggingHandler
from tests.support.mock import (
mock_open,
Mock,
@@ -437,6 +438,38 @@ def test_run_all_output_encoding(self):

self.assertEqual(ret['stdout'], stdout)

def test_run_all_output_loglevel_quiet(self):
'''
Test that specifying quiet for loglevel
does not log the command.
'''
stdout = b'test'
proc = MagicMock(return_value=MockTimedProc(stdout=stdout))

msg = "INFO:Executing command 'some command' in directory"
with patch('salt.utils.timed_subprocess.TimedProc', proc):
with TestsLoggingHandler() as log_handler:
ret = cmdmod.run_all('some command', output_loglevel='quiet')
assert not [x for x in log_handler.messages if msg in x]

self.assertEqual(ret['stdout'], stdout)

def test_run_all_output_loglevel_debug(self):
'''
Test that specifying debug for loglevel
does log the command.
'''
stdout = b'test'
proc = MagicMock(return_value=MockTimedProc(stdout=stdout))

msg = "INFO:Executing command 'some command' in directory"
with patch('salt.utils.timed_subprocess.TimedProc', proc):
with TestsLoggingHandler() as log_handler:
ret = cmdmod.run_all('some command', output_loglevel='debug')
assert [x for x in log_handler.messages if msg in x]

self.assertEqual(ret['stdout'], stdout)

def test_run_chroot_mount(self):
'''
Test cmdmod.run_chroot mount / umount balance