From dea41b6126cf56c4b34ed41b90754b654ae82d4a Mon Sep 17 00:00:00 2001 From: Luke Sneeringer Date: Tue, 7 Oct 2014 13:24:52 -0500 Subject: [PATCH] Record stdout in the database. --- awx/main/models/unified_jobs.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/awx/main/models/unified_jobs.py b/awx/main/models/unified_jobs.py index 210d3d4b6b..27fea7cd73 100644 --- a/awx/main/models/unified_jobs.py +++ b/awx/main/models/unified_jobs.py @@ -9,7 +9,7 @@ import re import shlex import os import os.path -from cStringIO import StringIO +from StringIO import StringIO # PyYAML import yaml @@ -504,10 +504,19 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique # Sanity check: Has the job just completed? If so, mark down its # completion time, and record its output to the database. if self.status in ('successful', 'failed', 'error', 'canceled') and not self.finished: + # Record the `finished` time. self.finished = now() if 'finished' not in update_fields: update_fields.append('finished') + # Take the output from the filesystem and record it in the + # database. + stdout = self.result_stdout_raw_handle() + if not isinstance(stdout, StringIO): + self.result_stdout_text = stdout.read() + if 'result_stdout_text' not in update_fields: + update_fields.append('result_stdout_text') + # If we have a start and finished time, and haven't already calculated # out the time that elapsed, do so. if self.started and self.finished and not self.elapsed: