From 1a60dd89bdacf11ba0c5443887e1981bbd66c24b Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Thu, 29 Sep 2016 16:01:15 -0400 Subject: [PATCH 1/2] add back in removed method --- awx/main/tasks.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 07cd7df835..6dbac70108 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -305,6 +305,10 @@ class BaseTask(Task): logger.error('Failed to update %s after %d retries.', self.model._meta.object_name, _attempt) + def signal_finished(self, pk): + pass + # notify_task_runner(dict(complete=pk)) + def get_path_to(self, *args): ''' Return absolute path relative to this file. From 9cafebd8db85e2330b46cf2ddfff2cd1a661c93d Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Thu, 29 Sep 2016 16:17:05 -0400 Subject: [PATCH 2/2] remove job to jt allow_simultaneous dependency * Foreshadowing of what's to come with the task manager. When deciding on what job to run in our task manager, we can't depend on job template fields. Otherwise, this would cost us a query. --- awx/api/serializers.py | 3 ++- .../migrations/0037_job_allow_simultaneous.py | 19 +++++++++++++++++++ awx/main/models/jobs.py | 10 +++++----- 3 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 awx/main/migrations/0037_job_allow_simultaneous.py diff --git a/awx/api/serializers.py b/awx/api/serializers.py index db249bac9a..97191607b7 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -1953,7 +1953,8 @@ class JobSerializer(UnifiedJobSerializer, JobOptionsSerializer): model = Job fields = ('*', 'job_template', 'passwords_needed_to_start', 'ask_variables_on_launch', 'ask_limit_on_launch', 'ask_tags_on_launch', 'ask_skip_tags_on_launch', - 'ask_job_type_on_launch', 'ask_inventory_on_launch', 'ask_credential_on_launch') + 'ask_job_type_on_launch', 'ask_inventory_on_launch', 'ask_credential_on_launch', + 'allow_simultaneous',) def get_related(self, obj): res = super(JobSerializer, self).get_related(obj) diff --git a/awx/main/migrations/0037_job_allow_simultaneous.py b/awx/main/migrations/0037_job_allow_simultaneous.py new file mode 100644 index 0000000000..8a2e89df94 --- /dev/null +++ b/awx/main/migrations/0037_job_allow_simultaneous.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('main', '0036_v310_remove_tower_settings'), + ] + + operations = [ + migrations.AddField( + model_name='job', + name='allow_simultaneous', + field=models.BooleanField(default=False), + ), + ] diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index 1602872d2b..8fa9c8d176 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -138,6 +138,9 @@ class JobOptions(BaseModel): become_enabled = models.BooleanField( default=False, ) + allow_simultaneous = models.BooleanField( + default=False, + ) extra_vars_dict = VarsDictProperty('extra_vars', True) @@ -236,9 +239,6 @@ class JobTemplate(UnifiedJobTemplate, JobOptions, ResourceMixin): read_role = ImplicitRoleField( parent_role=['project.organization.auditor_role', 'inventory.organization.auditor_role', 'execute_role', 'admin_role'], ) - allow_simultaneous = models.BooleanField( - default=False, - ) @classmethod @@ -251,7 +251,7 @@ class JobTemplate(UnifiedJobTemplate, JobOptions, ResourceMixin): 'playbook', 'credential', 'cloud_credential', 'network_credential', 'forks', 'schedule', 'limit', 'verbosity', 'job_tags', 'extra_vars', 'launch_type', 'force_handlers', 'skip_tags', 'start_at_task', 'become_enabled', - 'labels', 'survey_passwords'] + 'labels', 'survey_passwords', 'allow_simultaneous',] def resource_validation_data(self): ''' @@ -616,7 +616,7 @@ class Job(UnifiedJob, JobOptions, JobNotificationMixin): if obj.job_template is not None and obj.inventory is not None: if obj.job_template == self.job_template and \ obj.inventory == self.inventory: - if self.job_template.allow_simultaneous: + if self.allow_simultaneous: return False if obj.launch_type == 'callback' and self.launch_type == 'callback' and \ obj.limit != self.limit: