-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add actor to check for particular cloud package (provided from special repository) to determine whether we are on public cloud. - disable DNF plugin with a message - use the resolved mirrorlist on AWS - copy RHUI data from special Leapp package when on public cloud and running without RHSM - add hybrid (BIOS, UEFI) image grubby workaround
- Loading branch information
Showing
23 changed files
with
689 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
from leapp.actors import Actor | ||
from leapp.libraries.common.rpms import has_package | ||
from leapp.models import ( | ||
DNFPluginTask, | ||
InstalledRPM, | ||
KernelCmdlineArg, | ||
RHUIInfo, | ||
RequiredTargetUserspacePackages, | ||
RpmTransactionTasks, | ||
) | ||
from leapp.reporting import Report, create_report | ||
from leapp import reporting | ||
from leapp.tags import ChecksPhaseTag, IPUWorkflowTag | ||
from leapp.libraries.common import rhsm, rhui | ||
|
||
|
||
class CheckRHUI(Actor): | ||
""" | ||
Check if system is using RHUI infrastructure (on public cloud) and send messages to | ||
provide additional data needed for upgrade. | ||
""" | ||
|
||
name = 'checkrhui' | ||
consumes = (InstalledRPM) | ||
produces = ( | ||
KernelCmdlineArg, | ||
RHUIInfo, | ||
RequiredTargetUserspacePackages, | ||
Report, DNFPluginTask, | ||
RpmTransactionTasks, | ||
) | ||
tags = (ChecksPhaseTag, IPUWorkflowTag) | ||
|
||
def process(self): | ||
for provider, info in rhui.RHUI_CLOUD_MAP.items(): | ||
if has_package(InstalledRPM, info['el7_pkg']): | ||
if not rhsm.skip_rhsm(): | ||
create_report([ | ||
reporting.Title('Upgrade initiated with RHSM on public cloud with RHUI infrastructure'), | ||
reporting.Summary( | ||
'Leapp detected this system is on public cloud with RHUI infrastructure ' | ||
'but the process was initiated without "--no-rhsm" command line option ' | ||
'which implies RHSM usage (valid subscription is needed).' | ||
), | ||
reporting.Severity(reporting.Severity.INFO), | ||
reporting.Tags([reporting.Tags.PUBLIC_CLOUD]), | ||
]) | ||
return | ||
# AWS RHUI package is provided and signed by RH but the Azure one not | ||
if not has_package(InstalledRPM, info['leapp_pkg']): | ||
create_report([ | ||
reporting.Title('Package "{}" is missing'.format(info['leapp_pkg'])), | ||
reporting.Summary( | ||
'On {} using RHUI infrastructure, a package "{}" is needed for' | ||
'in-place upgrade'.format(provider.upper(), info['leapp_pkg']) | ||
), | ||
reporting.Severity(reporting.Severity.HIGH), | ||
reporting.RelatedResource('package', info['leapp_pkg']), | ||
reporting.Flags([reporting.Flags.INHIBITOR]), | ||
reporting.Tags([reporting.Tags.PUBLIC_CLOUD, reporting.Tags.RHUI]), | ||
reporting.Remediation(commands=[['yum', 'install', '-y', info['leapp_pkg']]]) | ||
]) | ||
return | ||
if provider == 'aws': | ||
self.produce(DNFPluginTask(name='amazon-id', disable_in=['upgrade'])) | ||
if provider == 'azure': | ||
# Azure RHEL8 package has different name and it is not signed | ||
self.produce(RpmTransactionTasks(to_install=[info['el8_pkg']])) | ||
self.produce(RpmTransactionTasks(to_remove=[info['el7_pkg']])) | ||
self.produce(KernelCmdlineArg(**{'key': 'rootdelay', 'value': '300'})) | ||
self.produce(RHUIInfo(provider=provider)) | ||
self.produce(RequiredTargetUserspacePackages(packages=[info['el8_pkg']])) | ||
return |
61 changes: 61 additions & 0 deletions
61
repos/system_upgrade/el7toel8/actors/checkrhui/tests/component_test_checkrhui.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from collections import namedtuple | ||
|
||
import pytest | ||
|
||
from leapp.snactor.fixture import current_actor_context | ||
from leapp.models import ( | ||
InstalledRedHatSignedRPM, | ||
InstalledRPM, | ||
RPM, | ||
RHUIInfo, | ||
RequiredTargetUserspacePackages, | ||
) | ||
from leapp.reporting import Report | ||
from leapp.libraries.common.config import mock_configs | ||
from leapp.libraries.common import rhsm | ||
|
||
|
||
RH_PACKAGER = 'Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>' | ||
|
||
NO_RHUI = [ | ||
RPM(name='yolo', version='0.1', release='1.sm01', epoch='1', packager=RH_PACKAGER, arch='noarch', | ||
pgpsig='RSA/SHA256, Mon 01 Jan 1970 00:00:00 AM -03, Key ID 199e2f91fd431d51'), | ||
] | ||
|
||
ON_AWS_WITHOUT_LEAPP_PKG = [ | ||
RPM(name='rh-amazon-rhui-client', version='0.1', release='1.sm01', epoch='1', packager=RH_PACKAGER, | ||
arch='noarch', pgpsig='RSA/SHA256, Mon 01 Jan 1970 00:00:00 AM -03, Key ID 199e2f91fd431d51'), | ||
] | ||
|
||
ON_AWS_WITH_LEAPP_PKG = [ | ||
RPM(name='rh-amazon-rhui-client', version='0.1', release='1.sm01', epoch='1', packager=RH_PACKAGER, | ||
arch='noarch', pgpsig='RSA/SHA256, Mon 01 Jan 1970 00:00:00 AM -03, Key ID 199e2f91fd431d51'), | ||
RPM(name='leapp-rhui-aws', version='0.1', release='1.sm01', epoch='1', packager=RH_PACKAGER, | ||
arch='noarch', pgpsig='RSA/SHA256, Mon 01 Jan 1970 00:00:00 AM -03, Key ID 199e2f91fd431d51') | ||
] | ||
|
||
|
||
def create_modulesfacts(installed_rpm): | ||
return InstalledRPM(items=installed_rpm) | ||
|
||
|
||
msgs_received = namedtuple('MsgsReceived', ['report', 'rhui_info', 'req_target_userspace']) | ||
|
||
|
||
@pytest.mark.parametrize('skip_rhsm, msgs_received, installed_rpms', [ | ||
(False, msgs_received(False, False, False), NO_RHUI), | ||
(True, msgs_received(True, False, False), ON_AWS_WITHOUT_LEAPP_PKG), | ||
(True, msgs_received(False, True, True), ON_AWS_WITH_LEAPP_PKG), | ||
(False, msgs_received(True, False, False), ON_AWS_WITH_LEAPP_PKG) | ||
]) | ||
def test_check_rhui_actor( | ||
monkeypatch, current_actor_context, skip_rhsm, msgs_received, installed_rpms | ||
): | ||
monkeypatch.setattr(rhsm, 'skip_rhsm', lambda: skip_rhsm) | ||
|
||
current_actor_context.feed(create_modulesfacts(installed_rpm=installed_rpms)) | ||
current_actor_context.run(config_model=mock_configs.CONFIG) | ||
assert bool(current_actor_context.consume(Report)) is msgs_received.report | ||
assert bool(current_actor_context.consume(RHUIInfo)) is msgs_received.rhui_info | ||
assert bool(current_actor_context.consume( | ||
RequiredTargetUserspacePackages)) is msgs_received.req_target_userspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.