properly copy parent roles when migrating v1 SSH creds to SSH + Vault

see: #7050
This commit is contained in:
Ryan Petrello 2017-07-13 15:02:55 -04:00
parent bc869284f7
commit 58abfc3fde

View File

@ -125,6 +125,11 @@ def migrate_to_v2_credentials(apps, schema_editor):
if any([getattr(cred, field) for field in ssh_type.defined_fields]):
new_cred.save(force_insert=True)
# copy parent roles
for role_type in ('read_role', 'admin_role', 'use_role'):
for role in getattr(cred, role_type).parents.all():
getattr(new_cred, role_type).parents.add(role)
for jt in job_templates:
jt.credential = new_cred
jt.save()