Skip to content

Commit

Permalink
Review comment addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
jyejare committed Nov 19, 2024
1 parent 60620c5 commit aa21a03
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
6 changes: 6 additions & 0 deletions conf/content_host.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ content_host:
deploy_rhel_version: '9'
target_memory: 1536 MiB
target_cores: 1
rhel10_fips:
vm:
workflow: deploy-template
deploy_rhel_version: '10'
target_memory: 1536 MiB
target_cores: 1
centos7:
vm:
workflow: deploy-centos
Expand Down
20 changes: 3 additions & 17 deletions pytest_fixtures/core/contenthosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,19 @@ def host_conf(request):
deploy_kwargs = settings.content_host.get(_rhelver).to_dict().get('vm', {})
if network := params.get('network'):
deploy_kwargs.update({'deploy_network_type': network})
# Post_deploy_workflow_runs to be run in ContentHost.setup method
if 'fips' in params.get('rhel_version'):
deploy_kwargs.update({'fips': True})
conf.update(deploy_kwargs)
return conf


def run_post_deployments(request, host):
"""Execute post deploy"""
params = {}
if hasattr(request, 'param'):
params = request.param
if 'fips' in params.get('rhel_version'):
Broker().execute(workflow='enable-fips', target_host=host.name)


@pytest.fixture
def rhel_contenthost(request):
"""A function-level fixture that provides a content host object parametrized"""
# Request should be parametrized through pytest_fixtures.fixture_markers
# unpack params dict
with Broker(**host_conf(request), host_class=ContentHost) as host:
run_post_deployments(request, host)
yield host


Expand All @@ -66,7 +59,6 @@ def module_rhel_contenthost(request):
# Request should be parametrized through pytest_fixtures.fixture_markers
# unpack params dict
with Broker(**host_conf(request), host_class=ContentHost) as host:
run_post_deployments(request, host)
yield host


Expand Down Expand Up @@ -123,8 +115,6 @@ def rhel9_contenthost(request):
def content_hosts(request):
"""A function-level fixture that provides two rhel content hosts object"""
with Broker(**host_conf(request), host_class=ContentHost, _count=2) as hosts:
for host in hosts:
run_post_deployments(request, host)
hosts[0].set_infrastructure_type('physical')
yield hosts

Expand All @@ -133,8 +123,6 @@ def content_hosts(request):
def mod_content_hosts(request):
"""A module-level fixture that provides two rhel content hosts object"""
with Broker(**host_conf(request), host_class=ContentHost, _count=2) as hosts:
for host in hosts:
run_post_deployments(request, host)
hosts[0].set_infrastructure_type('physical')
yield hosts

Expand Down Expand Up @@ -187,7 +175,6 @@ def cockpit_host(class_target_sat, class_org, rhel_contenthost):
def rex_contenthost(request, module_org, target_sat, module_ak_with_cv):
request.param['no_containers'] = True
with Broker(**host_conf(request), host_class=ContentHost) as host:
run_post_deployments(request, host)
repo = settings.repos['SATCLIENT_REPO'][f'RHEL{host.os_version.major}']
host.register(
module_org, None, module_ak_with_cv.name, target_sat, repo_data=f'repo={repo}'
Expand All @@ -200,7 +187,6 @@ def rex_contenthosts(request, module_org, target_sat, module_ak_with_cv):
request.param['no_containers'] = True
with Broker(**host_conf(request), host_class=ContentHost, _count=2) as hosts:
for host in hosts:
run_post_deployments(request, host)
repo = settings.repos['SATCLIENT_REPO'][f'RHEL{host.os_version.major}']
host.register(
module_org, None, module_ak_with_cv.name, target_sat, repo_data=f'repo={repo}'
Expand Down
8 changes: 8 additions & 0 deletions robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def __init__(self, hostname, auth=None, **kwargs):
self._satellite = kwargs.get('satellite')
self.ipv6 = kwargs.get('ipv6', settings.server.is_ipv6)
self.blank = kwargs.get('blank', False)
self.fips = kwargs.get('fips', False)
super().__init__(hostname=hostname, **kwargs)

@classmethod
Expand Down Expand Up @@ -336,10 +337,17 @@ def clean_cached_properties(self):
with contextlib.suppress(KeyError): # ignore if property is not cached
del self.__dict__[name]

def enable_fips(self):
logger.debug(f'Enabling FIPS on the host {self.name}')
Broker().execute(workflow='enable-fips', target_host=self.name)
logger.debug(f'Enabling FIPS on the host {self.name} finished.')

def setup(self):
logger.debug('START: setting up host %s', self)
if not self.blank:
self.reset_rhsm()
if self.fips:
self.enable_fips()

logger.debug('END: setting up host %s', self)

Expand Down

0 comments on commit aa21a03

Please sign in to comment.