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

Add ELS option for convert2rhel for EL7 #17143

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
45 changes: 45 additions & 0 deletions pytest_fixtures/component/taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,27 @@ def module_gt_manifest_org(module_target_sat):
return org


@pytest.fixture
def function_els_sca_manifest_org(function_org, function_sca_els_manifest, target_sat):
"""Creates an organization and uploads an SCA mode manifest generated with manifester"""
target_sat.upload_manifest(function_org.id, function_sca_els_manifest.content)
return function_org


@pytest.fixture(scope='module')
def module_els_sca_manifest_org(module_org, module_sca_els_manifest, module_target_sat):
"""Creates an organization and uploads an SCA mode manifest generated with manifester"""
module_target_sat.upload_manifest(module_org.id, module_sca_els_manifest.content)
return module_org


@pytest.fixture(scope='class')
def class_els_sca_manifest_org(class_org, class_sca_els_manifest, class_target_sat):
"""Creates an organization and uploads an SCA mode manifest generated with manifester"""
class_target_sat.upload_manifest(class_org.id, class_sca_els_manifest.content)
return class_org


# Note: Manifester should not be used with the Satellite QE RHSM account until
# subscription needs are scoped and sufficient subscriptions added to the
# Satellite QE RHSM account. Manifester can be safely used locally with personal
Expand Down Expand Up @@ -195,6 +216,30 @@ def second_function_sca_manifest():
yield manifest


@pytest.fixture(scope='module')
def module_sca_els_manifest():
"""Yields a manifest in Simple Content Access mode with subscriptions determined by the
`manifest_category.els_rhel_manifest` setting in conf/manifest.yaml."""
with Manifester(manifest_category=settings.manifest.els_rhel_manifest) as manifest:
yield manifest


@pytest.fixture(scope='class')
def class_sca_els_manifest():
"""Yields a manifest in Simple Content Access mode with subscriptions determined by the
`manifest_category.els_rhel_manifest` setting in conf/manifest.yaml."""
with Manifester(manifest_category=settings.manifest.els_rhel_manifest) as manifest:
yield manifest


@pytest.fixture
def function_sca_els_manifest():
"""Yields a manifest in Simple Content Access mode with subscriptions determined by the
`manifest_category.els_rhel_manifest` setting in conf/manifest.yaml."""
with Manifester(manifest_category=settings.manifest.els_rhel_manifest) as manifest:
yield manifest


@pytest.fixture(scope='module')
def smart_proxy_location(module_org, module_target_sat, default_smart_proxy):
location = module_target_sat.api.Location(organization=[module_org]).create()
Expand Down
20 changes: 18 additions & 2 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,14 @@
'rhel8': 'Red Hat Enterprise Linux for x86_64',
'rhel9': 'Red Hat Enterprise Linux for x86_64',
'rhel10_beta': 'Red Hat Enterprise Linux for x86_64 Beta',
'rhel_els': 'Red Hat Enterprise Linux Server - Extended Life Cycle Support',
}

