mirror of
https://github.com/ansible/awx.git
synced 2026-07-29 08:59:55 -02:30
replace all Job/JT relations with a single M2M credentials relation
Includes backwards compatibility for now-deprecated .credential, .vault_credential, and .extra_credentials This is a building block for multi-vault implementation and Alan's saved launch configurations (both coming soon) see: https://github.com/ansible/awx/issues/352 see: https://github.com/ansible/awx/issues/169
This commit is contained in:
12
awx/main/migrations/_multi_cred.py
Normal file
12
awx/main/migrations/_multi_cred.py
Normal file
@@ -0,0 +1,12 @@
|
||||
def migrate_to_multi_cred(app, schema_editor):
|
||||
Job = app.get_model('main', 'Job')
|
||||
JobTemplate = app.get_model('main', 'JobTemplate')
|
||||
|
||||
for cls in (Job, JobTemplate):
|
||||
for j in cls.objects.iterator():
|
||||
if j.credential:
|
||||
j.credentials.add(j.credential)
|
||||
if j.vault_credential:
|
||||
j.credentials.add(j.vault_credential)
|
||||
for cred in j.extra_credentials.all():
|
||||
j.credentials.add(cred)
|
||||
Reference in New Issue
Block a user