mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 01:21:21 +03:00
Add schedule based socket.io events for AC-1333
This commit is contained in:
parent
b6ba138522
commit
e72728b38c
@ -49,6 +49,11 @@ class JobEventNamespace(BaseNamespace):
|
||||
def recv_connect(self):
|
||||
print("Received client connect for job event namespace from %s" % str(self.environ['REMOTE_ADDR']))
|
||||
|
||||
class ScheduleNamespace(BaseNamespace):
|
||||
|
||||
def recv_connect(self):
|
||||
print("Received client connect for schedule namespace from %s" % str(self.environ['REMOTE_ADDR']))
|
||||
|
||||
class TowerSocket(object):
|
||||
|
||||
def __call__(self, environ, start_response):
|
||||
@ -57,7 +62,8 @@ class TowerSocket(object):
|
||||
if path.startswith('socket.io'):
|
||||
socketio_manage(environ, {'/socket.io/test': TestNamespace,
|
||||
'/socket.io/jobs': JobNamespace,
|
||||
'/socket.io/job_events': JobEventNamespace})
|
||||
'/socket.io/job_events': JobEventNamespace,
|
||||
'/socket.io/schedules': ScheduleNamespace})
|
||||
else:
|
||||
start_response('404 Not Found', [])
|
||||
return ['Tower version %s' % awx.__version__]
|
||||
|
@ -13,7 +13,7 @@ from django.utils.timezone import now, make_aware, get_default_timezone
|
||||
|
||||
# AWX
|
||||
from awx.main.models.base import *
|
||||
from awx.main.utils import ignore_inventory_computed_fields
|
||||
from awx.main.utils import ignore_inventory_computed_fields, emit_websocket_notification
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
logger = logging.getLogger('awx.main.models.schedule')
|
||||
@ -105,6 +105,7 @@ class Schedule(CommonModel):
|
||||
self.dtend = make_aware(datetime.datetime.strptime(until_date, "%Y%m%dT%H%M%SZ"), get_default_timezone())
|
||||
if 'count' in self.rrule.lower():
|
||||
self.dtend = future_rs[-1]
|
||||
emit_websocket_notification('/socket.io/schedules', 'schedule_change', dict(id=self.id))
|
||||
with ignore_inventory_computed_fields():
|
||||
self.unified_job_template.update_computed_fields()
|
||||
|
||||
|
@ -37,7 +37,7 @@ from django.utils.timezone import now
|
||||
|
||||
# AWX
|
||||
from awx.main.models import * # Job, JobEvent, ProjectUpdate, InventoryUpdate, Schedule, UnifiedJobTemplate
|
||||
from awx.main.utils import get_ansible_version, decrypt_field, update_scm_url, ignore_inventory_computed_fields
|
||||
from awx.main.utils import get_ansible_version, decrypt_field, update_scm_url, ignore_inventory_computed_fields, emit_websocket_notification
|
||||
|
||||
__all__ = ['RunJob', 'RunProjectUpdate', 'RunInventoryUpdate', 'handle_work_error', 'update_inventory_computed_fields']
|
||||
|
||||
@ -96,6 +96,7 @@ def tower_periodic_scheduler(self):
|
||||
new_unified_job.job_explanation = "Scheduled job could not start because it was not in the right state or required manual credentials"
|
||||
new_unified_job.save(update_fields=['job_status', 'job_explanation'])
|
||||
new_unified_job.socketio_emit_status("failed")
|
||||
emit_websocket_notification('/socket.io/schedules', 'schedule_change', dict(id=schedule.id))
|
||||
|
||||
@task()
|
||||
def notify_task_runner(metadata_dict):
|
||||
|
Loading…
Reference in New Issue
Block a user