mirror of
https://github.com/ansible/awx.git
synced 2026-02-27 15:58:45 -03:30
add migration to remove old start_args
This commit is contained in:
22
awx/main/migrations/0011_blank_start_args.py
Normal file
22
awx/main/migrations/0011_blank_start_args.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Python
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
# Django
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
# AWX
|
||||||
|
from awx.main.migrations import _migration_utils as migration_utils
|
||||||
|
from awx.main.migrations._reencrypt import blank_old_start_args
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('main', '0010_saved_launchtime_configs'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(migration_utils.set_current_apps_for_migrations, migrations.RunPython.noop),
|
||||||
|
migrations.RunPython(blank_old_start_args, migrations.RunPython.noop),
|
||||||
|
]
|
||||||
@@ -74,3 +74,20 @@ def _unified_jobs(apps):
|
|||||||
uj.start_args = decrypt_field(uj, 'start_args')
|
uj.start_args = decrypt_field(uj, 'start_args')
|
||||||
uj.start_args = encrypt_field(uj, 'start_args')
|
uj.start_args = encrypt_field(uj, 'start_args')
|
||||||
uj.save()
|
uj.save()
|
||||||
|
|
||||||
|
|
||||||
|
def blank_old_start_args(apps, schema_editor):
|
||||||
|
UnifiedJob = apps.get_model('main', 'UnifiedJob')
|
||||||
|
for uj in UnifiedJob.objects.defer('result_stdout_text').exclude(start_args='').iterator():
|
||||||
|
if uj.status in ['running', 'pending', 'new', 'waiting']:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
args_dict = decrypt_field(uj, 'start_args')
|
||||||
|
except ValueError:
|
||||||
|
args_dict = None
|
||||||
|
if args_dict == {}:
|
||||||
|
continue
|
||||||
|
if uj.start_args:
|
||||||
|
logger.debug('Blanking job args for %s', uj.pk)
|
||||||
|
uj.start_args = ''
|
||||||
|
uj.save()
|
||||||
|
|||||||
Reference in New Issue
Block a user