Skip to content

Commit

Permalink
Use custom Content for RHEL10 until SAT-29721 is resolved
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Talreja <[email protected]>
  • Loading branch information
Gauravtalreja1 committed Jan 17, 2025
1 parent 1383dd6 commit bdb827a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 35 deletions.
84 changes: 49 additions & 35 deletions pytest_fixtures/component/provision_pxe.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from robottelo import constants
from robottelo.config import settings
from robottelo.hosts import ContentHost
from robottelo.utils.issue_handlers import is_open


@pytest.fixture(scope='module')
Expand All @@ -39,20 +38,16 @@ def module_provisioning_rhel_content(
repo_names = []
if int(rhel_ver) <= 7:
repo_names.append(f'rhel{rhel_ver}')
# Provision using RHEL10 Beta repos until its GA
elif int(rhel_ver) == 10:
repo_names.append(f'rhel{rhel_ver}_bos_beta')
repo_names.append(f'rhel{rhel_ver}_aps_beta')
else:
elif int(rhel_ver) < 10:
repo_names.append(f'rhel{rhel_ver}_bos')
repo_names.append(f'rhel{rhel_ver}_aps')
rh_repos = []
tasks = []
rh_repo_id = ""
content_view = sat.api.ContentView(organization=module_sca_manifest_org).create()

# Custom Content for Client repo
if is_open('SAT-27193') and int(rhel_ver) != 10:
if int(rhel_ver) < 10:
# Custom Content for Client repo
custom_product = sat.api.Product(
organization=module_sca_manifest_org, name=f'rhel{rhel_ver}_{gen_string("alpha")}'
).create()
Expand All @@ -66,35 +61,53 @@ def module_provisioning_rhel_content(
tasks.append(task)
content_view.repository = [client_repo]

for name in repo_names:
rh_kickstart_repo_id = sat.api_factory.enable_rhrepo_and_fetchid(
basearch=constants.DEFAULT_ARCHITECTURE,
org_id=module_sca_manifest_org.id,
product=constants.REPOS['kickstart'][name]['product'],
repo=constants.REPOS['kickstart'][name]['name'],
reposet=constants.REPOS['kickstart'][name]['reposet'],
releasever=constants.REPOS['kickstart'][name]['version'],
)
# do not sync content repos for discovery based provisioning.
if module_provisioning_sat.provisioning_type != 'discovery':
rh_repo_id = sat.api_factory.enable_rhrepo_and_fetchid(
for name in repo_names:
rh_kickstart_repo_id = sat.api_factory.enable_rhrepo_and_fetchid(
basearch=constants.DEFAULT_ARCHITECTURE,
org_id=module_sca_manifest_org.id,
product=constants.REPOS[name]['product'],
repo=constants.REPOS[name]['name'],
reposet=constants.REPOS[name]['reposet'],
releasever=constants.REPOS[name]['releasever'],
product=constants.REPOS['kickstart'][name]['product'],
repo=constants.REPOS['kickstart'][name]['name'],
reposet=constants.REPOS['kickstart'][name]['reposet'],
releasever=constants.REPOS['kickstart'][name]['version'],
)
# do not sync content repos for discovery based provisioning.
if module_provisioning_sat.provisioning_type != 'discovery':
rh_repo_id = sat.api_factory.enable_rhrepo_and_fetchid(
basearch=constants.DEFAULT_ARCHITECTURE,
org_id=module_sca_manifest_org.id,
product=constants.REPOS[name]['product'],
repo=constants.REPOS[name]['name'],
reposet=constants.REPOS[name]['reposet'],
releasever=constants.REPOS[name]['releasever'],
)

# Sync step because repo is not synced by default
for repo_id in [rh_kickstart_repo_id, rh_repo_id]:
if repo_id:
rh_repo = sat.api.Repository(id=repo_id).read()
task = rh_repo.sync(synchronous=False)
tasks.append(task)
rh_repos.append(rh_repo)
content_view.repository.append(rh_repo)
content_view.update(['repository'])
else:
# Use custom Content for RHEL10 until SAT-29721 is resolved
custom_product = sat.api.Product(
organization=module_sca_manifest_org, name=f'rhel{rhel_ver}_{gen_string("alpha")}'
).create()
for repo in settings.repos.rhel10_os.values():
rh_repo = sat.api.Repository(
organization=module_sca_manifest_org,
product=custom_product,
content_type='yum',
url=repo,
).create()
task = repo.sync(synchronous=False)
tasks.append(task)
rh_repos.append(rh_repo)
content_view.repository.append(rh_repo)
content_view.update(['repository'])

# Sync step because repo is not synced by default
for repo_id in [rh_kickstart_repo_id, rh_repo_id]:
if repo_id:
rh_repo = sat.api.Repository(id=repo_id).read()
task = rh_repo.sync(synchronous=False)
tasks.append(task)
rh_repos.append(rh_repo)
content_view.repository.append(rh_repo)
content_view.update(['repository'])
for task in tasks:
sat.wait_for_tasks(
search_query=(f'id = {task["id"]}'),
Expand All @@ -105,7 +118,7 @@ def module_provisioning_rhel_content(
rhel_xy = Version(
constants.REPOS['kickstart'][f'rhel{rhel_ver}']['version']
if rhel_ver == 7
else constants.REPOS['kickstart'][f'rhel{rhel_ver}_bos_beta']['version']
else '10.0'
if rhel_ver == 10
else constants.REPOS['kickstart'][f'rhel{rhel_ver}_bos']['version']
)
Expand All @@ -116,6 +129,7 @@ def module_provisioning_rhel_content(
os = o_systems[0].read()
# return only the first kickstart repo - RHEL X KS or RHEL X BaseOS KS
ksrepo = rh_repos[0]

publish = content_view.publish()
task_status = sat.wait_for_tasks(
search_query=(f'Actions::Katello::ContentView::Publish and id = {publish["id"]}'),
Expand All @@ -133,7 +147,7 @@ def module_provisioning_rhel_content(
).create()

# Ensure client repo is enabled in the activation key
if is_open('SAT-27193') and int(rhel_ver) != 10:
if int(rhel_ver) < 10:
content = ak.product_content(data={'content_access_mode_all': '1'})['results']
client_repo_label = [repo['label'] for repo in content if repo['name'] == client_repo.name][
0
Expand Down
2 changes: 2 additions & 0 deletions pytest_fixtures/component/provisioning_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def module_sync_kickstart_content(
rhel_xy = Version(
constants.REPOS['kickstart'][f'rhel{rhel_ver}']['version']
if rhel_ver == 7
else constants.REPOS['kickstart'][f'rhel{rhel_ver}_bos_beta']['version']
if rhel_ver == 10
else constants.REPOS['kickstart'][f'rhel{rhel_ver}_bos']['version']
)
o_systems = module_target_sat.api.OperatingSystem().search(
Expand Down

0 comments on commit bdb827a

Please sign in to comment.