Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed the dynaconf transalation for ipv4 to ipv6 #16635

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions robottelo/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@
os.environ['ROBOTTELO_DIR'] = str(robottelo_root_dir)


def replace_ipv4_with_ipv6_in_urls(settings):
def replace_in_value(value):
# Only replace 'ipv4' with 'ipv6' in strings that contain 'redhat.com'
if isinstance(value, str) and 'ipv4' in value and 'redhat.com' in value:
return value.replace('ipv4', 'ipv6')
return value

def resolve_and_replace(settings_dict):
resolved = {}
for key, value in settings_dict.items():
if isinstance(value, str):
resolved[key] = replace_in_value(value)
elif isinstance(value, dict):
# Recursively handle nested dictionaries
resolved[key] = resolve_and_replace(value)
else:
resolved[key] = value
return resolved

# Update the settings in-place with resolved and replaced values
updated_settings = resolve_and_replace(settings.as_dict())
for key, value in updated_settings.items():
settings.set(key, value)


def get_settings():
"""Return Lazy settings object after validating

Expand Down Expand Up @@ -49,6 +74,7 @@ def get_settings():


settings = get_settings()
replace_ipv4_with_ipv6_in_urls(settings)
robottelo_tmp_dir = Path(settings.robottelo.tmp_dir)
robottelo_tmp_dir.mkdir(parents=True, exist_ok=True)

Expand Down