From b5d0224720e5469550bbb37bbb7952d1825c5f6d Mon Sep 17 00:00:00 2001 From: adamscmRH Date: Fri, 7 Jul 2017 12:29:05 -0400 Subject: [PATCH] Adds on_launch --diff on api --- awx/api/serializers.py | 11 ++++---- awx/main/migrations/0038_v320_release.py | 20 +++++++++++++++ awx/main/migrations/0044_v320_diff_mode.py | 29 ---------------------- awx/main/models/jobs.py | 12 ++++++++- 4 files changed, 37 insertions(+), 35 deletions(-) delete mode 100644 awx/main/migrations/0044_v320_diff_mode.py diff --git a/awx/api/serializers.py b/awx/api/serializers.py index b7bca2329d..a28597ec6c 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -2388,7 +2388,7 @@ class JobTemplateSerializer(JobTemplateMixin, UnifiedJobTemplateSerializer, JobO class Meta: model = JobTemplate - fields = ('*', 'host_config_key', 'ask_variables_on_launch', 'ask_limit_on_launch', 'ask_tags_on_launch', + fields = ('*', 'host_config_key', 'ask_diff_mode_on_launch', 'ask_variables_on_launch', 'ask_limit_on_launch', 'ask_tags_on_launch', 'ask_skip_tags_on_launch', 'ask_job_type_on_launch', 'ask_verbosity_on_launch', 'ask_inventory_on_launch', 'ask_credential_on_launch', 'survey_enabled', 'become_enabled', 'diff_mode', 'allow_simultaneous') @@ -2438,6 +2438,7 @@ class JobTemplateSerializer(JobTemplateMixin, UnifiedJobTemplateSerializer, JobO class JobSerializer(UnifiedJobSerializer, JobOptionsSerializer): passwords_needed_to_start = serializers.ReadOnlyField() + ask_diff_mode_on_launch = serializers.ReadOnlyField() ask_variables_on_launch = serializers.ReadOnlyField() ask_limit_on_launch = serializers.ReadOnlyField() ask_skip_tags_on_launch = serializers.ReadOnlyField() @@ -2450,8 +2451,8 @@ class JobSerializer(UnifiedJobSerializer, JobOptionsSerializer): class Meta: 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', + fields = ('*', 'job_template', 'passwords_needed_to_start', 'ask_diff_mode_on_launch', + 'ask_variables_on_launch', 'ask_limit_on_launch', 'ask_tags_on_launch', 'ask_skip_tags_on_launch', 'ask_job_type_on_launch', 'ask_verbosity_on_launch', 'ask_inventory_on_launch', 'ask_credential_on_launch', 'allow_simultaneous', 'artifacts', 'scm_revision', 'instance_group', 'diff_mode') @@ -3058,12 +3059,12 @@ class JobLaunchSerializer(BaseSerializer): fields = ('can_start_without_user_input', 'passwords_needed_to_start', 'extra_vars', 'limit', 'job_tags', 'skip_tags', 'job_type', 'inventory', 'credential', 'extra_credentials', 'ask_variables_on_launch', 'ask_tags_on_launch', - 'ask_skip_tags_on_launch', 'ask_job_type_on_launch', 'ask_limit_on_launch', + 'ask_diff_mode_on_launch', 'ask_skip_tags_on_launch', 'ask_job_type_on_launch', 'ask_limit_on_launch', 'ask_verbosity_on_launch', 'ask_inventory_on_launch', 'ask_credential_on_launch', 'survey_enabled', 'variables_needed_to_start', 'credential_needed_to_start', 'inventory_needed_to_start', 'job_template_data', 'defaults', 'verbosity') read_only_fields = ( - 'ask_variables_on_launch', 'ask_limit_on_launch', 'ask_tags_on_launch', + 'ask_diff_mode_on_launch', 'ask_variables_on_launch', 'ask_limit_on_launch', 'ask_tags_on_launch', 'ask_skip_tags_on_launch', 'ask_job_type_on_launch', 'ask_verbosity_on_launch', 'ask_inventory_on_launch', 'ask_credential_on_launch',) extra_kwargs = { diff --git a/awx/main/migrations/0038_v320_release.py b/awx/main/migrations/0038_v320_release.py index 4ef84465e6..3a4191e913 100644 --- a/awx/main/migrations/0038_v320_release.py +++ b/awx/main/migrations/0038_v320_release.py @@ -331,4 +331,24 @@ class Migration(migrations.Migration): name='timeout', field=models.IntegerField(default=0, help_text='The amount of time (in seconds) to run before the task is canceled.', blank=True), ), + migrations.AddField( + model_name='job', + name='diff_mode', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='jobtemplate', + name='diff_mode', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='adhoccommand', + name='diff_mode', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='jobtemplate', + name='ask_diff_mode_on_launch', + field=models.BooleanField(default=False), + ), ] diff --git a/awx/main/migrations/0044_v320_diff_mode.py b/awx/main/migrations/0044_v320_diff_mode.py deleted file mode 100644 index f27f96f605..0000000000 --- a/awx/main/migrations/0044_v320_diff_mode.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('main', '0043_v320_instancegroups'), - ] - - operations = [ - migrations.AddField( - model_name='job', - name='diff_mode', - field=models.BooleanField(default=False), - ), - migrations.AddField( - model_name='jobtemplate', - name='diff_mode', - field=models.BooleanField(default=False), - ), - migrations.AddField( - model_name='adhoccommand', - name='diff_mode', - field=models.BooleanField(default=False), - ), - ] diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index 402411021b..8ed3771061 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -240,7 +240,10 @@ class JobTemplate(UnifiedJobTemplate, JobOptions, SurveyJobTemplateMixin, Resour blank=True, default='', ) - + ask_diff_mode_on_launch = models.BooleanField( + blank=True, + default=False, + ) ask_variables_on_launch = models.BooleanField( blank=True, default=False, @@ -364,6 +367,7 @@ class JobTemplate(UnifiedJobTemplate, JobOptions, SurveyJobTemplateMixin, Resour def _ask_for_vars_dict(self): return dict( + diff_mode=self.ask_diff_mode_on_launch, extra_vars=self.ask_variables_on_launch, limit=self.ask_limit_on_launch, job_tags=self.ask_tags_on_launch, @@ -525,6 +529,12 @@ class Job(UnifiedJob, JobOptions, SurveyJobMixin, JobNotificationMixin): h = hmac.new(settings.SECRET_KEY, self.created.isoformat(), digestmod=hashlib.sha1) return '%d-%s' % (self.pk, h.hexdigest()) + @property + def ask_diff_mode_on_launch(self): + if self.job_template is not None: + return self.job_template.ask_diff_mode_on_launch + return False + @property def ask_variables_on_launch(self): if self.job_template is not None: