From 1f327508f361128b3b15b8f651a0e9ba0a04ec96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Gajdu=C5=A1ek?= Date: Mon, 9 Sep 2024 16:36:00 +0200 Subject: [PATCH] Set DNF proxy for IPv6 runs (#16274) --- robottelo/hosts.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/robottelo/hosts.py b/robottelo/hosts.py index d9278c94fee..f24280eaca9 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -835,6 +835,16 @@ def enable_rhsm_proxy(self, hostname, port=None): cmd += f' --server.proxy_port={port}' self.execute(cmd) + def enable_dnf_proxy(self, hostname, scheme=None, port=None): + """Configures proxy for dnf""" + if not scheme: + scheme = 'http' + cmd = f"echo -e 'proxy = {scheme}://{hostname}" + if port: + cmd += f':{port}' + cmd += "' >> /etc/dnf/dnf.conf" + self.execute(cmd) + def add_authorized_key(self, pub_key): """Inject a public key into the authorized keys file @@ -1690,10 +1700,6 @@ def enable_satellite_or_capsule_module_for_rhel8(self): Note: Make sure required repos are enabled before using this. """ if self.os_version.major == 8: - if settings.server.is_ipv6: - self.execute( - f"echo -e 'proxy={settings.server.http_proxy_ipv6_url}' >> /etc/dnf/dnf.conf" - ) assert ( self.execute( f'dnf -y module enable {self.product_rpm_name}:el{self.os_version.major}' @@ -2326,6 +2332,7 @@ def register_contenthost( if enable_proxy and settings.server.is_ipv6: url = urlparse(settings.server.http_proxy_ipv6_url) self.enable_rhsm_proxy(url.hostname, url.port) + self.enable_dnf_proxy(url.hostname, url.scheme, url.port) return super().register_contenthost( org=org, lce=lce, username=username, password=password, enable_proxy=enable_proxy )