mirror of
https://github.com/ansible/awx.git
synced 2026-03-02 01:08:48 -03:30
add new credential types in a more stable way in migrations
instead of writing individual migrations for new built-in credential types, this change makes the "setup_tower_managed_defaults" function idempotent so that it only adds the credential types you're missing
This commit is contained in:
committed by
Matthew Jones
parent
d4fe60756b
commit
f4a252a331
@@ -3,6 +3,7 @@
|
||||
from collections import OrderedDict
|
||||
import functools
|
||||
import json
|
||||
import logging
|
||||
import operator
|
||||
import os
|
||||
import stat
|
||||
@@ -35,6 +36,8 @@ from awx.main.utils import encrypt_field
|
||||
|
||||
__all__ = ['Credential', 'CredentialType', 'V1Credential']
|
||||
|
||||
logger = logging.getLogger('awx.main.models.credential')
|
||||
|
||||
|
||||
class V1Credential(object):
|
||||
|
||||
@@ -468,6 +471,11 @@ class CredentialType(CommonModelNameNotUnique):
|
||||
for default in cls.defaults.values():
|
||||
default_ = default()
|
||||
if persisted:
|
||||
if CredentialType.objects.filter(name=default_.name, kind=default_.kind).count():
|
||||
continue
|
||||
logger.debug(_(
|
||||
"adding %s credential type" % default_.name
|
||||
))
|
||||
default_.save()
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user