mirror of
https://github.com/ansible/awx.git
synced 2026-03-06 03:01:06 -03:30
remove the legacy fact cleanup system template
see: https://github.com/ansible/tower/issues/1021
This commit is contained in:
18
awx/main/migrations/0037_v330_remove_legacy_fact_cleanup.py
Normal file
18
awx/main/migrations/0037_v330_remove_legacy_fact_cleanup.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
# AWX
|
||||
from awx.main.migrations._scan_jobs import remove_legacy_fact_cleanup
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('main', '0036_v330_credtype_remove_become_methods'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(remove_legacy_fact_cleanup),
|
||||
]
|
||||
@@ -102,3 +102,11 @@ def remove_scan_type_nodes(apps, schema_editor):
|
||||
prompts.pop('job_type')
|
||||
node.char_prompts = prompts
|
||||
node.save()
|
||||
|
||||
|
||||
def remove_legacy_fact_cleanup(apps, schema_editor):
|
||||
SystemJobTemplate = apps.get_model('main', 'SystemJobTemplate')
|
||||
for job in SystemJobTemplate.objects.filter(job_type='cleanup_facts').all():
|
||||
for sched in job.schedules.all():
|
||||
sched.delete()
|
||||
job.delete()
|
||||
|
||||
@@ -2278,19 +2278,14 @@ class RunSystemJob(BaseTask):
|
||||
json_vars = {}
|
||||
else:
|
||||
json_vars = json.loads(system_job.extra_vars)
|
||||
if 'days' in json_vars and system_job.job_type != 'cleanup_facts':
|
||||
if 'days' in json_vars:
|
||||
args.extend(['--days', str(json_vars.get('days', 60))])
|
||||
if 'dry_run' in json_vars and json_vars['dry_run'] and system_job.job_type != 'cleanup_facts':
|
||||
if 'dry_run' in json_vars and json_vars['dry_run']:
|
||||
args.extend(['--dry-run'])
|
||||
if system_job.job_type == 'cleanup_jobs':
|
||||
args.extend(['--jobs', '--project-updates', '--inventory-updates',
|
||||
'--management-jobs', '--ad-hoc-commands', '--workflow-jobs',
|
||||
'--notifications'])
|
||||
if system_job.job_type == 'cleanup_facts':
|
||||
if 'older_than' in json_vars:
|
||||
args.extend(['--older_than', str(json_vars['older_than'])])
|
||||
if 'granularity' in json_vars:
|
||||
args.extend(['--granularity', str(json_vars['granularity'])])
|
||||
except Exception:
|
||||
logger.exception(six.text_type("{} Failed to parse system job").format(system_job.log_format))
|
||||
return args
|
||||
|
||||
Reference in New Issue
Block a user