Skip to content

Commit

Permalink
Make default_os name and major versions configurable
Browse files Browse the repository at this point in the history
also enable searching for os names other than redhat os
  • Loading branch information
dosas committed Apr 9, 2024
1 parent ca8ab78 commit 43cc628
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
7 changes: 7 additions & 0 deletions conf/server.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ SERVER:
HOSTNAMES: []
# - replace.with.satellite.hostname
# - replace.with.satellite.hostname
# default os name and versions used in default_os fixture
DEFAULT_OS:
NAME: "RedHat"
MAJOR_VERSIONS:
- 6
- 7
- 8
VERSION:
# The full release version (6.9.2)
RELEASE: 6.9.2
Expand Down
24 changes: 17 additions & 7 deletions pytest_fixtures/component/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
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
Expand All @@ -17,16 +20,25 @@ def default_os(
"""
os = getattr(request, 'param', None)
if os is None:
search_string = 'name="RedHat" AND (major="6" OR major="7" OR major="8")'
default_name = settings.server.default_os.name
default_major_versions = " OR ".join(
[f'major="{v}"' for v in settings.server.default_os.major_versions]
)
search_string = f'name="{default_name}" AND ({default_major_versions})'
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()
name, version = os.split(' ')
version = version.split('.')
search_string = f'name="{name}" AND major="{version[0]}" AND minor="{version[1]}"'
os = (
session_target_sat.OperatingSystem()
.search(query={'search': search_string, 'per_page': 50})[0]
.read()
)
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.OperatingSystem(id=os.id).read()


@pytest.fixture(scope='module')
Expand All @@ -36,8 +48,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
2 changes: 2 additions & 0 deletions robottelo/config/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
server=[
Validator('server.hostname', default=''),
Validator('server.hostnames', must_exist=True, is_type_of=list),
Validator('server.default_os.name', must_exist=True, default='RedHat'),
Validator('server.default_os.major_versions', must_exist=True, default=[6, 7, 8]),
Validator('server.version.release', must_exist=True),
Validator('server.version.source', must_exist=True),
Validator('server.version.rhel_version', must_exist=True, cast=str),
Expand Down

0 comments on commit 43cc628

Please sign in to comment.