Skip to content

Commit

Permalink
Configure RHN data for the isolated environment via Leapp task messages
Browse files Browse the repository at this point in the history
  • Loading branch information
prilr committed Mar 6, 2024
1 parent df21e77 commit 707544a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
35 changes: 33 additions & 2 deletions repos/system_upgrade/cloudlinux/actors/checkcllicense/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,35 @@
from leapp import reporting
from leapp.reporting import Report
from leapp.tags import ChecksPhaseTag, IPUWorkflowTag
from leapp.libraries.stdlib import CalledProcessError, run
from leapp.libraries.stdlib import CalledProcessError, run, api
from leapp.libraries.common.cllaunch import run_on_cloudlinux

from leapp.models import (
RequiredUpgradeInitramPackages, # deprecated
TargetUserSpaceUpgradeTasks,
CopyFile
)

import os

RHN_CONFIG_DIR = '/etc/sysconfig/rhn'
REQUIRED_PKGS = ['dnf-plugin-spacewalk', 'rhn-client-tools']


def rhn_to_target_userspace():
"""
Produce messages to copy RHN configuration files and packages to the target userspace
"""
files_to_copy = []
for dirpath, _, filenames in os.walk(RHN_CONFIG_DIR):
for filename in filenames:
src_path = os.path.join(dirpath, filename)
if os.path.isfile(src_path):
files_to_copy.append(CopyFile(src=src_path))

api.produce(RequiredUpgradeInitramPackages(packages=REQUIRED_PKGS))
api.produce(TargetUserSpaceUpgradeTasks(install_rpms=REQUIRED_PKGS, copy_files=files_to_copy))


class CheckClLicense(Actor):
"""
Expand All @@ -15,12 +39,17 @@ class CheckClLicense(Actor):

name = 'check_cl_license'
consumes = ()
produces = (Report,)
produces = (Report, RequiredUpgradeInitramPackages, TargetUserSpaceUpgradeTasks)
tags = (ChecksPhaseTag, IPUWorkflowTag)

system_id_path = '/etc/sysconfig/rhn/systemid'
rhn_check_bin = '/usr/sbin/rhn_check'

# # Copy RHN data independent from RHSM config
# if os.path.isdir('/etc/sysconfig/rhn'):
# run(['rm', '-rf', os.path.join(target_etc, 'sysconfig/rhn')])
# context.copytree_from('/etc/sysconfig/rhn', os.path.join(target_etc, 'sysconfig/rhn'))

@run_on_cloudlinux
def process(self):
res = None
Expand All @@ -40,3 +69,5 @@ def process(self):
reporting.Flags([reporting.Flags.INHIBITOR]),
reporting.Remediation(hint=remediation),
])
else:
rhn_to_target_userspace()
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,6 @@ def _prep_repository_access(context, target_userspace):
target_yum_repos_d = os.path.join(target_etc, 'yum.repos.d')
backup_yum_repos_d = os.path.join(target_etc, 'yum.repos.d.backup')

# Copy RHN data independent from RHSM config
if os.path.isdir('/etc/sysconfig/rhn'):
run(['rm', '-rf', os.path.join(target_etc, 'sysconfig/rhn')])
context.copytree_from('/etc/sysconfig/rhn', os.path.join(target_etc, 'sysconfig/rhn'))

if not rhsm.skip_rhsm():
run(['rm', '-rf', os.path.join(target_etc, 'pki')])
run(['rm', '-rf', os.path.join(target_etc, 'rhsm')])
Expand Down

0 comments on commit 707544a

Please sign in to comment.