From ca539f02b6e8fc40344e9c46b2698fd1b0fe8917 Mon Sep 17 00:00:00 2001 From: jyejare Date: Wed, 20 Mar 2024 15:24:51 +0530 Subject: [PATCH] Ipv6 Capsule is enabled for CDN communication via Proxy --- pytest_fixtures/core/sat_cap_factory.py | 12 ++++++++---- robottelo/hosts.py | 12 +++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/pytest_fixtures/core/sat_cap_factory.py b/pytest_fixtures/core/sat_cap_factory.py index 54c0ca19083..5f3fc214a9f 100644 --- a/pytest_fixtures/core/sat_cap_factory.py +++ b/pytest_fixtures/core/sat_cap_factory.py @@ -50,8 +50,10 @@ def cached_capsule_cdn_register(hostname=None): def _target_capsule_host(request, capsule_factory): if 'sanity' not in request.config.option.markexpr and not request.config.option.n_minus: new_cap = capsule_factory() + new_cap.enable_ipv6_http_proxy() yield new_cap new_cap.teardown() + new_cap.disable_ipv6_http_proxy() Broker(hosts=[new_cap]).checkin() elif request.config.option.n_minus: if not settings.capsule.hostname: @@ -96,9 +98,10 @@ def factory(retry_limit=3, delay=300, workflow=None, **broker_args): def large_capsule_host(capsule_factory): """A fixture that provides a Capsule based on config settings""" new_cap = capsule_factory(deploy_flavor=settings.flavors.custom_db) - # TO_DO - a question to resolve - How does the dynamic capsule talks to the CDN for contents ? + new_cap.enable_ipv6_http_proxy() yield new_cap new_cap.teardown() + new_cap.disable_ipv6_http_proxy() Broker(hosts=[new_cap]).checkin() @@ -120,7 +123,6 @@ def factory(retry_limit=3, delay=300, workflow=None, **broker_args): ) timeout = (1200 + delay) * retry_limit cap = wait_for(vmb.checkout, timeout=timeout, delay=delay, fail_condition=[]) - ## TO-DO: Need to add http proxy here for this capsule to talk outside/CDN return cap.out return factory @@ -248,10 +250,11 @@ def module_lb_capsule(retry_limit=3, delay=300, **broker_args): ) cap_hosts = wait_for(hosts.checkout, timeout=timeout, delay=delay) - ## TO_DO : Need to add Proxy here for these capsules + [cap.enable_ipv6_http_proxy() for cap in cap_hosts.out] yield cap_hosts.out [cap.teardown() for cap in cap_hosts.out] + [cap.disable_ipv6_http_proxy() for cap in cap_hosts.out] Broker(hosts=cap_hosts.out).checkin() @@ -328,8 +331,9 @@ def cap_ready_rhel(): 'workflow': settings.capsule.deploy_workflows.os, } with Broker(**deploy_args, host_class=Capsule) as host: - ## TO_DO: Need to add Proxy here for this capsule + host.enable_ipv6_http_proxy() yield host + host.disable_ipv6_http_proxy() @pytest.fixture(scope='session') diff --git a/robottelo/hosts.py b/robottelo/hosts.py index 66987d06519..7507f79809f 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -1615,6 +1615,17 @@ def enable_capsule_downstream_repos(self): snap=settings.capsule.version.snap, ) + def enable_ipv6_http_proxy(self): + if settings.server.is_ipv6 and settings.server.http_proxy_ipv6_url: + url = urlparse(settings.server.http_proxy_ipv6_url) + self.execute( + f'subscription-manager config --server.proxy_hostname={url.hostname} --server.proxy_port={url.port}' + ) + + def disable_ipv6_http_proxy(self): + if settings.server.is_ipv6: + self.execute('subscription-manager remove server.proxy_hostname server.proxy_port') + def capsule_setup(self, sat_host=None, capsule_cert_opts=None, **installer_kwargs): """Prepare the host and run the capsule installer""" self._satellite = sat_host or Satellite() @@ -1650,7 +1661,6 @@ def capsule_setup(self, sat_host=None, capsule_cert_opts=None, **installer_kwarg self.satellite.session.remote_copy(certs_tar, self) installer.update(**installer_kwargs) result = self.install(installer) - ## TO_DO : Add a http proxy for this to communicate outside if result.status: # before exit download the capsule log file self.session.sftp_read(