diff --git a/awx/api/serializers.py b/awx/api/serializers.py
index bcee4ba225..55b3f299cb 100644
--- a/awx/api/serializers.py
+++ b/awx/api/serializers.py
@@ -144,7 +144,6 @@ SUMMARIZABLE_FK_FIELDS = {
'inventory_sources_with_failures',
'organization_id',
'kind',
- 'insights_credential_id',
),
'host': DEFAULT_SUMMARY_FIELDS,
'group': DEFAULT_SUMMARY_FIELDS,
@@ -171,7 +170,6 @@ SUMMARIZABLE_FK_FIELDS = {
'role': ('id', 'role_field'),
'notification_template': DEFAULT_SUMMARY_FIELDS,
'instance_group': ('id', 'name', 'is_container_group'),
- 'insights_credential': DEFAULT_SUMMARY_FIELDS,
'source_credential': DEFAULT_SUMMARY_FIELDS + ('kind', 'cloud', 'credential_type_id'),
'target_credential': DEFAULT_SUMMARY_FIELDS + ('kind', 'cloud', 'credential_type_id'),
'webhook_credential': DEFAULT_SUMMARY_FIELDS + ('kind', 'cloud', 'credential_type_id'),
@@ -1661,7 +1659,6 @@ class InventorySerializer(BaseSerializerWithVariables):
'has_inventory_sources',
'total_inventory_sources',
'inventory_sources_with_failures',
- 'insights_credential',
'pending_deletion',
)
@@ -1686,8 +1683,6 @@ class InventorySerializer(BaseSerializerWithVariables):
copy=self.reverse('api:inventory_copy', kwargs={'pk': obj.pk}),
)
)
- if obj.insights_credential:
- res['insights_credential'] = self.reverse('api:credential_detail', kwargs={'pk': obj.insights_credential.pk})
if obj.organization:
res['organization'] = self.reverse('api:organization_detail', kwargs={'pk': obj.organization.pk})
return res
@@ -2636,7 +2631,6 @@ class CredentialSerializer(BaseSerializer):
if self.instance and credential_type.pk != self.instance.credential_type.pk:
for related_objects in (
'ad_hoc_commands',
- 'insights_inventories',
'unifiedjobs',
'unifiedjobtemplates',
'projects',
diff --git a/awx/main/access.py b/awx/main/access.py
index 2e91de385b..4eb375ea75 100644
--- a/awx/main/access.py
+++ b/awx/main/access.py
@@ -867,13 +867,11 @@ class InventoryAccess(BaseAccess):
# If no data is specified, just checking for generic add permission?
if not data:
return Organization.accessible_objects(self.user, 'inventory_admin_role').exists()
- return self.check_related('organization', Organization, data, role_field='inventory_admin_role') and self.check_related(
- 'insights_credential', Credential, data, role_field='use_role'
- )
+ return self.check_related('organization', Organization, data, role_field='inventory_admin_role')
@check_superuser
def can_change(self, obj, data):
- return self.can_admin(obj, data) and self.check_related('insights_credential', Credential, data, obj=obj, role_field='use_role')
+ return self.can_admin(obj, data)
@check_superuser
def can_admin(self, obj, data):
diff --git a/awx/main/migrations/0149_remove_inventory_insights_credential.py b/awx/main/migrations/0149_remove_inventory_insights_credential.py
new file mode 100644
index 0000000000..0aeee723fd
--- /dev/null
+++ b/awx/main/migrations/0149_remove_inventory_insights_credential.py
@@ -0,0 +1,17 @@
+# Generated by Django 2.2.16 on 2021-06-16 21:00
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('main', '0148_unifiedjob_receptor_unit_id'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='inventory',
+ name='insights_credential',
+ ),
+ ]
diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py
index 004e43401a..f7bcb7853e 100644
--- a/awx/main/models/inventory.py
+++ b/awx/main/models/inventory.py
@@ -165,15 +165,6 @@ class Inventory(CommonModelNameNotUnique, ResourceMixin, RelatedJobsMixin):
'admin_role',
]
)
- insights_credential = models.ForeignKey(
- 'Credential',
- related_name='insights_inventories',
- 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,
- default=None,
- )
pending_deletion = models.BooleanField(
default=False,
editable=False,
@@ -368,13 +359,6 @@ class Inventory(CommonModelNameNotUnique, ResourceMixin, RelatedJobsMixin):
group_pks = self.groups.values_list('pk', flat=True)
return self.groups.exclude(parents__pk__in=group_pks).distinct()
- def clean_insights_credential(self):
- if self.kind == 'smart' and self.insights_credential:
- raise ValidationError(_("Assignment not allowed for Smart Inventory"))
- if self.insights_credential and self.insights_credential.credential_type.kind != 'insights':
- raise ValidationError(_("Credential kind must be 'insights'."))
- return self.insights_credential
-
@transaction.atomic
def schedule_deletion(self, user_id=None):
from awx.main.tasks import delete_inventory
diff --git a/awx/main/tests/functional/api/test_credential.py b/awx/main/tests/functional/api/test_credential.py
index 9fe6328633..3d277049ab 100644
--- a/awx/main/tests/functional/api/test_credential.py
+++ b/awx/main/tests/functional/api/test_credential.py
@@ -5,7 +5,7 @@ import pytest
from django.utils.encoding import smart_str
-from awx.main.models import AdHocCommand, Credential, CredentialType, Job, JobTemplate, Inventory, InventorySource, Project, WorkflowJobNode
+from awx.main.models import AdHocCommand, Credential, CredentialType, Job, JobTemplate, InventorySource, Project, WorkflowJobNode
from awx.main.utils import decrypt_field
from awx.api.versioning import reverse
@@ -857,7 +857,6 @@ def test_field_removal(put, organization, admin, credentialtype_ssh):
'relation, related_obj',
[
['ad_hoc_commands', AdHocCommand()],
- ['insights_inventories', Inventory()],
['unifiedjobs', Job()],
['unifiedjobtemplates', JobTemplate()],
['unifiedjobtemplates', InventorySource(source='ec2')],
diff --git a/awx/main/tests/functional/api/test_inventory.py b/awx/main/tests/functional/api/test_inventory.py
index 5aa6fb8992..fb4cc19cda 100644
--- a/awx/main/tests/functional/api/test_inventory.py
+++ b/awx/main/tests/functional/api/test_inventory.py
@@ -592,23 +592,3 @@ class TestControlledBySCM:
rando,
expect=403,
)
-
-
-@pytest.mark.django_db
-class TestInsightsCredential:
- def test_insights_credential(self, patch, insights_inventory, admin_user, insights_credential):
- patch(insights_inventory.get_absolute_url(), {'insights_credential': insights_credential.id}, admin_user, expect=200)
-
- def test_insights_credential_protection(self, post, patch, insights_inventory, alice, insights_credential):
- insights_inventory.organization.admin_role.members.add(alice)
- insights_inventory.admin_role.members.add(alice)
- post(
- reverse('api:inventory_list'),
- {"name": "test", "organization": insights_inventory.organization.id, "insights_credential": insights_credential.id},
- alice,
- expect=403,
- )
- patch(insights_inventory.get_absolute_url(), {'insights_credential': insights_credential.id}, alice, expect=403)
-
- def test_non_insights_credential(self, patch, insights_inventory, admin_user, scm_credential):
- patch(insights_inventory.get_absolute_url(), {'insights_credential': scm_credential.id}, admin_user, expect=400)
diff --git a/awx/main/tests/unit/models/test_inventory.py b/awx/main/tests/unit/models/test_inventory.py
index 04e20e2f03..34a8000665 100644
--- a/awx/main/tests/unit/models/test_inventory.py
+++ b/awx/main/tests/unit/models/test_inventory.py
@@ -1,15 +1,11 @@
import pytest
from unittest import mock
-import json
from django.core.exceptions import ValidationError
from awx.main.models import (
UnifiedJob,
InventoryUpdate,
- Inventory,
- Credential,
- CredentialType,
InventorySource,
)
@@ -39,42 +35,6 @@ def test__build_job_explanation():
)
-def test_valid_clean_insights_credential():
- cred_type = CredentialType.defaults['insights']()
- insights_cred = Credential(credential_type=cred_type)
- inv = Inventory(insights_credential=insights_cred)
-
- inv.clean_insights_credential()
-
-
-def test_invalid_clean_insights_credential():
- cred_type = CredentialType.defaults['scm']()
- cred = Credential(credential_type=cred_type)
- inv = Inventory(insights_credential=cred)
-
- with pytest.raises(ValidationError) as e:
- inv.clean_insights_credential()
-
- 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():
- cred_type = CredentialType.defaults['insights']()
- insights_cred = Credential(credential_type=cred_type)
- inv = Inventory(kind='smart', insights_credential=insights_cred)
-
- with pytest.raises(ValidationError) as e:
- inv.clean_insights_credential()
-
- assert json.dumps(str(e.value)) == json.dumps(str([u'Assignment not allowed for Smart Inventory']))
-
-
class TestControlledBySCM:
def test_clean_source_path_valid(self):
inv_src = InventorySource(source_path='/not_real/', source='scm')
diff --git a/awx/ui_next/src/screens/Credential/CredentialDetail/CredentialDetail.test.jsx b/awx/ui_next/src/screens/Credential/CredentialDetail/CredentialDetail.test.jsx
index 14e48a3569..5418f1f8da 100644
--- a/awx/ui_next/src/screens/Credential/CredentialDetail/CredentialDetail.test.jsx
+++ b/awx/ui_next/src/screens/Credential/CredentialDetail/CredentialDetail.test.jsx
@@ -67,7 +67,7 @@ describe('', () => {
test('should have proper number of delete detail requests', () => {
expect(
wrapper.find('DeleteButton').prop('deleteDetailsRequests')
- ).toHaveLength(6);
+ ).toHaveLength(5);
});
test('should render details', () => {
diff --git a/awx/ui_next/src/screens/Credential/CredentialList/CredentialList.test.jsx b/awx/ui_next/src/screens/Credential/CredentialList/CredentialList.test.jsx
index e07ab770c5..35428638f0 100644
--- a/awx/ui_next/src/screens/Credential/CredentialList/CredentialList.test.jsx
+++ b/awx/ui_next/src/screens/Credential/CredentialList/CredentialList.test.jsx
@@ -43,7 +43,7 @@ describe('', () => {
test('should have proper number of delete detail requests', () => {
expect(
wrapper.find('ToolbarDeleteButton').prop('deleteDetailsRequests')
- ).toHaveLength(6);
+ ).toHaveLength(5);
});
test('should fetch credentials from api and render the in the list', () => {
diff --git a/awx/ui_next/src/screens/Inventory/InventoryAdd/InventoryAdd.jsx b/awx/ui_next/src/screens/Inventory/InventoryAdd/InventoryAdd.jsx
index 3f4a5b53db..cad2449b3a 100644
--- a/awx/ui_next/src/screens/Inventory/InventoryAdd/InventoryAdd.jsx
+++ b/awx/ui_next/src/screens/Inventory/InventoryAdd/InventoryAdd.jsx
@@ -1,53 +1,26 @@
-import React, { useState, useEffect } from 'react';
+import React, { useState } from 'react';
import { useHistory } from 'react-router-dom';
import { PageSection, Card } from '@patternfly/react-core';
import { CardBody } from '../../../components/Card';
-import ContentLoading from '../../../components/ContentLoading';
-import { InventoriesAPI, CredentialTypesAPI } from '../../../api';
+import { InventoriesAPI } from '../../../api';
import InventoryForm from '../shared/InventoryForm';
function InventoryAdd() {
const [error, setError] = useState(null);
- const [isLoading, setIsLoading] = useState(true);
- const [credentialTypeId, setCredentialTypeId] = useState(null);
const history = useHistory();
- useEffect(() => {
- const loadData = async () => {
- try {
- const {
- data: { results: loadedCredentialTypeId },
- } = await CredentialTypesAPI.read({ kind: 'insights' });
- setCredentialTypeId(loadedCredentialTypeId[0].id);
- } catch (err) {
- setError(err);
- } finally {
- setIsLoading(false);
- }
- };
- loadData();
- }, [isLoading, credentialTypeId]);
-
const handleCancel = () => {
history.push('/inventories');
};
const handleSubmit = async values => {
- const {
- instanceGroups,
- organization,
- insights_credential,
- ...remainingValues
- } = values;
+ const { instanceGroups, organization, ...remainingValues } = values;
try {
const {
data: { id: inventoryId },
} = await InventoriesAPI.create({
organization: organization.id,
- insights_credential: insights_credential
- ? insights_credential.id
- : null,
...remainingValues,
});
if (instanceGroups) {
@@ -68,9 +41,6 @@ function InventoryAdd() {
}
};
- if (isLoading) {
- return ;
- }
return (
@@ -78,7 +48,6 @@ function InventoryAdd() {
diff --git a/awx/ui_next/src/screens/Inventory/InventoryAdd/InventoryAdd.test.jsx b/awx/ui_next/src/screens/Inventory/InventoryAdd/InventoryAdd.test.jsx
index 0c6953cd21..3f70a22eb2 100644
--- a/awx/ui_next/src/screens/Inventory/InventoryAdd/InventoryAdd.test.jsx
+++ b/awx/ui_next/src/screens/Inventory/InventoryAdd/InventoryAdd.test.jsx
@@ -7,7 +7,7 @@ import {
} from '../../../../testUtils/enzymeHelpers';
import { sleep } from '../../../../testUtils/testUtils';
-import { InventoriesAPI, CredentialTypesAPI } from '../../../api';
+import { InventoriesAPI } from '../../../api';
import InventoryAdd from './InventoryAdd';
jest.mock('../../../api');
@@ -18,16 +18,6 @@ describe('', () => {
beforeEach(async () => {
history = createMemoryHistory({ initialEntries: ['/inventories'] });
- CredentialTypesAPI.read.mockResolvedValue({
- data: {
- results: [
- {
- id: 14,
- name: 'insights',
- },
- ],
- },
- });
InventoriesAPI.create.mockResolvedValue({ data: { id: 13 } });
await act(async () => {
wrapper = mountWithContexts(, {
@@ -50,7 +40,6 @@ describe('', () => {
wrapper.find('InventoryForm').prop('onSubmit')({
name: 'new Foo',
organization: { id: 2 },
- insights_credential: { id: 47 },
instanceGroups,
});
});
@@ -58,7 +47,6 @@ describe('', () => {
expect(InventoriesAPI.create).toHaveBeenCalledWith({
name: 'new Foo',
organization: 2,
- insights_credential: 47,
});
instanceGroups.map(IG =>
expect(InventoriesAPI.associateInstanceGroup).toHaveBeenCalledWith(
diff --git a/awx/ui_next/src/screens/Inventory/InventoryDetail/InventoryDetail.test.jsx b/awx/ui_next/src/screens/Inventory/InventoryDetail/InventoryDetail.test.jsx
index c40021e35d..636f38ec0a 100644
--- a/awx/ui_next/src/screens/Inventory/InventoryDetail/InventoryDetail.test.jsx
+++ b/awx/ui_next/src/screens/Inventory/InventoryDetail/InventoryDetail.test.jsx
@@ -22,10 +22,6 @@ const mockInventory = {
copy: true,
adhoc: true,
},
- insights_credential: {
- id: 1,
- name: 'Foo',
- },
},
created: '2019-10-04T16:56:48.025455Z',
modified: '2019-10-04T16:56:48.025468Z',
@@ -43,7 +39,6 @@ const mockInventory = {
has_inventory_sources: false,
total_inventory_sources: 0,
inventory_sources_with_failures: 0,
- insights_credential: null,
pending_deletion: false,
};
diff --git a/awx/ui_next/src/screens/Inventory/InventoryEdit/InventoryEdit.jsx b/awx/ui_next/src/screens/Inventory/InventoryEdit/InventoryEdit.jsx
index abd0ee3f5f..535656bfab 100644
--- a/awx/ui_next/src/screens/Inventory/InventoryEdit/InventoryEdit.jsx
+++ b/awx/ui_next/src/screens/Inventory/InventoryEdit/InventoryEdit.jsx
@@ -3,7 +3,7 @@ import { useHistory } from 'react-router-dom';
import { object } from 'prop-types';
import { CardBody } from '../../../components/Card';
-import { InventoriesAPI, CredentialTypesAPI } from '../../../api';
+import { InventoriesAPI } from '../../../api';
import ContentLoading from '../../../components/ContentLoading';
import InventoryForm from '../shared/InventoryForm';
import { getAddedAndRemoved } from '../../../util/lists';
@@ -13,31 +13,19 @@ function InventoryEdit({ inventory }) {
const [error, setError] = useState(null);
const [associatedInstanceGroups, setInstanceGroups] = useState(null);
const [contentLoading, setContentLoading] = useState(true);
- const [credentialTypeId, setCredentialTypeId] = useState(null);
const history = useHistory();
const isMounted = useIsMounted();
useEffect(() => {
const loadData = async () => {
try {
- const [
- {
- data: { results: loadedInstanceGroups },
- },
- {
- data: { results: loadedCredentialTypeId },
- },
- ] = await Promise.all([
- InventoriesAPI.readInstanceGroups(inventory.id),
- CredentialTypesAPI.read({
- kind: 'insights',
- }),
- ]);
+ const {
+ data: { results: loadedInstanceGroups },
+ } = await InventoriesAPI.readInstanceGroups(inventory.id);
if (!isMounted.current) {
return;
}
setInstanceGroups(loadedInstanceGroups);
- setCredentialTypeId(loadedCredentialTypeId[0].id);
} catch (err) {
setError(err);
} finally {
@@ -48,7 +36,7 @@ function InventoryEdit({ inventory }) {
};
loadData();
/* eslint-disable-next-line react-hooks/exhaustive-deps */
- }, [inventory.id, contentLoading, inventory, credentialTypeId]);
+ }, [inventory.id, contentLoading, inventory]);
const handleCancel = () => {
const url =
@@ -60,17 +48,9 @@ function InventoryEdit({ inventory }) {
};
const handleSubmit = async values => {
- const {
- instanceGroups,
- insights_credential,
- organization,
- ...remainingValues
- } = values;
+ const { instanceGroups, organization, ...remainingValues } = values;
try {
await InventoriesAPI.update(inventory.id, {
- insights_credential: insights_credential
- ? insights_credential.id
- : null,
organization: organization.id,
...remainingValues,
});
@@ -109,7 +89,6 @@ function InventoryEdit({ inventory }) {
onSubmit={handleSubmit}
inventory={inventory}
instanceGroups={associatedInstanceGroups}
- credentialTypeId={credentialTypeId}
submitError={error}
/>
diff --git a/awx/ui_next/src/screens/Inventory/InventoryEdit/InventoryEdit.test.jsx b/awx/ui_next/src/screens/Inventory/InventoryEdit/InventoryEdit.test.jsx
index 276eecdb17..441050104c 100644
--- a/awx/ui_next/src/screens/Inventory/InventoryEdit/InventoryEdit.test.jsx
+++ b/awx/ui_next/src/screens/Inventory/InventoryEdit/InventoryEdit.test.jsx
@@ -7,7 +7,7 @@ import {
} from '../../../../testUtils/enzymeHelpers';
import { sleep } from '../../../../testUtils/testUtils';
-import { InventoriesAPI, CredentialTypesAPI } from '../../../api';
+import { InventoriesAPI } from '../../../api';
import InventoryEdit from './InventoryEdit';
jest.mock('../../../api');
@@ -28,10 +28,6 @@ const mockInventory = {
copy: true,
adhoc: true,
},
- insights_credential: {
- id: 1,
- name: 'Foo',
- },
},
created: '2019-10-04T16:56:48.025455Z',
modified: '2019-10-04T16:56:48.025468Z',
@@ -49,7 +45,6 @@ const mockInventory = {
has_inventory_sources: false,
total_inventory_sources: 0,
inventory_sources_with_failures: 0,
- insights_credential: null,
pending_deletion: false,
};
@@ -65,16 +60,6 @@ describe('', () => {
let history;
beforeEach(async () => {
- CredentialTypesAPI.read.mockResolvedValue({
- data: {
- results: [
- {
- id: 14,
- name: 'insights',
- },
- ],
- },
- });
InventoriesAPI.readInstanceGroups.mockResolvedValue({
data: {
results: associatedInstanceGroups,
@@ -117,7 +102,6 @@ describe('', () => {
name: 'Foo',
id: 13,
organization: { id: 1 },
- insights_credential: { id: 13 },
instanceGroups,
});
});
diff --git a/awx/ui_next/src/screens/Inventory/InventoryList/InventoryList.test.jsx b/awx/ui_next/src/screens/Inventory/InventoryList/InventoryList.test.jsx
index 6d4f9734a4..f33cb993d2 100644
--- a/awx/ui_next/src/screens/Inventory/InventoryList/InventoryList.test.jsx
+++ b/awx/ui_next/src/screens/Inventory/InventoryList/InventoryList.test.jsx
@@ -47,7 +47,6 @@ const mockInventories = [
has_inventory_sources: false,
total_inventory_sources: 0,
inventory_sources_with_failures: 0,
- insights_credential: null,
pending_deletion: false,
},
{
@@ -83,7 +82,6 @@ const mockInventories = [
has_inventory_sources: false,
total_inventory_sources: 0,
inventory_sources_with_failures: 0,
- insights_credential: null,
pending_deletion: false,
},
{
@@ -119,7 +117,6 @@ const mockInventories = [
has_inventory_sources: false,
total_inventory_sources: 0,
inventory_sources_with_failures: 0,
- insights_credential: null,
pending_deletion: false,
},
];
diff --git a/awx/ui_next/src/screens/Inventory/shared/InventoryForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventoryForm.jsx
index 078122baa3..85d3242766 100644
--- a/awx/ui_next/src/screens/Inventory/shared/InventoryForm.jsx
+++ b/awx/ui_next/src/screens/Inventory/shared/InventoryForm.jsx
@@ -1,7 +1,7 @@
import React, { useCallback } from 'react';
import { Formik, useField, useFormikContext } from 'formik';
import { t } from '@lingui/macro';
-import { func, number, shape } from 'prop-types';
+import { func, shape } from 'prop-types';
import { Form } from '@patternfly/react-core';
import { VariablesField } from '../../../components/CodeEditor';
import FormField, { FormSubmitError } from '../../../components/FormField';
@@ -9,13 +9,12 @@ import FormActionGroup from '../../../components/FormActionGroup';
import { required } from '../../../util/validators';
import InstanceGroupsLookup from '../../../components/Lookup/InstanceGroupsLookup';
import OrganizationLookup from '../../../components/Lookup/OrganizationLookup';
-import CredentialLookup from '../../../components/Lookup/CredentialLookup';
import {
FormColumnLayout,
FormFullWidthLayout,
} from '../../../components/FormLayout';
-function InventoryFormFields({ credentialTypeId, inventory }) {
+function InventoryFormFields({ inventory }) {
const { setFieldValue, setFieldTouched } = useFormikContext();
const [organizationField, organizationMeta, organizationHelpers] = useField(
'organization'
@@ -23,9 +22,6 @@ function InventoryFormFields({ credentialTypeId, inventory }) {
const [instanceGroupsField, , instanceGroupsHelpers] = useField(
'instanceGroups'
);
- const [insightsCredentialField, insightsCredentialMeta] = useField(
- 'insights_credential'
- );
const handleOrganizationUpdate = useCallback(
value => {
setFieldValue('organization', value);
@@ -34,14 +30,6 @@ function InventoryFormFields({ credentialTypeId, inventory }) {
[setFieldValue, setFieldTouched]
);
- const handleCredentialUpdate = useCallback(
- value => {
- setFieldValue('insights_credential', value);
- setFieldTouched('insights_credential', true, false);
- },
- [setFieldValue, setFieldTouched]
- );
-
return (
<>
-
{
@@ -116,10 +93,6 @@ function InventoryForm({
(inventory.summary_fields && inventory.summary_fields.organization) ||
null,
instanceGroups: instanceGroups || [],
- insights_credential:
- (inventory.summary_fields &&
- inventory.summary_fields.insights_credential) ||
- null,
};
return (
@@ -150,7 +123,6 @@ InventoryForm.propType = {
handleCancel: func.isRequired,
instanceGroups: shape(),
inventory: shape(),
- credentialTypeId: number.isRequired,
submitError: shape(),
};
diff --git a/awx/ui_next/src/screens/Inventory/shared/InventoryForm.test.jsx b/awx/ui_next/src/screens/Inventory/shared/InventoryForm.test.jsx
index ffc8f59f4d..adcadc7b05 100644
--- a/awx/ui_next/src/screens/Inventory/shared/InventoryForm.test.jsx
+++ b/awx/ui_next/src/screens/Inventory/shared/InventoryForm.test.jsx
@@ -25,10 +25,6 @@ const inventory = {
copy: true,
adhoc: true,
},
- insights_credential: {
- id: 1,
- name: 'Foo',
- },
},
created: '2019-10-04T16:56:48.025455Z',
modified: '2019-10-04T16:56:48.025468Z',
@@ -46,7 +42,6 @@ const inventory = {
has_inventory_sources: false,
total_inventory_sources: 0,
inventory_sources_with_failures: 0,
- insights_credential: null,
pending_deletion: false,
};
@@ -89,9 +84,6 @@ describe('', () => {
expect(wrapper.find('FormGroup[label="Description"]').length).toBe(1);
expect(wrapper.find('FormGroup[label="Organization"]').length).toBe(1);
expect(wrapper.find('FormGroup[label="Instance Groups"]').length).toBe(1);
- expect(wrapper.find('FormGroup[label="Insights Credential"]').length).toBe(
- 1
- );
expect(wrapper.find('VariablesField[label="Variables"]').length).toBe(1);
expect(wrapper.find('CodeEditor').prop('value')).toEqual('---');
});
@@ -107,12 +99,6 @@ describe('', () => {
wrapper.find('input#inventory-name').simulate('change', {
target: { value: 'new Foo', name: 'name' },
});
-
- wrapper.find('CredentialLookup').invoke('onBlur')();
- wrapper.find('CredentialLookup').invoke('onChange')({
- id: 10,
- name: 'credential',
- });
});
wrapper.update();
expect(wrapper.find('OrganizationLookup').prop('value')).toEqual({
@@ -122,10 +108,6 @@ describe('', () => {
expect(wrapper.find('input#inventory-name').prop('value')).toEqual(
'new Foo'
);
- expect(wrapper.find('CredentialLookup').prop('value')).toEqual({
- id: 10,
- name: 'credential',
- });
});
test('should call handleCancel when Cancel button is clicked', async () => {
diff --git a/awx/ui_next/src/screens/Inventory/shared/data.inventory.json b/awx/ui_next/src/screens/Inventory/shared/data.inventory.json
index e1b7a3bfa0..12da00ee53 100644
--- a/awx/ui_next/src/screens/Inventory/shared/data.inventory.json
+++ b/awx/ui_next/src/screens/Inventory/shared/data.inventory.json
@@ -91,6 +91,5 @@
"has_inventory_sources": false,
"total_inventory_sources": 0,
"inventory_sources_with_failures": 0,
- "insights_credential": null,
"pending_deletion": false
}
\ No newline at end of file
diff --git a/awx/ui_next/src/screens/Inventory/shared/data.smart_inventory.json b/awx/ui_next/src/screens/Inventory/shared/data.smart_inventory.json
index 204f616b7e..e34e569a52 100644
--- a/awx/ui_next/src/screens/Inventory/shared/data.smart_inventory.json
+++ b/awx/ui_next/src/screens/Inventory/shared/data.smart_inventory.json
@@ -90,6 +90,5 @@
"has_inventory_sources": false,
"total_inventory_sources": 0,
"inventory_sources_with_failures": 0,
- "insights_credential": null,
"pending_deletion": false
}
\ No newline at end of file
diff --git a/awx/ui_next/src/util/getRelatedResouceDeleteDetails.test.js b/awx/ui_next/src/util/getRelatedResouceDeleteDetails.test.js
index 48b20a0593..2f9f7695d7 100644
--- a/awx/ui_next/src/util/getRelatedResouceDeleteDetails.test.js
+++ b/awx/ui_next/src/util/getRelatedResouceDeleteDetails.test.js
@@ -33,9 +33,6 @@ describe('delete details', () => {
getRelatedResourceDeleteCounts(
relatedResourceDeleteRequests.credential({ id: 1 })
);
- expect(InventoriesAPI.read).toBeCalledWith({
- insights_credential: 1,
- });
expect(InventorySourcesAPI.read).toBeCalledWith({
credentials__id: 1,
});
diff --git a/awx/ui_next/src/util/getRelatedResourceDeleteDetails.js b/awx/ui_next/src/util/getRelatedResourceDeleteDetails.js
index 656236c936..a76922e905 100644
--- a/awx/ui_next/src/util/getRelatedResourceDeleteDetails.js
+++ b/awx/ui_next/src/util/getRelatedResourceDeleteDetails.js
@@ -58,13 +58,6 @@ export const relatedResourceDeleteRequests = {
request: () => ProjectsAPI.read({ credentials: selected.id }),
label: t`Projects`,
},
- {
- request: () =>
- InventoriesAPI.read({
- insights_credential: selected.id,
- }),
- label: t`Inventories`,
- },
{
request: () =>
InventorySourcesAPI.read({
diff --git a/awx_collection/plugins/modules/inventory.py b/awx_collection/plugins/modules/inventory.py
index 5778aadaba..1e00786b3a 100644
--- a/awx_collection/plugins/modules/inventory.py
+++ b/awx_collection/plugins/modules/inventory.py
@@ -57,10 +57,6 @@ options:
description:
- The host_filter field. Only useful when C(kind=smart).
type: str
- insights_credential:
- description:
- - Credentials to be used by hosts belonging to this inventory when accessing Red Hat Insights API.
- type: str
instance_groups:
description:
- list of Instance Groups for this Organization to run on.
@@ -110,7 +106,6 @@ def main():
kind=dict(choices=['', 'smart'], default=''),
host_filter=dict(),
instance_groups=dict(type="list", elements='str'),
- insights_credential=dict(),
state=dict(choices=['present', 'absent'], default='present'),
)
@@ -126,7 +121,6 @@ def main():
state = module.params.get('state')
kind = module.params.get('kind')
host_filter = module.params.get('host_filter')
- insights_credential = module.params.get('insights_credential')
# Attempt to look up the related items the user specified (these will fail the module if not found)
org_id = module.resolve_name_to_id('organizations', organization)
@@ -161,8 +155,6 @@ def main():
inventory_fields['description'] = description
if variables is not None:
inventory_fields['variables'] = json.dumps(variables)
- if insights_credential is not None:
- inventory_fields['insights_credential'] = module.resolve_name_to_id('credentials', insights_credential)
association_fields = {}
diff --git a/awx_collection/test/awx/test_inventory.py b/awx_collection/test/awx/test_inventory.py
index aa42fdbfc0..66653e088c 100644
--- a/awx_collection/test/awx/test_inventory.py
+++ b/awx_collection/test/awx/test_inventory.py
@@ -5,11 +5,10 @@ __metaclass__ = type
import pytest
from awx.main.models import Inventory, Credential
-from awx.main.tests.functional.conftest import insights_credential, credentialtype_insights
@pytest.mark.django_db
-def test_inventory_create(run_module, admin_user, organization, insights_credential):
+def test_inventory_create(run_module, admin_user, organization):
# Create an insights credential
result = run_module(
@@ -18,7 +17,6 @@ def test_inventory_create(run_module, admin_user, organization, insights_credent
'name': 'foo-inventory',
'organization': organization.name,
'variables': {'foo': 'bar', 'another-foo': {'barz': 'bar2'}},
- 'insights_credential': insights_credential.name,
'state': 'present',
},
admin_user,
@@ -27,7 +25,6 @@ def test_inventory_create(run_module, admin_user, organization, insights_credent
inv = Inventory.objects.get(name='foo-inventory')
assert inv.variables == '{"foo": "bar", "another-foo": {"barz": "bar2"}}'
- assert inv.insights_credential.name == insights_credential.name
result.pop('module_args', None)
result.pop('invocation', None)
diff --git a/awx_collection/tests/integration/targets/inventory/tasks/main.yml b/awx_collection/tests/integration/targets/inventory/tasks/main.yml
index 0906372c45..2026cb3e37 100644
--- a/awx_collection/tests/integration/targets/inventory/tasks/main.yml
+++ b/awx_collection/tests/integration/targets/inventory/tasks/main.yml
@@ -41,7 +41,6 @@
inventory:
name: "{{ inv_name1 }}"
organization: Default
- insights_credential: "{{ result.id }}"
instance_groups:
- "{{ group_name1 }}"
state: present
@@ -55,7 +54,6 @@
inventory:
name: "{{ result.id }}"
organization: Default
- insights_credential: "{{ cred_name1 }}"
state: present
register: result
diff --git a/awxkit/awxkit/api/pages/inventory.py b/awxkit/awxkit/api/pages/inventory.py
index b47be84372..42b1a5dd26 100644
--- a/awxkit/awxkit/api/pages/inventory.py
+++ b/awxkit/awxkit/api/pages/inventory.py
@@ -59,14 +59,12 @@ class Inventory(HasCopy, HasCreate, HasInstanceGroups, HasVariables, base.Base):
organization=organization.id,
)
- optional_fields = ('host_filter', 'insights_credential', 'kind', 'variables')
+ optional_fields = ('host_filter', 'kind', 'variables')
update_payload(payload, optional_fields, kwargs)
if 'variables' in payload and isinstance(payload.variables, dict):
payload.variables = json.dumps(payload.variables)
- if 'insights_credential' in payload and isinstance(payload.insights_credential, Credential):
- payload.insights_credential = payload.insights_credential.id
return payload
diff --git a/awxkit/awxkit/cli/options.py b/awxkit/awxkit/cli/options.py
index d5ad777feb..6253c28d19 100644
--- a/awxkit/awxkit/cli/options.py
+++ b/awxkit/awxkit/cli/options.py
@@ -45,7 +45,7 @@ def pk_or_name(v2, model_name, value, page=None):
identity = UNIQUENESS_RULES[model_name][-1]
# certain related fields follow a pattern of _ e.g.,
- # insights_credential, target_credential etc...
+ # target_credential etc...
if not page and '_' in model_name:
return pk_or_name(v2, model_name.split('_')[-1], value, page)