mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 03:10:42 -03:30
Merge pull request #5012 from ansible/pu_iu_stdout_handling
Store project update and inventory update stdout in the database
This commit is contained in:
commit
ef51ee989d
@ -1314,6 +1314,15 @@ class RunProjectUpdate(BaseTask):
|
||||
'''
|
||||
return kwargs.get('private_data_files', {}).get('scm_credential', '')
|
||||
|
||||
def get_stdout_handle(self, instance):
|
||||
stdout_handle = super(RunProjectUpdate, self).get_stdout_handle(instance)
|
||||
|
||||
def raw_callback(data):
|
||||
instance_actual = ProjectUpdate.objects.get(pk=instance.pk)
|
||||
instance_actual.result_stdout_text += data
|
||||
instance_actual.save()
|
||||
return OutputEventFilter(stdout_handle, raw_callback=raw_callback)
|
||||
|
||||
def post_run_hook(self, instance, status, **kwargs):
|
||||
if instance.job_type == 'check' and status not in ('failed', 'canceled',):
|
||||
p = instance.project
|
||||
@ -1666,6 +1675,15 @@ class RunInventoryUpdate(BaseTask):
|
||||
args.append('--traceback')
|
||||
return args
|
||||
|
||||
def get_stdout_handle(self, instance):
|
||||
stdout_handle = super(RunInventoryUpdate, self).get_stdout_handle(instance)
|
||||
|
||||
def raw_callback(data):
|
||||
instance_actual = InventoryUpdate.objects.get(pk=instance.pk)
|
||||
instance_actual.result_stdout_text += data
|
||||
instance_actual.save()
|
||||
return OutputEventFilter(stdout_handle, raw_callback=raw_callback)
|
||||
|
||||
def build_cwd(self, inventory_update, **kwargs):
|
||||
return self.get_path_to('..', 'plugins', 'inventory')
|
||||
|
||||
|
||||
@ -766,9 +766,10 @@ class OutputEventFilter(object):
|
||||
|
||||
EVENT_DATA_RE = re.compile(r'\x1b\[K((?:[A-Za-z0-9+/=]+\x1b\[\d+D)+)\x1b\[K')
|
||||
|
||||
def __init__(self, fileobj=None, event_callback=None):
|
||||
def __init__(self, fileobj=None, event_callback=None, raw_callback=None):
|
||||
self._fileobj = fileobj
|
||||
self._event_callback = event_callback
|
||||
self._raw_callback = raw_callback
|
||||
self._counter = 1
|
||||
self._start_line = 0
|
||||
self._buffer = ''
|
||||
@ -781,6 +782,8 @@ class OutputEventFilter(object):
|
||||
if self._fileobj:
|
||||
self._fileobj.write(data)
|
||||
self._buffer += data
|
||||
if self._raw_callback:
|
||||
self._raw_callback(data)
|
||||
while True:
|
||||
match = self.EVENT_DATA_RE.search(self._buffer)
|
||||
if not match:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user