mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Make it possible to use prereq with test and saltmod state mods
this requisite passes a __prerequired__ kwarg so these need to support **kwargs for that reason. This also changes the comment for salt.function in test mode because it's inaccurate and doesn't make sense. Conflicts: - salt/states/test.py
This commit is contained in:
parent
ceb3f4d91f
commit
ed214c4cdb
3 changed files with 17 additions and 19 deletions
|
@ -427,7 +427,8 @@ def function(
|
|||
kwarg=None,
|
||||
timeout=None,
|
||||
batch=None,
|
||||
subset=None):
|
||||
subset=None,
|
||||
**kwargs): # pylint: disable=unused-argument
|
||||
'''
|
||||
Execute a single module function on a remote minion via salt or salt-ssh
|
||||
|
||||
|
@ -478,15 +479,15 @@ def function(
|
|||
|
||||
'''
|
||||
func_ret = {'name': name,
|
||||
'changes': {},
|
||||
'comment': '',
|
||||
'result': True}
|
||||
'changes': {},
|
||||
'comment': '',
|
||||
'result': True}
|
||||
if kwarg is None:
|
||||
kwarg = {}
|
||||
if isinstance(arg, six.string_types):
|
||||
func_ret['warnings'] = ['Please specify \'arg\' as a list, not a string. '
|
||||
'Modifying in place, but please update SLS file '
|
||||
'to remove this warning.']
|
||||
func_ret['warnings'] = [
|
||||
'Please specify \'arg\' as a list of arguments.'
|
||||
]
|
||||
arg = arg.split()
|
||||
|
||||
cmd_kw = {'arg': arg or [], 'kwarg': kwarg, 'ret': ret, 'timeout': timeout}
|
||||
|
@ -509,9 +510,8 @@ def function(
|
|||
|
||||
fun = name
|
||||
if __opts__['test'] is True:
|
||||
func_ret['comment'] = (
|
||||
'Function {0} will be executed on target {1} as test={2}'
|
||||
).format(fun, tgt, six.text_type(False))
|
||||
func_ret['comment'] = \
|
||||
'Function {0} would be executed on target {1}'.format(fun, tgt)
|
||||
func_ret['result'] = None
|
||||
return func_ret
|
||||
try:
|
||||
|
@ -751,7 +751,7 @@ def runner(name, **kwargs):
|
|||
return ret
|
||||
|
||||
|
||||
def parallel_runners(name, runners):
|
||||
def parallel_runners(name, runners, **kwargs): # pylint: disable=unused-argument
|
||||
'''
|
||||
Executes multiple runner modules on the master in parallel.
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ def nop(name, **kwargs):
|
|||
return succeed_without_changes(name)
|
||||
|
||||
|
||||
def succeed_without_changes(name, **kwargs):
|
||||
def succeed_without_changes(name, **kwargs): # pylint: disable=unused-argument
|
||||
'''
|
||||
Returns successful.
|
||||
|
||||
|
@ -85,7 +85,7 @@ def succeed_without_changes(name, **kwargs):
|
|||
return ret
|
||||
|
||||
|
||||
def fail_without_changes(name, **kwargs):
|
||||
def fail_without_changes(name, **kwargs): # pylint: disable=unused-argument
|
||||
'''
|
||||
Returns failure.
|
||||
|
||||
|
@ -108,7 +108,7 @@ def fail_without_changes(name, **kwargs):
|
|||
return ret
|
||||
|
||||
|
||||
def succeed_with_changes(name, **kwargs):
|
||||
def succeed_with_changes(name, **kwargs): # pylint: disable=unused-argument
|
||||
'''
|
||||
Returns successful and changes is not empty
|
||||
|
||||
|
@ -141,7 +141,7 @@ def succeed_with_changes(name, **kwargs):
|
|||
return ret
|
||||
|
||||
|
||||
def fail_with_changes(name, **kwargs):
|
||||
def fail_with_changes(name, **kwargs): # pylint: disable=unused-argument
|
||||
'''
|
||||
Returns failure and changes is not empty.
|
||||
|
||||
|
|
|
@ -175,13 +175,11 @@ class SaltmodTestCase(TestCase, LoaderModuleMockMixin):
|
|||
name = 'state'
|
||||
tgt = 'larry'
|
||||
|
||||
comt = ('Function state will be executed'
|
||||
' on target {0} as test=False'.format(tgt))
|
||||
|
||||
ret = {'name': name,
|
||||
'changes': {},
|
||||
'result': None,
|
||||
'comment': comt}
|
||||
'comment': 'Function state would be executed '
|
||||
'on target {0}'.format(tgt)}
|
||||
|
||||
with patch.dict(saltmod.__opts__, {'test': True}):
|
||||
self.assertDictEqual(saltmod.function(name, tgt), ret)
|
||||
|
|
Loading…
Add table
Reference in a new issue