mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 01:21:21 +03:00
monkey-patch get_current_apps so that resolve_role_field works correctly
This commit is contained in:
parent
adc371fcf8
commit
2c1a39233e
@ -1,3 +1,4 @@
|
|||||||
|
from awx.main import utils
|
||||||
from awx.conf.migrations._reencrypt import decrypt_field
|
from awx.conf.migrations._reencrypt import decrypt_field
|
||||||
|
|
||||||
|
|
||||||
@ -23,17 +24,25 @@ def _notification_templates(apps):
|
|||||||
|
|
||||||
|
|
||||||
def _credentials(apps):
|
def _credentials(apps):
|
||||||
Credential = apps.get_model('main', 'Credential')
|
# this monkey-patch is necessary to make the implicit role generation save
|
||||||
for credential in Credential.objects.all():
|
# signal use the correct Role model (the version active at this point in
|
||||||
for field_name, value in credential.inputs.items():
|
# migration, not the one at HEAD)
|
||||||
if field_name in credential.credential_type.inputs.get('fields', []):
|
orig_current_apps = utils.get_current_apps
|
||||||
value = getattr(credential, field_name)
|
try:
|
||||||
if value.startswith('$encrypted$AESCBC$'):
|
utils.get_current_apps = lambda: apps
|
||||||
continue
|
for credential in apps.get_model('main', 'Credential').objects.all():
|
||||||
elif value.startswith('$encrypted$AES$'):
|
for field_name, value in credential.inputs.items():
|
||||||
value = decrypt_field(credential, field_name)
|
if field_name in credential.credential_type.inputs.get('fields', []):
|
||||||
credential.inputs[field_name] = value
|
value = getattr(credential, field_name)
|
||||||
credential.save()
|
if value.startswith('$encrypted$AESCBC$'):
|
||||||
|
continue
|
||||||
|
elif value.startswith('$encrypted$AES$'):
|
||||||
|
value = decrypt_field(credential, field_name)
|
||||||
|
credential.inputs[field_name] = value
|
||||||
|
credential.save()
|
||||||
|
finally:
|
||||||
|
utils.get_current_apps = orig_current_apps
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _unified_jobs(apps):
|
def _unified_jobs(apps):
|
||||||
|
Loading…
Reference in New Issue
Block a user