Skip to content

Commit

Permalink
update texts and reports regarding the --no-rhsm
Browse files Browse the repository at this point in the history
The content (target repositories) for the target system is supposed
to be delivered using RHSM by default. However it is possible to
skip it using the --no-rhsm option (or LEAPP_NO_RHSM=1). User should
be notified that if problem is encountered around rhsm (e.g. system
is not registered), there is possibility to skip RHSM and provide
the RHEL 8 content via custom repositories.

Modify all related texts and reports.
  • Loading branch information
pirat89 committed Apr 6, 2020
1 parent fc4300c commit d32a695
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 9 deletions.
3 changes: 2 additions & 1 deletion repos/system_upgrade/el7toel8/actors/checkrhsmsku/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class CheckRedHatSubscriptionManagerSKU(Actor):
Ensure the system is subscribed to the subscription manager
This actor verifies that the system is correctly subscribed to via the Red Hat Subscription Manager and
has attached SKUs. The actor will inhibit the upgrade if there are none.
has attached SKUs. The actor will inhibit the upgrade if there are none and RHSM is not supposed
to be skipped.
"""

name = 'check_rhsmsku'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ def process():
create_report([
reporting.Title('The system is not registered or subscribed.'),
reporting.Summary(
'The system has to be registered and subscribed to be able to proceed the upgrade.'
'The system has to be registered and subscribed to be able to proceed the upgrade,'
' unless the --no-rhsm option is specified when executing leapp.'
),
reporting.Severity(reporting.Severity.HIGH),
reporting.Tags([reporting.Tags.SANITY]),
reporting.Flags([reporting.Flags.INHIBITOR]),
reporting.Remediation(
hint='Register your system with the subscription-manager tool and attach it to proper SKUs'
' to be able to proceed the upgrade.'),
' to be able to proceed the upgrade. Or use the --no-rhsm leapp option if you want to'
' provide target repositories by yourself.'),
reporting.RelatedResource('package', 'subscription-manager')
])
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@

class ReportSetTargetRelease(Actor):
"""
Reports that a release will be set in the subscription-manager after the upgrade.
Reports information related to the release set in the subscription-manager after the upgrade.
When using Red Hat subscription-manager (RHSM), the release is set by default
to the target version release. In case of skip of the RHSM (--no-rhsm), the
release stay as it is on the RHEL 7 and user has to handle it manually after
the upgrade.
"""

name = 'report_set_target_release'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from leapp import reporting
from leapp.libraries.stdlib import api
from leapp.libraries.common import rhsm


def process():
# TODO: skip if users are not using rhsm at all (RHELLEAPP-201)
def _report_set_release():
target_version = api.current_actor().configuration.version.target
reporting.create_report([
reporting.Title(
Expand All @@ -20,3 +20,35 @@ def process():
reporting.Tags([reporting.Tags.UPGRADE_PROCESS]),
reporting.RelatedResource('package', 'subscription-manager')
])


def _report_unhandled_release():
# TODO: set the POST group after it's created.
target_version = api.current_actor().configuration.version.target
commands = [
['subscription-manager', 'release', '--unset'],
['subscription-manager', 'release', '--set', target_version],
]
hint = 'Set the new release (or unset it) after the upgrade using subscription-manager.'
reporting.create_report([
reporting.Title(
'The subscription-manager release is going to be kept as it is during the upgrade'),
reporting.Summary(
'The upgrade is executed with the --no-rhsm option (or with'
' the LEAPP_NO_RHSM environment variable). In this case, the subscription-manager'
' will not be configured during the upgrade. If the system is subscribed and release'
' is set already, you could encounter issues to get RHEL 8 content when use DNF/YUM'
' after the upgrade.'
),
reporting.Severity(reporting.Severity.LOW),
reporting.Remediation(commands=commands, hint=hint),
reporting.Tags([reporting.Tags.UPGRADE_PROCESS]),
reporting.RelatedResource('package', 'subscription-manager')
])


def process():
if rhsm.skip_rhsm():
_report_unhandled_release()
else:
_report_set_release()
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from leapp import reporting
from leapp.libraries.actor import library
from leapp.libraries.common import rhsm
from leapp.libraries.common.testutils import create_report_mocked
from leapp.libraries.stdlib import api

Expand All @@ -21,8 +22,19 @@ def __call__(self):
@pytest.mark.parametrize('version', ['8.{}'.format(i) for i in range(4)])
def test_report_target_version(monkeypatch, version):
monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(dst_ver=version))
monkeypatch.setattr(rhsm, 'skip_rhsm', lambda: False)
monkeypatch.setattr(reporting, 'create_report', create_report_mocked())
SUMMARY_FMT = 'will be set to {}.'
library.process()
assert reporting.create_report.called == 1
assert SUMMARY_FMT.format(version) in reporting.create_report.report_fields['summary']
assert 'is going to be set' in reporting.create_report.report_fields['title']


def test_report_unhandled_release(monkeypatch):
monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(dst_ver='8.1'))
monkeypatch.setattr(rhsm, 'skip_rhsm', lambda: True)
monkeypatch.setattr(reporting, 'create_report', create_report_mocked())
library.process()
assert reporting.create_report.called == 1
assert 'is going to be kept' in reporting.create_report.report_fields['title']
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,13 @@ def gather_target_repositories(context):
details={
# FIXME: update the text - mention the possibility of custom repos
'hint': ('It is required to have RHEL repositories on the system'
' provided by the subscription-manager. Possibly you'
' provided by the subscription-manager unless the --no-rhsm'
' options is specified. Possibly you'
' are missing a valid SKU for the target system or network'
' connection failed. Check whether your system is attached'
' to a valid SKU providing RHEL 8 repositories.')
' to a valid SKU providing RHEL 8 repositories.'
' In case the Satellite is used, read the upgrade documentation'
' to setup satellite and system properly.')
}
)
else:
Expand Down
10 changes: 9 additions & 1 deletion repos/system_upgrade/el7toel8/libraries/rhsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,20 @@ def _handle_rhsm_exceptions(hint=None):
}
)
except CalledProcessError as e:
_def_hint = (
'Please ensure you have a valid RHEL subscription and your network is up.'
' If you are using proxy for Red Hat subscription-manager, please ensure'
' it is specified inside the /etc/rhsm/rhsm.conf file.'
' Or use the --no-rhsm option when running leapp, if you do ot want to'
' use subscription-manager for the in-place upgrade and you want to'
' deliver all target repositories by yourself.'
)
raise StopActorExecutionError(
message='A subscription-manager command failed to execute',
details={
'details': str(e),
'stderr': e.stderr,
'hint': hint or 'Please ensure you have a valid RHEL subscription and your network is up.'
'hint': hint or _def_hint
}
)

Expand Down

0 comments on commit d32a695

Please sign in to comment.