diff --git a/pytest_fixtures/component/rh_cloud.py b/pytest_fixtures/component/rh_cloud.py index 03c563a44c7..5085754452d 100644 --- a/pytest_fixtures/component/rh_cloud.py +++ b/pytest_fixtures/component/rh_cloud.py @@ -33,7 +33,7 @@ def rhcloud_registered_hosts( ): """Fixture that registers content hosts to Satellite and Insights.""" for vm in mod_content_hosts: - vm.configure_rhai_client( + vm.configure_insights_client( satellite=module_target_sat, activation_key=rhcloud_activation_key, org=rhcloud_manifest_org, @@ -51,7 +51,7 @@ def rhel_insights_vm( rhel_contenthost.configure_rex( satellite=module_target_sat, org=rhcloud_manifest_org, register=False ) - rhel_contenthost.configure_rhai_client( + rhel_contenthost.configure_insights_client( satellite=module_target_sat, activation_key=rhcloud_activation_key, org=rhcloud_manifest_org, diff --git a/robottelo/hosts.py b/robottelo/hosts.py index f24280eaca9..ff8415d3107 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -1038,7 +1038,7 @@ def configure_rex(self, satellite, org, subnet_id=None, by_ip=True, register=Tru host.host_parameters_attributes = host_parameters host.update(['host_parameters_attributes']) - def configure_rhai_client( + def configure_insights_client( self, satellite, activation_key, org, rhel_distro, register_insights=True, register=True ): """Configures a Red Hat Access Insights service on the system by @@ -1052,18 +1052,7 @@ def configure_rhai_client( :param register: Whether to register client to insights :return: None """ - if register: - if not activation_key: - activation_key = satellite.api.ActivationKey( - content_view=org.default_content_view.id, - environment=org.library.id, - organization=org, - ).create() - self.register( - org, None, activation_key.name, satellite, setup_insights=register_insights - ) - - # Red Hat Insights requires RHEL 6/7/8 repo and it is not + # Red Hat Insights requires RHEL 6/7/8/9 repo and it is not # possible to sync the repo during the tests, Adding repo file. distro_repo_map = { 'rhel6': settings.repos.rhel6_os, @@ -1084,6 +1073,17 @@ def configure_rhai_client( # Ensure insights-client rpm is installed if self.execute('yum install -y insights-client').status != 0: raise ContentHostError('Unable to install insights-client rpm') + # attempt to register host + if register: + if not activation_key: + activation_key = satellite.api.ActivationKey( + content_view=org.default_content_view.id, + environment=org.library.id, + organization=org, + ).create() + self.register( + org, None, activation_key.name, satellite, setup_insights=register_insights + ) def unregister_insights(self): """Unregister insights client. diff --git a/tests/foreman/cli/test_http_proxy.py b/tests/foreman/cli/test_http_proxy.py index b5251e162af..c583ff8e638 100644 --- a/tests/foreman/cli/test_http_proxy.py +++ b/tests/foreman/cli/test_http_proxy.py @@ -122,7 +122,7 @@ def test_insights_client_registration_with_http_proxy( :customerscenario: true """ - rhel_contenthost.configure_rhai_client( + rhel_contenthost.configure_insights_client( module_target_sat, rhcloud_activation_key, rhcloud_manifest_org,