REPOSET = {
'rhct6': 'Red Hat CloudForms Tools for RHEL 6 (RPMs)',
'rhel6': 'Red Hat Enterprise Linux 6 Server (RPMs)',
'rhel7': 'Red Hat Enterprise Linux 7 Server (RPMs)',
'rhel7_els': 'Red Hat Enterprise Linux 7 Server - Extended Life Cycle Support (RPMs)',
'rhva6': ('Red Hat Enterprise Virtualization Agents for RHEL 6 Server (RPMs)'),
'rhs7': 'Red Hat Satellite 6.11 (for RHEL 7 Server) (RPMs)',
'rhs8': 'Red Hat Satellite 6.13 for RHEL 8 x86_64 (RPMs)',
Expand Down Expand Up @@ -356,8 +358,22 @@
'releasever': '7Server',
'arch': 'x86_64',
'distro': 'rhel7',
'reposet': REPOSET['rhel7'],
'product': PRDS['rhel'],
'reposet': REPOSET['rhel7_els'],
'product': PRDS['rhel_els'],
'major_version': 7,
'distro_repository': True,
'key': 'rhel',
'version': '7.9',
'basearch': 'x86_64',
},
'rhel7_els': {
'id': 'rhel-7-server-els-rpms',
'name': 'Red Hat Enterprise Linux 7 Server - Extended Life Cycle Support RPMs x86_64',
'releasever': '7Server',
'arch': 'x86_64',
'distro': 'rhel7',
'reposet': REPOSET['rhel7_els'],
'product': PRDS['rhel_els'],
'major_version': 7,
'distro_repository': True,
'key': 'rhel',
Expand Down
40 changes: 25 additions & 15 deletions tests/foreman/api/test_convert2rhel.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,42 +50,44 @@ def update_cv(sat, cv, lce, repos):


@pytest.fixture(scope='module')
def ssl_cert(module_target_sat, module_sca_manifest_org):
def ssl_cert(module_target_sat, module_els_sca_manifest_org):
"""Create credetial with SSL cert for Oracle Linux"""
res = requests.get(settings.repos.convert2rhel.ssl_cert_oracle)
res.raise_for_status()
return module_target_sat.api.ContentCredential(
content=res.text, organization=module_sca_manifest_org, content_type='cert'
content=res.text, organization=module_els_sca_manifest_org, content_type='cert'
).create()


@pytest.fixture
def activation_key_rhel(module_target_sat, module_sca_manifest_org, module_lce, module_promoted_cv):
def activation_key_rhel(
module_target_sat, module_els_sca_manifest_org, module_lce, module_promoted_cv
):
"""Create activation key that will be used after conversion for registration"""
return module_target_sat.api.ActivationKey(
organization=module_sca_manifest_org,
organization=module_els_sca_manifest_org,
content_view=module_promoted_cv,
environment=module_lce,
).create()


@pytest.fixture(scope='module')
def enable_rhel_subscriptions(module_target_sat, module_sca_manifest_org, version):
def enable_rhel_subscriptions(module_target_sat, module_els_sca_manifest_org, version):
"""Enable and sync RHEL rpms repos"""
major = version.split('.')[0]
minor = ''
if major == '8':
repo_names = ['rhel8_bos', 'rhel8_aps']
minor = version[1:]
else:
repo_names = ['rhel7']
repo_names = ['rhel7_els']

rh_repos = []
tasks = []
for name in repo_names:
rh_repo_id = module_target_sat.api_factory.enable_rhrepo_and_fetchid(
basearch=DEFAULT_ARCHITECTURE,
org_id=module_sca_manifest_org.id,
org_id=module_els_sca_manifest_org.id,
product=REPOS[name]['product'],
repo=REPOS[name]['name'] + minor,
reposet=REPOS[name]['reposet'],
Expand All @@ -112,7 +114,7 @@ def enable_rhel_subscriptions(module_target_sat, module_sca_manifest_org, versio
def centos(
module_target_sat,
centos_host,
module_sca_manifest_org,
module_els_sca_manifest_org,
smart_proxy_location,
module_promoted_cv,
module_lce,
Expand All @@ -123,12 +125,12 @@ def centos(
major = version.split('.')[0]
assert centos_host.execute('yum -y update').status == 0
repo_url = settings.repos.convert2rhel.convert_to_rhel_repo.format(major)
repo = create_repo(module_target_sat, module_sca_manifest_org, repo_url)
repo = create_repo(module_target_sat, module_els_sca_manifest_org, repo_url)
cv = update_cv(
module_target_sat, module_promoted_cv, module_lce, enable_rhel_subscriptions + [repo]
)
ak = module_target_sat.api.ActivationKey(
organization=module_sca_manifest_org,
organization=module_els_sca_manifest_org,
content_view=cv,
environment=module_lce,
).create()
Expand All @@ -140,7 +142,7 @@ def centos(
# Register CentOS host with Satellite
result = centos_host.api_register(
module_target_sat,
organization=module_sca_manifest_org,
organization=module_els_sca_manifest_org,
activation_keys=[ak.name],
location=smart_proxy_location,
)
Expand All @@ -158,7 +160,7 @@ def centos(
def oracle(
module_target_sat,
oracle_host,
module_sca_manifest_org,
module_els_sca_manifest_org,
smart_proxy_location,
module_promoted_cv,
module_lce,
Expand Down Expand Up @@ -195,12 +197,12 @@ def oracle(
oracle_host.power_control(state='reboot')

repo_url = settings.repos.convert2rhel.convert_to_rhel_repo.format(major)
repo = create_repo(module_target_sat, module_sca_manifest_org, repo_url, ssl_cert)
repo = create_repo(module_target_sat, module_els_sca_manifest_org, repo_url, ssl_cert)
cv = update_cv(
module_target_sat, module_promoted_cv, module_lce, enable_rhel_subscriptions + [repo]
)
ak = module_target_sat.api.ActivationKey(
organization=module_sca_manifest_org,
organization=module_els_sca_manifest_org,
content_view=cv,
environment=module_lce,
).create()
Expand All @@ -215,7 +217,7 @@ def oracle(
# Register Oracle host with Satellite
result = oracle_host.api_register(
module_target_sat,
organization=module_sca_manifest_org,
organization=module_els_sca_manifest_org,
activation_keys=[ak.name],
location=smart_proxy_location,
repo=ubi_url,
Expand Down Expand Up @@ -280,6 +282,9 @@ def test_convert2rhel_oracle_with_pre_conversion_template_check(
'job_template_id': template_id,
'targeting_type': 'static_query',
'search_query': f'name = {oracle.hostname}',
'inputs': {
'ELS': 'yes' if major <= '7' else 'no',
},
},
)
# wait for job to complete
Expand All @@ -301,6 +306,7 @@ def test_convert2rhel_oracle_with_pre_conversion_template_check(
'inputs': {
'Activation Key': activation_key_rhel.id,
'Restart': 'yes',
'ELS': 'yes' if major <= '7' else 'no',
},
'targeting_type': 'static_query',
'search_query': f'name = {oracle.hostname}',
Expand Down Expand Up @@ -370,6 +376,9 @@ def test_convert2rhel_centos_with_pre_conversion_template_check(
'job_template_id': template_id,
'targeting_type': 'static_query',
'search_query': f'name = {centos.hostname}',
'inputs': {
'ELS': 'yes' if major <= '7' else 'no',
},
},
)
# wait for job to complete
Expand All @@ -392,6 +401,7 @@ def test_convert2rhel_centos_with_pre_conversion_template_check(
'inputs': {
'Activation Key': activation_key_rhel.id,
'Restart': 'yes',
'ELS': 'yes' if major <= '7' else 'no',
},
'targeting_type': 'static_query',
'search_query': f'name = {centos.hostname}',
Expand Down
Loading