Skip to content

Commit

Permalink
Post deployments for content hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
jyejare committed Nov 13, 2024
1 parent 54eff8d commit 6cadb2e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
14 changes: 7 additions & 7 deletions conf/content_host.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,51 @@ content_host:
default_rhel_version: 7
rhel6:
vm:
workflow: deploy-base-rhel
workflow: deploy-rhel
deploy_rhel_version: '6'
target_memory: 1GiB
target_cores: 1
container:
container_host: rhel6:latest
rhel7:
vm:
workflow: deploy-base-rhel
workflow: deploy-rhel
deploy_rhel_version: '7'
target_memory: 1GiB
target_cores: 1
container:
container_host: ubi7:latest
rhel7_fips:
vm:
workflow: deploy-base-rhel-fips
workflow: deploy-rhel
deploy_rhel_version: '7'
target_memory: 1GiB
target_cores: 1
rhel8:
vm:
workflow: deploy-base-rhel
workflow: deploy-rhel
deploy_rhel_version: '8'
target_memory: 1536 MiB
target_cores: 1
container:
container_host: ubi8:latest
rhel8_fips:
vm:
workflow: deploy-base-rhel-fips
workflow: deploy-rhel
deploy_rhel_version: '8'
target_memory: 1536 MiB
target_cores: 1
rhel9:
vm:
workflow: deploy-base-rhel
workflow: deploy-rhel
deploy_rhel_version: '9'
target_memory: 1536 MiB
target_cores: 1
container:
container_host: ubi9:latest
rhel9_fips:
vm:
workflow: deploy-base-rhel-fips
workflow: deploy-rhel
deploy_rhel_version: '9'
target_memory: 1536 MiB
target_cores: 1
Expand Down
17 changes: 17 additions & 0 deletions pytest_fixtures/core/contenthosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,22 @@ def host_conf(request):
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 @@ -56,6 +66,7 @@ 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 @@ -112,6 +123,8 @@ 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 @@ -120,6 +133,8 @@ 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 @@ -172,6 +187,7 @@ 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 @@ -184,6 +200,7 @@ 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

0 comments on commit 6cadb2e

Please sign in to comment.