mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 20:00:43 -03:30
Add --diff feature to API
This commit is contained in:
parent
a515a174e6
commit
d57bc3b59c
@ -2390,7 +2390,7 @@ class JobTemplateSerializer(JobTemplateMixin, UnifiedJobTemplateSerializer, JobO
|
||||
model = JobTemplate
|
||||
fields = ('*', 'host_config_key', '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',
|
||||
'ask_credential_on_launch', 'survey_enabled', 'become_enabled', 'diff_mode',
|
||||
'allow_simultaneous')
|
||||
|
||||
def get_related(self, obj):
|
||||
@ -2454,7 +2454,7 @@ class JobSerializer(UnifiedJobSerializer, JobOptionsSerializer):
|
||||
'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')
|
||||
'instance_group', 'diff_mode')
|
||||
|
||||
def get_related(self, obj):
|
||||
res = super(JobSerializer, self).get_related(obj)
|
||||
|
||||
24
awx/main/migrations/0044_v320_diff_mode.py
Normal file
24
awx/main/migrations/0044_v320_diff_mode.py
Normal file
@ -0,0 +1,24 @@
|
||||
# -*- 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),
|
||||
),
|
||||
]
|
||||
@ -60,6 +60,9 @@ class JobOptions(BaseModel):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
diff_mode = models.BooleanField(
|
||||
default=False,
|
||||
)
|
||||
job_type = models.CharField(
|
||||
max_length=64,
|
||||
choices=JOB_TYPE_CHOICES,
|
||||
@ -293,7 +296,7 @@ class JobTemplate(UnifiedJobTemplate, JobOptions, SurveyJobTemplateMixin, Resour
|
||||
'job_tags', 'extra_vars', 'launch_type', 'force_handlers',
|
||||
'skip_tags', 'start_at_task', 'become_enabled', 'labels',
|
||||
'survey_passwords', 'allow_simultaneous', 'timeout',
|
||||
'use_fact_cache',]
|
||||
'use_fact_cache', 'diff_mode',]
|
||||
|
||||
def resource_validation_data(self):
|
||||
'''
|
||||
|
||||
@ -1012,6 +1012,8 @@ class RunJob(BaseTask):
|
||||
args.append('--ask-pass')
|
||||
if job.become_enabled:
|
||||
args.append('--become')
|
||||
if job.diff_mode:
|
||||
args.append('--diff')
|
||||
if become_method:
|
||||
args.extend(['--become-method', become_method])
|
||||
if become_username:
|
||||
@ -2011,6 +2013,8 @@ class RunAdHocCommand(BaseTask):
|
||||
args.append('--forks=%d' % ad_hoc_command.forks)
|
||||
if ad_hoc_command.verbosity:
|
||||
args.append('-%s' % ('v' * min(5, ad_hoc_command.verbosity)))
|
||||
# if ad_hoc_command.diff_mode:
|
||||
# args.append('--diff')
|
||||
|
||||
if ad_hoc_command.extra_vars_dict:
|
||||
args.extend(['-e', json.dumps(ad_hoc_command.extra_vars_dict)])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user