mirror of
https://github.com/ansible/awx.git
synced 2026-01-21 22:48:02 -03:30
remove backwords migraiton support for inv plugins
* Do not write out inventory source_vars to a file on disk as they _may_ contain sensitive information. This also removes support for backwards migrations. This is fine, backwards migration is really only useful during development.
This commit is contained in:
parent
dcf5917a4e
commit
03ad1aa141
@ -1,7 +1,6 @@
|
||||
# Generated by Django 2.2.11 on 2020-07-20 19:56
|
||||
|
||||
import logging
|
||||
import json
|
||||
import yaml
|
||||
|
||||
from django.db import migrations, models
|
||||
@ -12,7 +11,6 @@ from ._inventory_source_vars import FrozenInjectors
|
||||
|
||||
|
||||
logger = logging.getLogger('awx.main.migrations')
|
||||
BACKUP_FILENAME = '/tmp/tower_migration_inventory_source_vars.json'
|
||||
|
||||
|
||||
def _get_inventory_sources(InventorySource):
|
||||
@ -34,8 +32,6 @@ def inventory_source_vars_forward(apps, schema_editor):
|
||||
|
||||
if inv_source_obj.source in FrozenInjectors:
|
||||
source_vars_backup[inv_source_obj.id] = dict(inv_source_obj.source_vars_dict)
|
||||
with open(BACKUP_FILENAME, 'w') as fh:
|
||||
json.dump(source_vars_backup, fh)
|
||||
|
||||
injector = FrozenInjectors[inv_source_obj.source]()
|
||||
new_inv_source_vars = injector.inventory_as_dict(inv_source_obj, None)
|
||||
@ -43,21 +39,6 @@ def inventory_source_vars_forward(apps, schema_editor):
|
||||
inv_source_obj.save()
|
||||
|
||||
|
||||
def inventory_source_vars_backward(apps, schema_editor):
|
||||
InventorySource = apps.get_model("main", "InventorySource")
|
||||
try:
|
||||
with open(BACKUP_FILENAME, 'r') as fh:
|
||||
source_vars_backup = json.load(fh)
|
||||
except FileNotFoundError:
|
||||
print(f"Rollback file not found {BACKUP_FILENAME}")
|
||||
return
|
||||
|
||||
for inv_source_obj in _get_inventory_sources(InventorySource):
|
||||
if inv_source_obj.id in source_vars_backup:
|
||||
inv_source_obj.source_vars = source_vars_backup[inv_source_obj.id]
|
||||
inv_source_obj.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
@ -65,7 +46,7 @@ class Migration(migrations.Migration):
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(inventory_source_vars_forward, inventory_source_vars_backward,),
|
||||
migrations.RunPython(inventory_source_vars_forward),
|
||||
migrations.RemoveField(
|
||||
model_name='inventorysource',
|
||||
name='group_by',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user