mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
directly call cmd.run_all
Apparently, you can't always use __salt__ in a util
This commit is contained in:
parent
e7f53a3df0
commit
2e68d35678
@ -66,6 +66,7 @@ import re
|
||||
import tempfile
|
||||
|
||||
# Import Salt libs
|
||||
import salt.modules.cmdmod
|
||||
import salt.utils.files
|
||||
import salt.utils.platform
|
||||
from salt.exceptions import CommandExecutionError
|
||||
@ -117,8 +118,8 @@ def _auditpol_cmd(cmd):
|
||||
Raises:
|
||||
CommandExecutionError: If the command encounters an error
|
||||
'''
|
||||
ret = __salt__['cmd.run_all'](cmd='auditpol {0}'.format(cmd),
|
||||
python_shell=True)
|
||||
ret = salt.modules.cmdmod.run_all(cmd='auditpol {0}'.format(cmd),
|
||||
python_shell=True)
|
||||
if ret['retcode'] == 0:
|
||||
return ret['stdout'].splitlines()
|
||||
|
||||
|
@ -55,7 +55,7 @@ class WinLgpoAuditpolTestCase(TestCase, LoaderModuleMockMixin):
|
||||
def test_set_setting(self):
|
||||
names = ['Credential Validation', 'IPsec Driver', 'File System', 'SAM']
|
||||
mock_set = MagicMock(return_value={'retcode': 0, 'stdout': 'Success'})
|
||||
with patch.dict(win_lgpo_auditpol.__salt__, {'cmd.run_all': mock_set}):
|
||||
with patch.object(salt.modules.cmdmod, 'run_all', mock_set):
|
||||
with patch.object(win_lgpo_auditpol, '_get_valid_names',
|
||||
return_value=[k.lower() for k in names]):
|
||||
for name in names:
|
||||
|
Loading…
Reference in New Issue
Block a user