Skip to content

Commit

Permalink
Fix deployment in Interop testing
Browse files Browse the repository at this point in the history
  • Loading branch information
rmynar committed Feb 4, 2025
1 parent e2eedd5 commit 5f272af
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 32 deletions.
48 changes: 31 additions & 17 deletions pytest_fixtures/core/sat_cap_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,19 @@ def parametrized_enrolled_sat(
Broker(hosts=[new_sat]).checkin()


def get_deploy_args(request):
"""Get deploy arguments for Satellite base OS deployment. Should not be used for Capsule."""
def get_sat_deploy_args(request):
"""Get deploy arguments for Satellite base OS deployment."""
rhel_version = get_sat_rhel_version()
deploy_args = settings.content_host[f'rhel{rhel_version.major}'].vm | {
'deploy_rhel_version': rhel_version.base_version,
'deploy_network_type': 'ipv6' if settings.server.is_ipv6 else 'ipv4',
'deploy_flavor': settings.flavors.default,
'workflow': settings.server.deploy_workflows.os,
}
deploy_args = (
settings.content_host[f'rhel{rhel_version.major}'].vm
| settings.server.deploy_arguments
| {
'deploy_rhel_version': rhel_version.base_version,
'deploy_network_type': 'ipv6' if settings.server.is_ipv6 else 'ipv4',
'deploy_flavor': settings.flavors.default,
'workflow': settings.server.deploy_workflows.os,
}
)
if hasattr(request, 'param'):
if isinstance(request.param, dict):
deploy_args.update(request.param)
Expand All @@ -309,16 +313,31 @@ def get_deploy_args(request):
return deploy_args


def get_cap_deploy_args():
"""Get deploy arguments for Capsule base OS deployment."""
rhel_version = Version(settings.capsule.version.rhel_version)
return (
settings.content_host[f'rhel{rhel_version.major}'].vm
| settings.capsule.deploy_arguments
| {
'deploy_rhel_version': rhel_version.base_version,
'deploy_network_type': 'ipv6' if settings.server.is_ipv6 else 'ipv4',
'deploy_flavor': settings.flavors.default,
'workflow': settings.capsule.deploy_workflows.os,
}
)


@pytest.fixture
def sat_ready_rhel(request):
deploy_args = get_deploy_args(request)
deploy_args = get_sat_deploy_args(request)
with Broker(**deploy_args, host_class=Satellite) as host:
yield host


@pytest.fixture(scope='module')
def module_sat_ready_rhels(request, module_target_sat):
deploy_args = get_deploy_args(request)
deploy_args = get_sat_deploy_args(request)
if 'build_sanity' not in request.config.option.markexpr:
with Broker(**deploy_args, host_class=Satellite, _count=3) as hosts:
yield hosts
Expand All @@ -329,13 +348,8 @@ def module_sat_ready_rhels(request, module_target_sat):
@pytest.fixture
def cap_ready_rhel():
"""Deploy bare RHEL system ready for Capsule installation."""
rhel_version = Version(settings.capsule.version.rhel_version)
deploy_args = settings.capsule.deploy_arguments | {
'deploy_rhel_version': rhel_version.base_version,
'deploy_network_type': 'ipv6' if settings.server.is_ipv6 else 'ipv4',
'deploy_flavor': settings.flavors.default,
'workflow': settings.capsule.deploy_workflows.os,
}
deploy_args = get_cap_deploy_args()

with Broker(**deploy_args, host_class=Capsule) as host:
host.enable_ipv6_dnf_and_rhsm_proxy()
yield host
Expand Down
41 changes: 26 additions & 15 deletions robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1655,24 +1655,32 @@ def capsule_setup(self, sat_host=None, capsule_cert_opts=None, **installer_kwarg
"""Prepare the host and run the capsule installer"""
self._satellite = sat_host or Satellite()

# Register capsule host to CDN and enable repos
result = self.register_contenthost(
org=None,
lce=None,
username=settings.subscription.rhn_username,
password=settings.subscription.rhn_password,
auto_attach=True,
)
if result.status:
raise CapsuleHostError(f'Capsule CDN registration failed\n{result.stderr}')

for repo in getattr(constants, f"OHSNAP_RHEL{self.os_version.major}_REPOS"):
result = self.enable_repo(repo, force=True)
if settings.robottelo.rhelsource == "ga":
# Register capsule host to CDN and enable repos
result = self.register_contenthost(
org=None,
lce=None,
username=settings.subscription.rhn_username,
password=settings.subscription.rhn_password,
auto_attach=True,
)
if result.status:
raise CapsuleHostError(f'Repo enable at capsule host failed\n{result.stdout}')
raise CapsuleHostError(f'Capsule CDN registration failed\n{result.stderr}')

for repo in getattr(constants, f"OHSNAP_RHEL{self.os_version.major}_REPOS"):
result = self.enable_repo(repo, force=True)
if result.status:
raise CapsuleHostError(f'Repo enable at capsule host failed\n{result.stdout}')
elif settings.robottelo.rhel_source == "internal":
# add internal rhel repos
self.create_custom_repos(**settings.repos.get(f'rhel{self.os_version.major}_os'))

# Update system, firewall services and check capsule is already installed from template
self.execute('yum -y update', timeout=0)
# Setups firewall on Capsule
self.execute('dnf -y update', timeout=0)
assert self.execute("which firewall-cmd || dnf -y install firewalld").status == 0, (
"firewalld is not present and can't be installed"
)
self.execute('firewall-cmd --add-service RH-Satellite-6-capsule')
self.execute('firewall-cmd --runtime-to-permanent')
result = self.execute('rpm -q satellite-capsule')
Expand Down Expand Up @@ -2027,6 +2035,9 @@ def is_remote_db(self):

def setup_firewall(self):
# Setups firewall on Satellite
assert self.execute("which firewall-cmd || dnf -y install firewalld").status == 0, (
"firewalld is not present and can't be installed"
)
assert (
self.execute(
command='firewall-cmd --add-port="53/udp" --add-port="53/tcp" --add-port="67/udp" '
Expand Down

0 comments on commit 5f272af

Please sign in to comment.