From 516e4785dd3a0276c31ec4c5cf9ce651fe5a7063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= Date: Tue, 24 May 2016 09:21:43 +0100 Subject: [PATCH 11/13] jobs.exit_success allow to check if a job has executed and exit successfully jobs.exit_success() now works parsing the results of jobs.lookup_id() --- salt/runners/jobs.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/salt/runners/jobs.py b/salt/runners/jobs.py index def40976fccf..6e37ab0d0ee6 100644 --- a/salt/runners/jobs.py +++ b/salt/runners/jobs.py @@ -488,6 +488,33 @@ 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 = dict() + + data = lookup_jid( + jid, + ext_source=ext_source + ) + + for minion in data: + if "retcode" in data[minion]: + ret[minion] = True if not data[minion]['retcode'] else False + + return ret + + def last_run(ext_source=None, outputter=None, metadata=None, -- 2.8.3