-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add el8toel9 upgrade facts for Satellite
- Loading branch information
Showing
2 changed files
with
235 additions
and
0 deletions.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
repos/system_upgrade/el8toel9/actors/satellite_upgrade_facts/actor.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,105 @@ | ||
from leapp.actors import Actor | ||
from leapp.libraries.common.config import architecture | ||
from leapp.libraries.common.rpms import has_package | ||
from leapp.models import ( | ||
InstalledRPM, | ||
Module, | ||
RepositoriesSetupTasks, | ||
RpmTransactionTasks, | ||
SatelliteFacts, | ||
SatellitePostgresqlFacts | ||
) | ||
from leapp.tags import FactsPhaseTag, IPUWorkflowTag | ||
|
||
|
||
class SatelliteUpgradeFacts(Actor): | ||
""" | ||
Report which Satellite packages require updates and how to handle PostgreSQL data | ||
""" | ||
|
||
name = 'satellite_upgrade_facts' | ||
consumes = (InstalledRPM, ) | ||
produces = (RepositoriesSetupTasks, RpmTransactionTasks, SatelliteFacts) | ||
tags = (IPUWorkflowTag, FactsPhaseTag) | ||
|
||
def process(self): | ||
if not architecture.matches_architecture(architecture.ARCH_X86_64): | ||
return | ||
|
||
has_foreman = has_package(InstalledRPM, 'foreman') or has_package(InstalledRPM, 'foreman-proxy') | ||
if not has_foreman: | ||
return | ||
|
||
installer_has_systemchecks = False | ||
|
||
local_postgresql = has_package(InstalledRPM, 'postgresql-server') | ||
postgresql_contrib = has_package(InstalledRPM, 'postgresql-contrib') | ||
postgresql_evr = has_package(InstalledRPM, 'postgresql-evr') | ||
|
||
to_remove = [] | ||
to_install = ['rubygem-foreman_maintain'] | ||
modules_to_enable = [] | ||
|
||
if has_package(InstalledRPM, 'katello'): | ||
to_install.append('katello') | ||
|
||
for rpm_pkgs in self.consume(InstalledRPM): | ||
for pkg in rpm_pkgs.items: | ||
if (pkg.name.startswith('rubygem-hammer') or pkg.name.startswith('rubygem-foreman') | ||
or pkg.name.startswith('rubygem-katello') | ||
or pkg.name.startswith('rubygem-smart_proxy')): | ||
to_install.append(pkg.name) | ||
elif pkg.name.startswith('python3.11-pulp'): | ||
to_install.append(pkg.name) | ||
elif pkg.name.startswith('foreman-installer') or pkg.name.startswith('satellite-installer'): | ||
to_install.append(pkg.name) | ||
|
||
on_same_partition = True | ||
bytes_required = None | ||
bytes_available = None | ||
old_pgsql_data = False | ||
|
||
if local_postgresql: | ||
""" | ||
Handle migration of the PostgreSQL legacy-actions files. | ||
RPM cannot handle replacement of directories by symlinks by default | ||
without the %pretrans scriptlet. As PostgreSQL package is packaged wrong, | ||
we have to workaround that by migration of the PostgreSQL files | ||
before the rpm transaction is processed. | ||
""" | ||
to_install.extend(['postgresql', 'postgresql-server']) | ||
if postgresql_contrib: | ||
to_install.append('postgresql-contrib') | ||
if postgresql_evr: | ||
to_install.append('postgresql-evr') | ||
|
||
self.produce(SatelliteFacts( | ||
has_foreman=has_foreman, | ||
installer_has_systemchecks=installer_has_systemchecks, | ||
postgresql=SatellitePostgresqlFacts( | ||
local_postgresql=local_postgresql, | ||
old_var_lib_pgsql_data=old_pgsql_data, | ||
same_partition=on_same_partition, | ||
space_required=bytes_required, | ||
space_available=bytes_available, | ||
), | ||
)) | ||
|
||
repositories_to_enable = ['satellite-maintenance-6.11-for-rhel-8-x86_64-rpms'] | ||
if has_package(InstalledRPM, 'satellite'): | ||
repositories_to_enable.append('satellite-6.11-for-rhel-8-x86_64-rpms') | ||
modules_to_enable.append(Module(name='satellite', stream='el8')) | ||
to_install.append('satellite') | ||
elif has_package(InstalledRPM, 'satellite-capsule'): | ||
repositories_to_enable.append('satellite-capsule-6.11-for-rhel-8-x86_64-rpms') | ||
modules_to_enable.append(Module(name='satellite-capsule', stream='el8')) | ||
to_install.append('satellite-capsule') | ||
|
||
self.produce(RpmTransactionTasks( | ||
to_remove=to_remove, | ||
to_install=to_install, | ||
modules_to_enable=modules_to_enable | ||
) | ||
) | ||
|
||
self.produce(RepositoriesSetupTasks(to_enable=repositories_to_enable)) |
130 changes: 130 additions & 0 deletions
130
...pgrade/el8toel9/actors/satellite_upgrade_facts/tests/unit_test_satellite_upgrade_facts.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,130 @@ | ||
from leapp.libraries.common.config import mock_configs | ||
from leapp.models import InstalledRPM, Module, RepositoriesSetupTasks, RPM, RpmTransactionTasks, SatelliteFacts | ||
|
||
RH_PACKAGER = 'Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>' | ||
|
||
|
||
def fake_package(pkg_name): | ||
return RPM(name=pkg_name, 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') | ||
|
||
|
||
FOREMAN_RPM = fake_package('foreman') | ||
FOREMAN_PROXY_RPM = fake_package('foreman-proxy') | ||
KATELLO_INSTALLER_RPM = fake_package('foreman-installer-katello') | ||
KATELLO_RPM = fake_package('katello') | ||
POSTGRESQL_RPM = fake_package('postgresql-server') | ||
SATELLITE_RPM = fake_package('satellite') | ||
SATELLITE_CAPSULE_RPM = fake_package('satellite-capsule') | ||
|
||
|
||
def test_no_satellite_present(current_actor_context): | ||
current_actor_context.feed(InstalledRPM(items=[])) | ||
current_actor_context.run(config_model=mock_configs.CONFIG) | ||
message = current_actor_context.consume(SatelliteFacts) | ||
assert not message | ||
|
||
|
||
def test_satellite_present(current_actor_context): | ||
current_actor_context.feed(InstalledRPM(items=[FOREMAN_RPM])) | ||
current_actor_context.run(config_model=mock_configs.CONFIG) | ||
message = current_actor_context.consume(SatelliteFacts)[0] | ||
assert message.has_foreman | ||
|
||
|
||
def test_wrong_arch(current_actor_context): | ||
current_actor_context.feed(InstalledRPM(items=[FOREMAN_RPM])) | ||
current_actor_context.run(config_model=mock_configs.CONFIG_S390X) | ||
message = current_actor_context.consume(SatelliteFacts) | ||
assert not message | ||
|
||
|
||
def test_satellite_capsule_present(current_actor_context): | ||
current_actor_context.feed(InstalledRPM(items=[FOREMAN_PROXY_RPM])) | ||
current_actor_context.run(config_model=mock_configs.CONFIG) | ||
message = current_actor_context.consume(SatelliteFacts)[0] | ||
assert message.has_foreman | ||
|
||
|
||
def test_no_katello_installer_present(current_actor_context): | ||
current_actor_context.feed(InstalledRPM(items=[FOREMAN_RPM])) | ||
current_actor_context.run(config_model=mock_configs.CONFIG) | ||
message = current_actor_context.consume(SatelliteFacts)[0] | ||
assert not message.installer_has_systemchecks | ||
|
||
|
||
def test_katello_installer_present(current_actor_context): | ||
current_actor_context.feed(InstalledRPM(items=[FOREMAN_RPM, KATELLO_INSTALLER_RPM])) | ||
current_actor_context.run(config_model=mock_configs.CONFIG) | ||
message = current_actor_context.consume(SatelliteFacts)[0] | ||
assert not message.installer_has_systemchecks | ||
|
||
|
||
def test_enables_satellite_module(current_actor_context): | ||
current_actor_context.feed(InstalledRPM(items=[FOREMAN_RPM, SATELLITE_RPM])) | ||
current_actor_context.run(config_model=mock_configs.CONFIG) | ||
message = current_actor_context.consume(RpmTransactionTasks)[0] | ||
assert Module(name='satellite', stream='el8') in message.modules_to_enable | ||
assert Module(name='satellite-capsule', stream='el8') not in message.modules_to_enable | ||
|
||
|
||
def test_enables_satellite_capsule_module(current_actor_context): | ||
current_actor_context.feed(InstalledRPM(items=[FOREMAN_PROXY_RPM, SATELLITE_CAPSULE_RPM])) | ||
current_actor_context.run(config_model=mock_configs.CONFIG) | ||
message = current_actor_context.consume(RpmTransactionTasks)[0] | ||
assert Module(name='satellite-capsule', stream='el8') in message.modules_to_enable | ||
assert Module(name='satellite', stream='el8') not in message.modules_to_enable | ||
|
||
|
||
def test_installs_satellite_package(current_actor_context): | ||
current_actor_context.feed(InstalledRPM(items=[FOREMAN_RPM, SATELLITE_RPM])) | ||
current_actor_context.run(config_model=mock_configs.CONFIG) | ||
message = current_actor_context.consume(RpmTransactionTasks)[0] | ||
assert 'satellite' in message.to_install | ||
assert 'satellite-capsule' not in message.to_install | ||
|
||
|
||
def test_installs_satellite_capsule_package(current_actor_context): | ||
current_actor_context.feed(InstalledRPM(items=[FOREMAN_PROXY_RPM, SATELLITE_CAPSULE_RPM])) | ||
current_actor_context.run(config_model=mock_configs.CONFIG) | ||
message = current_actor_context.consume(RpmTransactionTasks)[0] | ||
assert 'satellite-capsule' in message.to_install | ||
assert 'satellite' not in message.to_install | ||
|
||
|
||
def test_detects_local_postgresql(current_actor_context): | ||
current_actor_context.feed(InstalledRPM(items=[FOREMAN_RPM, POSTGRESQL_RPM])) | ||
current_actor_context.run(config_model=mock_configs.CONFIG) | ||
|
||
satellitemsg = current_actor_context.consume(SatelliteFacts)[0] | ||
assert satellitemsg.postgresql.local_postgresql | ||
|
||
|
||
def test_detects_remote_postgresql(current_actor_context): | ||
current_actor_context.feed(InstalledRPM(items=[FOREMAN_RPM])) | ||
current_actor_context.run(config_model=mock_configs.CONFIG) | ||
|
||
satellitemsg = current_actor_context.consume(SatelliteFacts)[0] | ||
assert not satellitemsg.postgresql.local_postgresql | ||
|
||
|
||
def test_enables_right_repositories_on_satellite(current_actor_context): | ||
current_actor_context.feed(InstalledRPM(items=[FOREMAN_RPM, SATELLITE_RPM])) | ||
current_actor_context.run(config_model=mock_configs.CONFIG) | ||
|
||
rpmmessage = current_actor_context.consume(RepositoriesSetupTasks)[0] | ||
|
||
assert 'satellite-maintenance-6.11-for-rhel-8-x86_64-rpms' in rpmmessage.to_enable | ||
assert 'satellite-6.11-for-rhel-8-x86_64-rpms' in rpmmessage.to_enable | ||
assert 'satellite-capsule-6.11-for-rhel-8-x86_64-rpms' not in rpmmessage.to_enable | ||
|
||
|
||
def test_enables_right_repositories_on_capsule(current_actor_context): | ||
current_actor_context.feed(InstalledRPM(items=[FOREMAN_PROXY_RPM, SATELLITE_CAPSULE_RPM])) | ||
current_actor_context.run(config_model=mock_configs.CONFIG) | ||
|
||
rpmmessage = current_actor_context.consume(RepositoriesSetupTasks)[0] | ||
|
||
assert 'satellite-maintenance-6.11-for-rhel-8-x86_64-rpms' in rpmmessage.to_enable | ||
assert 'satellite-6.11-for-rhel-8-x86_64-rpms' not in rpmmessage.to_enable | ||
assert 'satellite-capsule-6.11-for-rhel-8-x86_64-rpms' in rpmmessage.to_enable |