1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

remove insights logic from backwards compat logic

* spelling fixes
This commit is contained in:
Chris Meyers 2017-05-26 09:58:20 -04:00
parent 2f43f0fe2b
commit b25b397e14
4 changed files with 10 additions and 7 deletions

View File

@ -246,7 +246,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='inventory',
name='insights_credential',
field=models.ForeignKey(related_name='insights_credential', default=None, blank=True, on_delete=models.deletion.SET_NULL, to='main.Credential', help_text='Credentials to be used by hosts belonging to this invtory when accessing Red Hat Insights API.', null=True),
field=models.ForeignKey(related_name='insights_credential', default=None, blank=True, on_delete=models.deletion.SET_NULL, to='main.Credential', help_text='Credentials to be used by hosts belonging to this inventory when accessing Red Hat Insights API.', null=True),
),
migrations.AlterField(
model_name='inventory',

View File

@ -49,6 +49,10 @@ def _populate_deprecated_cred_types(cred, kind):
return cred[kind]
def _get_insights_credential_type():
return CredentialType.objects.get(kind='insights')
def _is_insights_scm(apps, cred):
return apps.get_model('main', 'Credential').objects.filter(id=cred.id, projects__scm_type='insights').exists()
@ -74,9 +78,10 @@ def migrate_to_v2_credentials(apps, schema_editor):
if getattr(cred, 'vault_password', None):
data['vault_password'] = cred.vault_password
if _is_insights_scm(apps, cred):
data['is_insights'] = True
_disassociate_non_insights_projects(apps, cred)
credential_type = _populate_deprecated_cred_types(deprecated_cred, cred.kind) or CredentialType.from_v1_kind(cred.kind, data)
credential_type = _get_insights_credential_type()
else:
credential_type = _populate_deprecated_cred_types(deprecated_cred, cred.kind) or CredentialType.from_v1_kind(cred.kind, data)
defined_fields = credential_type.defined_fields
cred.credential_type = apps.get_model('main', 'CredentialType').objects.get(pk=credential_type.pk)

View File

@ -469,8 +469,6 @@ class CredentialType(CommonModelNameNotUnique):
requirements['kind'] = 'vault'
else:
requirements['kind'] = 'ssh'
elif kind == 'scm' and data.get('is_insights', False):
requirements['kind'] = 'insights'
elif kind in ('net', 'scm'):
requirements['kind'] = kind
elif kind in kind_choices:

View File

@ -146,7 +146,7 @@ class Inventory(CommonModelNameNotUnique, ResourceMixin):
insights_credential = models.ForeignKey(
'Credential',
related_name='insights_credential',
help_text=_('Credentials to be used by hosts belonging to this invtory when accessing Red Hat Insights API.'),
help_text=_('Credentials to be used by hosts belonging to this inventory when accessing Red Hat Insights API.'),
on_delete=models.SET_NULL,
blank=True,
null=True,
@ -357,7 +357,7 @@ class Inventory(CommonModelNameNotUnique, ResourceMixin):
def clean_insights_credential(self):
if self.insights_credential and self.insights_credential.credential_type.kind != 'insights':
raise ValidationError(_('Invalid CredentialType'))
raise ValidationError(_("Credential kind must be 'insights'."))
return self.insights_credential