Skip to content

Commit

Permalink
Fix test_rhcloud_inventory_api_e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
jameerpathan111 committed Jan 8, 2024
1 parent 814ae23 commit 5df4bf7
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,9 +1082,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(
self, satellite, activation_key, org, rhel_distro, register_insights=True, register=True
):
def configure_rhai_client(self, satellite, activation_key, org, rhel_distro):
"""Configures a Red Hat Access Insights service on the system by
installing the redhat-access-insights package and registering to the
service.
Expand All @@ -1096,12 +1094,6 @@ def configure_rhai_client(
:param register: Whether to register client to insights
:return: None
"""
if register:
# Install Satellite CA rpm
self.install_katello_ca(satellite)

self.register_contenthost(org, activation_key)

# Red Hat Insights requires RHEL 6/7/8 repo and it is not
# possible to sync the repo during the tests, Adding repo file.
distro_repo_map = {
Expand All @@ -1120,16 +1112,18 @@ def configure_rhai_client(
else:
self.create_custom_repos(**{rhel_distro: rhel_repo})

# Install insights-client rpm
if self.execute('yum install -y insights-client').status != 0:
raise ContentHostError('Unable to install insights-client rpm')

if register_insights:
# Register client
if self.execute('insights-client --register').status != 0:
raise ContentHostError('Unable to register client to Insights through Satellite')
if self.execute('insights-client --test-connection').status != 0:
raise ContentHostError('Test connection failed via insights.')
command = satellite.api.RegistrationCommand(
organization=org,
activation_keys=[activation_key.name],
update_packages=True,
setup_insights=True,
insecure=True,
force=True,
).create()
result = self.execute(command)
assert result.status == 0, f'Failed to register host: {result.stderr}'
result = self.execute('insights-client --test-connection')
assert result.status == 0, f'Test connection failed via insights: {result.stderr}'

def unregister_insights(self):
"""Unregister insights client.
Expand Down

0 comments on commit 5df4bf7

Please sign in to comment.