mirror of
https://github.com/ansible/awx.git
synced 2026-01-22 15:08:03 -03:30
Add migration for new cyberark plugin names
This commit is contained in:
parent
7deddabea6
commit
2d114a4d16
31
awx/main/migrations/0177_change_cyberark_plugin_names.py
Normal file
31
awx/main/migrations/0177_change_cyberark_plugin_names.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Generated by Django 3.2.16 on 2023-03-14 18:25
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
from awx.main.models import CredentialType
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
def update_cyberark_ccp_name(apps, schema_editor):
|
||||
CredentialType.setup_tower_managed_defaults(apps)
|
||||
aim_types = apps.get_model('main', 'CredentialType').objects.filter(namespace='aim').order_by('id')
|
||||
|
||||
if aim_types.count() == 2:
|
||||
original, renamed = aim_types.all()
|
||||
apps.get_model('main', 'Credential').objects.filter(credential_type_id=original.id).update(credential_type_id=renamed.id)
|
||||
original.delete()
|
||||
|
||||
def update_cyberark_conjur_name(apps, schema_editor):
|
||||
CredentialType.setup_tower_managed_defaults(apps)
|
||||
conjur_types = apps.get_model('main', 'CredentialType').objects.filter(namespace='conjur').order_by('id')
|
||||
|
||||
if conjur_types.count() == 2:
|
||||
original, renamed = conjur_types.all()
|
||||
apps.get_model('main', 'Credential').objects.filter(credential_type_id=original.id).update(credential_type_id=renamed.id)
|
||||
original.delete()
|
||||
|
||||
dependencies = [
|
||||
('main', '0176_inventorysource_scm_branch'),
|
||||
]
|
||||
|
||||
operations = [migrations.RunPython(update_cyberark_ccp_name), migrations.RunPython(update_cyberark_conjur_name)]
|
||||
Loading…
x
Reference in New Issue
Block a user