summaryrefslogtreecommitdiff
path: root/utilities
diff options
context:
space:
mode:
authorJames Cammarata <jimi@sngx.net>2016-07-07 13:41:35 -0500
committerJames Cammarata <jimi@sngx.net>2016-07-07 13:41:50 -0500
commitb75f305079c89ba44358890db7145dd507b3dc92 (patch)
treee4a553a22055b8bbd6b69328ff9ed356775df511 /utilities
parent6b2ed8e468c79857e78b9df415b2aa9558b47049 (diff)
downloadansible-modules-core-b75f305079c89ba44358890db7145dd507b3dc92.tar.gz
Ensure async wrapper and status return consistent fields
Diffstat (limited to 'utilities')
-rw-r--r--utilities/logic/async_status.py8
-rw-r--r--utilities/logic/async_wrapper.py4
2 files changed, 8 insertions, 4 deletions
diff --git a/utilities/logic/async_status.py b/utilities/logic/async_status.py
index a35f3c0c..7c3d458f 100644
--- a/utilities/logic/async_status.py
+++ b/utilities/logic/async_status.py
@@ -76,11 +76,13 @@ def main():
# no remote kill mode currently exists, but probably should
# consider log_path + ".pid" file and also unlink that above
- data = file(log_path).read()
+ data = None
try:
+ data = file(log_path).read()
+ import q; q(data)
data = json.loads(data)
except Exception:
- if data == '':
+ if not data:
# file not written yet? That means it is running
module.exit_json(results_file=log_path, ansible_job_id=jid, started=1, finished=0)
else:
@@ -90,6 +92,8 @@ def main():
if not 'started' in data:
data['finished'] = 1
data['ansible_job_id'] = jid
+ elif 'finished' not in data:
+ data['finished'] = 0
# Fix error: TypeError: exit_json() keywords must be strings
data = dict([(str(k), v) for k, v in data.iteritems()])
diff --git a/utilities/logic/async_wrapper.py b/utilities/logic/async_wrapper.py
index a99c4f07..3a9b44d4 100644
--- a/utilities/logic/async_wrapper.py
+++ b/utilities/logic/async_wrapper.py
@@ -74,7 +74,7 @@ def _run_module(wrapped_cmd, jid, job_path):
tmp_job_path = job_path + ".tmp"
jobfile = open(tmp_job_path, "w")
- jobfile.write(json.dumps({ "started" : 1, "ansible_job_id" : jid }))
+ jobfile.write(json.dumps({ "started" : 1, "finished" : 0, "ansible_job_id" : jid }))
jobfile.close()
os.rename(tmp_job_path, job_path)
jobfile = open(tmp_job_path, "w")
@@ -161,7 +161,7 @@ if __name__ == '__main__':
# this probably could be done with some IPC later. Modules should always read
# the argsfile at the very first start of their execution anyway
notice("Return async_wrapper task started.")
- print(json.dumps({ "started" : 1, "ansible_job_id" : jid, "results_file" : job_path }))
+ print(json.dumps({ "started" : 1, "finished" : 0, "ansible_job_id" : jid, "results_file" : job_path }))
sys.stdout.flush()
time.sleep(1)
sys.exit(0)