mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
jobs.exit_success allow to check if a job has executed and exit successfully
This commit is contained in:
parent
c8b4f338d8
commit
7ba40c4f31
1 changed files with 42 additions and 0 deletions
|
@ -488,6 +488,48 @@ def print_job(jid, ext_source=None, outputter=None):
|
|||
return ret
|
||||
|
||||
|
||||
def exit_success(jid, ext_source=None):
|
||||
'''
|
||||
Check if a job has been executed and exit successfully
|
||||
|
||||
jid
|
||||
The jid to look up.
|
||||
ext_source
|
||||
The external job cache to use. Default: `None`.
|
||||
|
||||
CLI Example:
|
||||
.. code-block:: bash
|
||||
salt-run jobs.exit_success 20160520145827701627
|
||||
'''
|
||||
ret = {}
|
||||
mminion = salt.minion.MasterMinion(__opts__)
|
||||
returner = _get_returner((
|
||||
__opts__['ext_job_cache'],
|
||||
ext_source,
|
||||
__opts__['master_job_cache']
|
||||
))
|
||||
|
||||
try:
|
||||
data = list_job(
|
||||
jid,
|
||||
ext_source=ext_source
|
||||
)
|
||||
except TypeError:
|
||||
return ('Requested returner could not be loaded. '
|
||||
'No JIDs could be retrieved.')
|
||||
|
||||
returns = data.get('Result', {})
|
||||
|
||||
for minion in returns:
|
||||
minion_ret = returns[minion].get('return', {})
|
||||
if minion_ret['retcode'] == 0:
|
||||
ret[minion] = True
|
||||
else:
|
||||
ret[minion] = False
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def last_run(ext_source=None,
|
||||
outputter=None,
|
||||
metadata=None,
|
||||
|
|
Loading…
Add table
Reference in a new issue