mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 23:37:39 -02:30
AC-1040 Unified jobs updates to get unit tests to pass (hopefully).
This commit is contained in:
@@ -32,6 +32,9 @@ from django.utils.timezone import now, make_aware, get_default_timezone
|
||||
# Django-JSONField
|
||||
from jsonfield import JSONField
|
||||
|
||||
# Django-Polymorphic
|
||||
from polymorphic import PolymorphicModel
|
||||
|
||||
# AWX
|
||||
from awx.main.models.base import *
|
||||
from awx.main.models.unified_jobs import *
|
||||
@@ -142,6 +145,7 @@ class JobTemplateBase(JobOptions):
|
||||
default='',
|
||||
)
|
||||
|
||||
class JobTemplateBaseMethods(object):
|
||||
|
||||
def create_job(self, **kwargs):
|
||||
'''
|
||||
@@ -185,7 +189,7 @@ class JobTemplateBase(JobOptions):
|
||||
|
||||
if getattr(settings, 'UNIFIED_JOBS_STEP') == 0:
|
||||
|
||||
class JobTemplate(CommonModel, JobTemplateBase):
|
||||
class JobTemplate(JobTemplateBaseMethods, CommonModel, JobTemplateBase):
|
||||
|
||||
class Meta:
|
||||
app_label = 'main'
|
||||
@@ -199,7 +203,7 @@ if getattr(settings, 'UNIFIED_JOBS_STEP') == 0:
|
||||
|
||||
if getattr(settings, 'UNIFIED_JOBS_STEP') in (0, 1):
|
||||
|
||||
class JobTemplateNew(UnifiedJobTemplate, JobTemplateBase):
|
||||
class JobTemplateNew(JobTemplateBaseMethods, UnifiedJobTemplate, JobTemplateBase):
|
||||
|
||||
class Meta:
|
||||
app_label = 'main'
|
||||
@@ -221,7 +225,8 @@ if getattr(settings, 'UNIFIED_JOBS_STEP') == 1:
|
||||
|
||||
if getattr(settings, 'UNIFIED_JOBS_STEP') == 2:
|
||||
|
||||
class JobTemplate(UnifiedJobTemplate, JobTemplateBase):
|
||||
#class JobTemplate(JobTemplateBase, UnifiedJobTemplate):
|
||||
class JobTemplate(JobTemplateBaseMethods, UnifiedJobTemplate, JobTemplateBase):
|
||||
|
||||
class Meta:
|
||||
app_label = 'main'
|
||||
@@ -253,6 +258,8 @@ class JobBase(JobOptions):
|
||||
through='JobHostSummary',
|
||||
)
|
||||
|
||||
class JobBaseMethods(object):
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('api:job_detail', args=(self.pk,))
|
||||
|
||||
@@ -405,7 +412,7 @@ class JobBase(JobOptions):
|
||||
|
||||
if getattr(settings, 'UNIFIED_JOBS_STEP') == 0:
|
||||
|
||||
class Job(CommonTask, JobBase):
|
||||
class Job(JobBaseMethods, CommonTask, JobBase):
|
||||
|
||||
LAUNCH_TYPE_CHOICES = [
|
||||
('manual', _('Manual')),
|
||||
@@ -439,7 +446,7 @@ if getattr(settings, 'UNIFIED_JOBS_STEP') == 0:
|
||||
|
||||
if getattr(settings, 'UNIFIED_JOBS_STEP') in (0, 1):
|
||||
|
||||
class JobNew(UnifiedJob, JobBase):
|
||||
class JobNew(JobBaseMethods, UnifiedJob, JobBase):
|
||||
|
||||
class Meta:
|
||||
app_label = 'main'
|
||||
@@ -468,7 +475,8 @@ if getattr(settings, 'UNIFIED_JOBS_STEP') == 1:
|
||||
|
||||
if getattr(settings, 'UNIFIED_JOBS_STEP') == 2:
|
||||
|
||||
class Job(UnifiedJob, JobBase):
|
||||
#class Job(JobBase, UnifiedJob):
|
||||
class Job(JobBaseMethods, UnifiedJob, JobBase):
|
||||
|
||||
class Meta:
|
||||
app_label = 'main'
|
||||
@@ -535,7 +543,7 @@ class JobHostSummaryBase(CreatedModifiedModel):
|
||||
update_fields = kwargs.get('update_fields', [])
|
||||
self.failed = bool(self.dark or self.failures)
|
||||
update_fields.append('failed')
|
||||
super(JobHostSummary, self).save(*args, **kwargs)
|
||||
super(JobHostSummaryBase, self).save(*args, **kwargs)
|
||||
self.update_host_last_job_summary()
|
||||
|
||||
def update_host_last_job_summary(self):
|
||||
@@ -887,7 +895,7 @@ class JobEventBase(CreatedModifiedModel):
|
||||
self.parent = self._find_parent()
|
||||
if 'parent' not in update_fields:
|
||||
update_fields.append('parent')
|
||||
super(JobEvent, self).save(*args, **kwargs)
|
||||
super(JobEventBase, self).save(*args, **kwargs)
|
||||
if post_process and not from_parent_update:
|
||||
self.update_parent_failed_and_changed()
|
||||
# FIXME: The update_hosts() call (and its queries) are the current
|
||||
|
||||
Reference in New Issue
Block a user