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

[6.15.z] Make default_os name and major versions configurable #15065

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions conf/supportability.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
supportability:
content_hosts:
default_os_name: "RedHat"
rhel:
versions: [6, 7,'7_fips', 8, '8_fips', 9, '9_fips']
33 changes: 17 additions & 16 deletions pytest_fixtures/component/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,34 @@
from nailgun import entities
import pytest

from robottelo.config import settings


@pytest.fixture(scope='session')
def default_os(
default_architecture,
default_partitiontable,
default_pxetemplate,
request,
session_target_sat,
):
"""Returns an Operating System entity read from searching Redhat family

Indirect parametrization should pass an operating system version string like 'RHEL 7.9'
Default operating system will find the first RHEL6 or RHEL7 entity
"""
os = getattr(request, 'param', None)
if os is None:
search_string = 'name="RedHat" AND (major="6" OR major="7" OR major="8")'
else:
version = os.split(' ')[1].split('.')
search_string = f'family="Redhat" AND major="{version[0]}" AND minor="{version[1]}"'
os = entities.OperatingSystem().search(query={'search': search_string})[0].read()
"""Returns an Operating System entity read from searching for supportability.content_host.default_os_name"""
search_string = f'name="{settings.supportability.content_hosts.default_os_name}"'

try:
os = (
session_target_sat.api.OperatingSystem()
.search(query={'search': search_string})[0]
.read()
)
except IndexError as e:
raise RuntimeError(f"Could not find operating system for '{search_string}'") from e

os.architecture.append(default_architecture)
os.ptable.append(default_partitiontable)
os.provisioning_template.append(default_pxetemplate)
os.update(['architecture', 'ptable', 'provisioning_template'])
return entities.OperatingSystem(id=os.id).read()

return session_target_sat.api.OperatingSystem(id=os.id).read()


@pytest.fixture(scope='module')
Expand All @@ -36,8 +39,6 @@ def module_os():

@pytest.fixture(scope='module')
def os_path(default_os):
from robottelo.config import settings

# Check what OS was found to use correct media
if default_os.major == "6":
os_distr_url = settings.repos.rhel6_os
Expand Down
5 changes: 4 additions & 1 deletion robottelo/config/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

VALIDATORS = dict(
supportability=[
Validator('supportability.content_hosts.rhel.versions', must_exist=True, is_type_of=list)
Validator('supportability.content_hosts.rhel.versions', must_exist=True, is_type_of=list),
Validator(
'supportability.content_hosts.default_os_name', must_exist=True, default='RedHat'
),
],
server=[
Validator('server.hostname', default=''),
Expand Down
Loading