mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 22:37:41 -02:30
Implement timeout on other unified jobs/JTs.
This commit is contained in:
@@ -914,7 +914,7 @@ class ProjectSerializer(UnifiedJobTemplateSerializer, ProjectOptionsSerializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = Project
|
model = Project
|
||||||
fields = ('*', 'organization', 'scm_delete_on_next_update', 'scm_update_on_launch',
|
fields = ('*', 'organization', 'scm_delete_on_next_update', 'scm_update_on_launch',
|
||||||
'scm_update_cache_timeout') + \
|
'scm_update_cache_timeout', 'timeout') + \
|
||||||
('last_update_failed', 'last_updated') # Backwards compatibility
|
('last_update_failed', 'last_updated') # Backwards compatibility
|
||||||
read_only_fields = ('scm_delete_on_next_update',)
|
read_only_fields = ('scm_delete_on_next_update',)
|
||||||
|
|
||||||
@@ -1329,7 +1329,8 @@ class InventorySourceOptionsSerializer(BaseSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
fields = ('*', 'source', 'source_path', 'source_script', 'source_vars', 'credential',
|
fields = ('*', 'source', 'source_path', 'source_script', 'source_vars', 'credential',
|
||||||
'source_regions', 'instance_filters', 'group_by', 'overwrite', 'overwrite_vars')
|
'source_regions', 'instance_filters', 'group_by', 'overwrite', 'overwrite_vars',
|
||||||
|
'timeout')
|
||||||
|
|
||||||
def get_related(self, obj):
|
def get_related(self, obj):
|
||||||
res = super(InventorySourceOptionsSerializer, self).get_related(obj)
|
res = super(InventorySourceOptionsSerializer, self).get_related(obj)
|
||||||
@@ -2061,7 +2062,7 @@ class AdHocCommandSerializer(UnifiedJobSerializer):
|
|||||||
model = AdHocCommand
|
model = AdHocCommand
|
||||||
fields = ('*', 'job_type', 'inventory', 'limit', 'credential',
|
fields = ('*', 'job_type', 'inventory', 'limit', 'credential',
|
||||||
'module_name', 'module_args', 'forks', 'verbosity', 'extra_vars',
|
'module_name', 'module_args', 'forks', 'verbosity', 'extra_vars',
|
||||||
'become_enabled', '-unified_job_template', '-description')
|
'become_enabled', 'timeout', '-unified_job_template', '-description')
|
||||||
extra_kwargs = {
|
extra_kwargs = {
|
||||||
'name': {
|
'name': {
|
||||||
'read_only': True,
|
'read_only': True,
|
||||||
@@ -2159,7 +2160,7 @@ class SystemJobSerializer(UnifiedJobSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = SystemJob
|
model = SystemJob
|
||||||
fields = ('*', 'system_job_template', 'job_type', 'extra_vars')
|
fields = ('*', 'system_job_template', 'job_type', 'extra_vars', 'timeout')
|
||||||
|
|
||||||
def get_related(self, obj):
|
def get_related(self, obj):
|
||||||
res = super(SystemJobSerializer, self).get_related(obj)
|
res = super(SystemJobSerializer, self).get_related(obj)
|
||||||
|
|||||||
@@ -11,6 +11,21 @@ class Migration(migrations.Migration):
|
|||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='adhoccommand',
|
||||||
|
name='timeout',
|
||||||
|
field=models.PositiveIntegerField(default=0, blank=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='inventorysource',
|
||||||
|
name='timeout',
|
||||||
|
field=models.PositiveIntegerField(default=0, blank=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='inventoryupdate',
|
||||||
|
name='timeout',
|
||||||
|
field=models.PositiveIntegerField(default=0, blank=True),
|
||||||
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='job',
|
model_name='job',
|
||||||
name='timeout',
|
name='timeout',
|
||||||
@@ -21,4 +36,24 @@ class Migration(migrations.Migration):
|
|||||||
name='timeout',
|
name='timeout',
|
||||||
field=models.PositiveIntegerField(default=0, blank=True),
|
field=models.PositiveIntegerField(default=0, blank=True),
|
||||||
),
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='project',
|
||||||
|
name='timeout',
|
||||||
|
field=models.PositiveIntegerField(default=0, blank=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='projectupdate',
|
||||||
|
name='timeout',
|
||||||
|
field=models.PositiveIntegerField(default=0, blank=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='systemjob',
|
||||||
|
name='timeout',
|
||||||
|
field=models.PositiveIntegerField(default=0, blank=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='systemjobtemplate',
|
||||||
|
name='timeout',
|
||||||
|
field=models.PositiveIntegerField(default=0, blank=True),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -88,6 +88,10 @@ class AdHocCommand(UnifiedJob, JobNotificationMixin):
|
|||||||
blank=True,
|
blank=True,
|
||||||
default='',
|
default='',
|
||||||
)
|
)
|
||||||
|
timeout = models.PositiveIntegerField(
|
||||||
|
blank=True,
|
||||||
|
default=0,
|
||||||
|
)
|
||||||
|
|
||||||
extra_vars_dict = VarsDictProperty('extra_vars', True)
|
extra_vars_dict = VarsDictProperty('extra_vars', True)
|
||||||
|
|
||||||
|
|||||||
@@ -860,6 +860,10 @@ class InventorySourceOptions(BaseModel):
|
|||||||
default=False,
|
default=False,
|
||||||
help_text=_('Overwrite local variables from remote inventory source.'),
|
help_text=_('Overwrite local variables from remote inventory source.'),
|
||||||
)
|
)
|
||||||
|
timeout = models.PositiveIntegerField(
|
||||||
|
blank=True,
|
||||||
|
default=0,
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_ec2_region_choices(cls):
|
def get_ec2_region_choices(cls):
|
||||||
@@ -1084,7 +1088,8 @@ class InventorySource(UnifiedJobTemplate, InventorySourceOptions):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def _get_unified_job_field_names(cls):
|
def _get_unified_job_field_names(cls):
|
||||||
return ['name', 'description', 'source', 'source_path', 'source_script', 'source_vars', 'schedule',
|
return ['name', 'description', 'source', 'source_path', 'source_script', 'source_vars', 'schedule',
|
||||||
'credential', 'source_regions', 'instance_filters', 'group_by', 'overwrite', 'overwrite_vars']
|
'credential', 'source_regions', 'instance_filters', 'group_by', 'overwrite', 'overwrite_vars',
|
||||||
|
'timeout']
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
# If update_fields has been specified, add our field names to it,
|
# If update_fields has been specified, add our field names to it,
|
||||||
|
|||||||
@@ -1336,6 +1336,11 @@ class SystemJobOptions(BaseModel):
|
|||||||
default='',
|
default='',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
timeout = models.PositiveIntegerField(
|
||||||
|
blank=True,
|
||||||
|
default=0,
|
||||||
|
)
|
||||||
|
|
||||||
class SystemJobTemplate(UnifiedJobTemplate, SystemJobOptions):
|
class SystemJobTemplate(UnifiedJobTemplate, SystemJobOptions):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -1347,7 +1352,7 @@ class SystemJobTemplate(UnifiedJobTemplate, SystemJobOptions):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_unified_job_field_names(cls):
|
def _get_unified_job_field_names(cls):
|
||||||
return ['name', 'description', 'job_type', 'extra_vars']
|
return ['name', 'description', 'job_type', 'extra_vars', 'timeout']
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('api:system_job_template_detail', args=(self.pk,))
|
return reverse('api:system_job_template_detail', args=(self.pk,))
|
||||||
|
|||||||
@@ -106,6 +106,10 @@ class ProjectOptions(models.Model):
|
|||||||
default=None,
|
default=None,
|
||||||
on_delete=models.SET_NULL,
|
on_delete=models.SET_NULL,
|
||||||
)
|
)
|
||||||
|
timeout = models.PositiveIntegerField(
|
||||||
|
blank=True,
|
||||||
|
default=0,
|
||||||
|
)
|
||||||
|
|
||||||
def clean_scm_type(self):
|
def clean_scm_type(self):
|
||||||
return self.scm_type or ''
|
return self.scm_type or ''
|
||||||
@@ -251,7 +255,7 @@ class Project(UnifiedJobTemplate, ProjectOptions, ResourceMixin):
|
|||||||
def _get_unified_job_field_names(cls):
|
def _get_unified_job_field_names(cls):
|
||||||
return ['name', 'description', 'local_path', 'scm_type', 'scm_url',
|
return ['name', 'description', 'local_path', 'scm_type', 'scm_url',
|
||||||
'scm_branch', 'scm_clean', 'scm_delete_on_update',
|
'scm_branch', 'scm_clean', 'scm_delete_on_update',
|
||||||
'credential', 'schedule']
|
'credential', 'schedule', 'timeout']
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
new_instance = not bool(self.pk)
|
new_instance = not bool(self.pk)
|
||||||
|
|||||||
Reference in New Issue
Block a user