mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
allow smart inventory to be created
related to https://github.com/ansible/ansible-tower/issues/7261
This commit is contained in:
parent
f175fbba23
commit
eaddafc920
@ -370,7 +370,7 @@ class Inventory(CommonModelNameNotUnique, ResourceMixin):
|
|||||||
return self.groups.exclude(parents__pk__in=group_pks).distinct()
|
return self.groups.exclude(parents__pk__in=group_pks).distinct()
|
||||||
|
|
||||||
def clean_insights_credential(self):
|
def clean_insights_credential(self):
|
||||||
if self.kind == 'smart':
|
if self.kind == 'smart' and self.insights_credential:
|
||||||
raise ValidationError(_("Assignment not allowed for Smart Inventory"))
|
raise ValidationError(_("Assignment not allowed for Smart Inventory"))
|
||||||
if self.insights_credential and self.insights_credential.credential_type.kind != 'insights':
|
if self.insights_credential and self.insights_credential.credential_type.kind != 'insights':
|
||||||
raise ValidationError(_("Credential kind must be 'insights'."))
|
raise ValidationError(_("Credential kind must be 'insights'."))
|
||||||
|
@ -64,6 +64,12 @@ def test_invalid_clean_insights_credential():
|
|||||||
assert json.dumps(str(e.value)) == json.dumps(str([u"Credential kind must be 'insights'."]))
|
assert json.dumps(str(e.value)) == json.dumps(str([u"Credential kind must be 'insights'."]))
|
||||||
|
|
||||||
|
|
||||||
|
def test_valid_kind_clean_insights_credential():
|
||||||
|
inv = Inventory(kind='smart')
|
||||||
|
|
||||||
|
inv.clean_insights_credential()
|
||||||
|
|
||||||
|
|
||||||
def test_invalid_kind_clean_insights_credential():
|
def test_invalid_kind_clean_insights_credential():
|
||||||
cred_type = CredentialType.defaults['insights']()
|
cred_type = CredentialType.defaults['insights']()
|
||||||
insights_cred = Credential(credential_type=cred_type)
|
insights_cred = Credential(credential_type=cred_type)
|
||||||
|
Loading…
Reference in New Issue
Block a user