mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 07:26:03 -03:30
Working Redis, but need to switch out ZeroMQ.
This commit is contained in:
@@ -727,7 +727,9 @@ class ProjectUpdateView(GenericAPIView):
|
|||||||
return Response({}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
else:
|
else:
|
||||||
headers = {'Location': project_update.get_absolute_url()}
|
headers = {'Location': project_update.get_absolute_url()}
|
||||||
return Response(dict(project_update=project_update.id), status=status.HTTP_202_ACCEPTED, headers=headers)
|
return Response({'project_update': project_update.id},
|
||||||
|
headers=headers,
|
||||||
|
status=status.HTTP_202_ACCEPTED)
|
||||||
else:
|
else:
|
||||||
return self.http_method_not_allowed(request, *args, **kwargs)
|
return self.http_method_not_allowed(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|||||||
@@ -674,24 +674,41 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def signal_start(self, **kwargs):
|
def signal_start(self, **kwargs):
|
||||||
'''
|
"""Notify the task runner system to begin work on this task."""
|
||||||
Notify the task runner system to begin work on this task.
|
|
||||||
'''
|
# Sanity check: If we are running unit tests, then run synchronously.
|
||||||
from awx.main.tasks import notify_task_runner
|
|
||||||
if getattr(settings, 'CELERY_UNIT_TEST', False):
|
if getattr(settings, 'CELERY_UNIT_TEST', False):
|
||||||
return self.start(None, **kwargs)
|
return self.start(None, **kwargs)
|
||||||
|
|
||||||
|
# Sanity check: Are we able to start the job? If not, do not attempt
|
||||||
|
# to do so.
|
||||||
if not self.can_start:
|
if not self.can_start:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# Get any passwords or other data that are prerequisites to running
|
||||||
|
# the job.
|
||||||
needed = self.get_passwords_needed_to_start()
|
needed = self.get_passwords_needed_to_start()
|
||||||
opts = dict([(field, kwargs.get(field, '')) for field in needed])
|
opts = dict([(field, kwargs.get(field, '')) for field in needed])
|
||||||
if not all(opts.values()):
|
if not all(opts.values()):
|
||||||
return False
|
return False
|
||||||
extra_data = dict([(field, kwargs[field]) for field in kwargs if field not in needed])
|
extra_data = dict([(field, kwargs[field]) for field in kwargs
|
||||||
|
if field not in needed])
|
||||||
self.handle_extra_data(extra_data)
|
self.handle_extra_data(extra_data)
|
||||||
|
|
||||||
|
# Save the pending status, and inform the SocketIO listener.
|
||||||
self.update_fields(start_args=json.dumps(kwargs), status='pending')
|
self.update_fields(start_args=json.dumps(kwargs), status='pending')
|
||||||
self.socketio_emit_status("pending")
|
self.socketio_emit_status("pending")
|
||||||
|
|
||||||
|
# Each type of unified job has a different Task class; get the
|
||||||
|
# appropirate one.
|
||||||
task_type = get_type_for_model(self)
|
task_type = get_type_for_model(self)
|
||||||
# notify_task_runner.delay(dict(task_type=task_type, id=self.id, metadata=kwargs))
|
|
||||||
|
# Actually tell the task runner to run this task.
|
||||||
|
from awx.main.tasks import notify_task_runner
|
||||||
|
notify_task_runner.delay({'id': self.id, 'metadata': kwargs,
|
||||||
|
'task_type': task_type})
|
||||||
|
|
||||||
|
# Done!
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -112,7 +112,8 @@ def notify_task_runner(metadata_dict):
|
|||||||
|
|
||||||
@task(bind=True)
|
@task(bind=True)
|
||||||
def handle_work_error(self, task_id, subtasks=None):
|
def handle_work_error(self, task_id, subtasks=None):
|
||||||
print('Executing error task id %s, subtasks: %s' % (str(self.request.id), str(subtasks)))
|
print('Executing error task id %s, subtasks: %s' %
|
||||||
|
(str(self.request.id), str(subtasks)))
|
||||||
first_task = None
|
first_task = None
|
||||||
first_task_type = ''
|
first_task_type = ''
|
||||||
first_task_name = ''
|
first_task_name = ''
|
||||||
|
|||||||
Reference in New Issue
Block a user