diff --git a/repos/system_upgrade/common/actors/satellite_upgrade_services/actor.py b/repos/system_upgrade/common/actors/satellite_upgrade_services/actor.py index 3cda49a92d..d14edfb75c 100644 --- a/repos/system_upgrade/common/actors/satellite_upgrade_services/actor.py +++ b/repos/system_upgrade/common/actors/satellite_upgrade_services/actor.py @@ -2,8 +2,8 @@ import os from leapp.actors import Actor -from leapp.models import SatelliteFacts -from leapp.tags import ApplicationsPhaseTag, IPUWorkflowTag +from leapp.models import SatelliteFacts, SystemdServicesTasks +from leapp.tags import FactsPhaseTag, IPUWorkflowTag SYSTEMD_WANTS_BASE = '/etc/systemd/system/multi-user.target.wants/' SERVICES_TO_DISABLE = ['dynflow-sidekiq@*', 'foreman', 'foreman-proxy', @@ -18,8 +18,8 @@ class SatelliteUpgradeServices(Actor): name = 'satellite_upgrade_services' consumes = (SatelliteFacts,) - produces = () - tags = (IPUWorkflowTag, ApplicationsPhaseTag) + produces = (SystemdServicesTasks,) + tags = (IPUWorkflowTag, FactsPhaseTag) def process(self): facts = next(self.consume(SatelliteFacts), None) @@ -27,9 +27,8 @@ def process(self): return # disable services, will be re-enabled by the installer + services_to_disable = [] for service_name in SERVICES_TO_DISABLE: for service in glob.glob(os.path.join(SYSTEMD_WANTS_BASE, '{}.service'.format(service_name))): - try: - os.unlink(service) - except OSError as e: - self.log.warning('Failed disabling service {}: {}'.format(service, e)) + services_to_disable.append(os.path.basename(service)) + self.produce(SystemdServicesTasks(to_disable=services_to_disable)) diff --git a/repos/system_upgrade/common/actors/satellite_upgrade_services/tests/unit_test_satellite_upgrade_services.py b/repos/system_upgrade/common/actors/satellite_upgrade_services/tests/unit_test_satellite_upgrade_services.py new file mode 100644 index 0000000000..f41621ab5e --- /dev/null +++ b/repos/system_upgrade/common/actors/satellite_upgrade_services/tests/unit_test_satellite_upgrade_services.py @@ -0,0 +1,24 @@ +import glob + +from leapp.models import SatelliteFacts, SatellitePostgresqlFacts, SystemdServicesTasks + + +def test_disable_httpd(monkeypatch, current_actor_context): + def mock_glob(): + orig_glob = glob.glob + + def mocked_glob(pathname): + if pathname == '/etc/systemd/system/multi-user.target.wants/httpd.service': + return [pathname] + return orig_glob(pathname) + + return mocked_glob + + monkeypatch.setattr('glob.glob', mock_glob()) + + current_actor_context.feed(SatelliteFacts(has_foreman=True, + postgresql=SatellitePostgresqlFacts(local_postgresql=False))) + current_actor_context.run() + + message = current_actor_context.consume(SystemdServicesTasks)[0] + assert 'httpd.service' in message.to_disable