mirror of
https://github.com/ansible/awx.git
synced 2026-03-04 02:01:01 -03:30
Store project update and inventory update stdout in the database
So things work across the cluster
This commit is contained in:
@@ -1314,6 +1314,15 @@ class RunProjectUpdate(BaseTask):
|
|||||||
'''
|
'''
|
||||||
return kwargs.get('private_data_files', {}).get('scm_credential', '')
|
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):
|
def post_run_hook(self, instance, status, **kwargs):
|
||||||
if instance.job_type == 'check' and status not in ('failed', 'canceled',):
|
if instance.job_type == 'check' and status not in ('failed', 'canceled',):
|
||||||
p = instance.project
|
p = instance.project
|
||||||
@@ -1666,6 +1675,15 @@ class RunInventoryUpdate(BaseTask):
|
|||||||
args.append('--traceback')
|
args.append('--traceback')
|
||||||
return args
|
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):
|
def build_cwd(self, inventory_update, **kwargs):
|
||||||
return self.get_path_to('..', 'plugins', 'inventory')
|
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')
|
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._fileobj = fileobj
|
||||||
self._event_callback = event_callback
|
self._event_callback = event_callback
|
||||||
|
self._raw_callback = raw_callback
|
||||||
self._counter = 1
|
self._counter = 1
|
||||||
self._start_line = 0
|
self._start_line = 0
|
||||||
self._buffer = ''
|
self._buffer = ''
|
||||||
@@ -781,6 +782,8 @@ class OutputEventFilter(object):
|
|||||||
if self._fileobj:
|
if self._fileobj:
|
||||||
self._fileobj.write(data)
|
self._fileobj.write(data)
|
||||||
self._buffer += data
|
self._buffer += data
|
||||||
|
if self._raw_callback:
|
||||||
|
self._raw_callback(data)
|
||||||
while True:
|
while True:
|
||||||
match = self.EVENT_DATA_RE.search(self._buffer)
|
match = self.EVENT_DATA_RE.search(self._buffer)
|
||||||
if not match:
|
if not match:
|
||||||
|
|||||||
Reference in New Issue
Block a user