Skip to content

Commit

Permalink
Move common Satellite Upgrade code to "common"
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Feb 21, 2024
1 parent b875ae2 commit be261cd
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import glob
import os

from leapp.actors import Actor
from leapp.models import SatelliteFacts
from leapp.tags import ApplicationsPhaseTag, IPUWorkflowTag

SYSTEMD_WANTS_BASE = '/etc/systemd/system/multi-user.target.wants/'
SERVICES_TO_DISABLE = ['dynflow-sidekiq@*', 'foreman', 'foreman-proxy',
'httpd', 'postgresql', 'pulpcore-api', 'pulpcore-content',
'pulpcore-worker@*', 'tomcat']


class SatelliteUpgradeServices(Actor):
"""
Reconfigure Satellite services
"""

name = 'satellite_upgrade_services'
consumes = (SatelliteFacts,)
produces = ()
tags = (IPUWorkflowTag, ApplicationsPhaseTag)

def process(self):
facts = next(self.consume(SatelliteFacts), None)
if not facts or not facts.has_foreman:
return

# disable services, will be re-enabled by the installer
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 Exception as e: # pylint: disable=broad-except
self.log.warning('Failed disabling service {}: {}'.format(service, e))
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@
POSTGRESQL_USER = 'postgres'
POSTGRESQL_GROUP = 'postgres'

SYSTEMD_WANTS_BASE = '/etc/systemd/system/multi-user.target.wants/'
SERVICES_TO_DISABLE = ['dynflow-sidekiq@*', 'foreman', 'foreman-proxy',
'httpd', 'postgresql', 'pulpcore-api', 'pulpcore-content',
'pulpcore-worker@*', 'tomcat']


class SatelliteUpgradeDataMigration(Actor):
"""
Reconfigure Satellite services and migrate PostgreSQL data
Migrate Satellite PostgreSQL data
"""

name = 'satellite_upgrade_data_migration'
Expand All @@ -32,14 +27,6 @@ def process(self):
if not facts or not facts.has_foreman:
return

# disable services, will be re-enabled by the installer
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 Exception as e: # pylint: disable=broad-except
self.log.warning('Failed disabling service {}: {}'.format(service, e))

if facts.postgresql.local_postgresql and os.path.exists(POSTGRESQL_SCL_DATA_PATH):
# we can assume POSTGRESQL_DATA_PATH exists and is empty
# move PostgreSQL data to the new home
Expand Down

0 comments on commit be261cd

Please sign in to comment.