mirror of
https://github.com/ansible/awx.git
synced 2026-05-04 08:05:30 -02:30
generalize stdout event processing to emit events for *all* job types
* introduces three new models: `ProjectUpdateEvent`, `InventoryUpdateEvent`, and `SystemJobEvent` * simplifies the stdout callback management in `tasks.py` - now _all_ job run types capture and emit events to the callback receiver * supports stdout reconstruction from events for stdout downloads for _all_ job types * configures `ProjectUpdate` runs to configure the awx display callback (so we can capture real playbook events for `project_update.yml`) * ProjectUpdate, InventoryUpdate, and SystemJob runs no longer write text blobs to the deprecated `main_unifiedjob.result_stdout_text` column see: https://github.com/ansible/awx/issues/200
This commit is contained in:
@@ -4586,25 +4586,18 @@ class UnifiedJobStdout(RetrieveAPIView):
|
||||
tablename, related_name = {
|
||||
Job: ('main_jobevent', 'job_id'),
|
||||
AdHocCommand: ('main_adhoccommandevent', 'ad_hoc_command_id'),
|
||||
}.get(unified_job.__class__, (None, None))
|
||||
if tablename is None:
|
||||
# stdout job event reconstruction isn't supported
|
||||
# for certain job types (such as inventory syncs),
|
||||
# so just grab the raw stdout from the DB
|
||||
write_fd.write(unified_job.result_stdout_text)
|
||||
write_fd.close()
|
||||
else:
|
||||
cursor.copy_expert(
|
||||
"copy (select stdout from {} where {}={} order by start_line) to stdout".format(
|
||||
tablename,
|
||||
related_name,
|
||||
unified_job.id
|
||||
),
|
||||
write_fd
|
||||
)
|
||||
write_fd.close()
|
||||
subprocess.Popen("sed -i 's/\\\\r\\\\n/\\n/g' {}".format(unified_job.result_stdout_file),
|
||||
shell=True).wait()
|
||||
}.get(unified_job.__class__, ('main_genericcommandevent', 'unified_job_id'))
|
||||
cursor.copy_expert(
|
||||
"copy (select stdout from {} where {}={} order by start_line) to stdout".format(
|
||||
tablename,
|
||||
related_name,
|
||||
unified_job.id
|
||||
),
|
||||
write_fd
|
||||
)
|
||||
write_fd.close()
|
||||
subprocess.Popen("sed -i 's/\\\\r\\\\n/\\n/g' {}".format(unified_job.result_stdout_file),
|
||||
shell=True).wait()
|
||||
except Exception as e:
|
||||
return Response({"error": _("Error generating stdout download file: {}".format(e))})
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user