Skip to content
3 changes: 3 additions & 0 deletions packaging/leapp-repository.spec
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ Conflicts: leapp-upgrade-el7toel8

%endif

# Requires tools which allow switching between channels
Requires: cln-switch-channel = 2

# IMPORTANT: every time the requirements are changed, increment number by one
# - same for Provides in deps subpackage
Requires: leapp-repository-dependencies = %{leapp_repo_deps}
Expand Down
27 changes: 1 addition & 26 deletions repos/system_upgrade/cloudlinux/actors/checkcllicense/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,6 @@

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(TargetUserSpacePreupgradeTasks(install_rpms=REQUIRED_PKGS, copy_files=files_to_copy))
api.produce(TargetUserSpaceUpgradeTasks(install_rpms=REQUIRED_PKGS, copy_files=files_to_copy))


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

name = 'check_cl_license'
consumes = ()
produces = (Report, TargetUserSpacePreupgradeTasks, TargetUserSpaceUpgradeTasks)
produces = (Report,)
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 @@ -69,5 +46,3 @@ def process(self):
reporting.Groups([reporting.Groups.INHIBITOR]),
reporting.Remediation(hint=remediation),
])
else:
rhn_to_target_userspace()

This file was deleted.

This file was deleted.

44 changes: 44 additions & 0 deletions repos/system_upgrade/cloudlinux/actors/copycllicense/actor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os
from leapp.actors import Actor
from leapp.reporting import Report
from leapp.tags import ChecksPhaseTag, IPUWorkflowTag
from leapp.libraries.common.cllaunch import run_on_cloudlinux
from leapp.libraries.stdlib import api
from leapp.models import (
TargetUserSpacePreupgradeTasks,
CopyFile
)


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


class CopyClLicense(Actor):
"""
Produce task to copy CloudLinux license files to target system.
"""

name = 'copy_rhn_client_tools_config'
consumes = ()
produces = (Report, TargetUserSpacePreupgradeTasks)
tags = (ChecksPhaseTag, IPUWorkflowTag)

@run_on_cloudlinux
def process(self):
"""
Produce artifacts to copy RHN configuration files
and install packages to the target userspace,
including up2date and systemid.
"""
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(TargetUserSpacePreupgradeTasks(
install_rpms=REQUIRED_PKGS,
copy_files=files_to_copy
))
59 changes: 59 additions & 0 deletions repos/system_upgrade/cloudlinux/actors/pinclnmirror/actor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import json
import os

from leapp.actors import Actor
from leapp.libraries.stdlib import api
from leapp.libraries.common.cllaunch import run_on_cloudlinux
from leapp.libraries.common.cln_switch import get_target_userspace_path
from leapp.tags import DownloadPhaseTag, IPUWorkflowTag
from leapp.libraries.common.config.version import get_target_major_version


class PinClnMirror(Actor):
"""
Save CLN mirror that was used last time.
"""

name = 'pin_cln_mirror'
consumes = ()
produces = ()
tags = (IPUWorkflowTag, DownloadPhaseTag.Before)

CLN_REPO_ID = "cloudlinux-x86_64-server-%s"
DEFAULT_CLN_MIRROR = "https://xmlrpc.cln.cloudlinux.com/XMLRPC/"

@run_on_cloudlinux
def process(self):
"""Pin CLN mirror"""
target_userspace = get_target_userspace_path()
api.current_logger().info("Pin CLN mirror: target userspace=%s", target_userspace)

# load last mirror URL from dnf spacewalk plugin cache
spacewalk_settings = {}

# find the mirror used in the last transaction
# (expecting to find the one used in dnf_package_download actor)
spacewalk_json_path = os.path.join(target_userspace, 'var/lib/dnf/_spacewalk.json')
try:
with open(spacewalk_json_path) as file:
spacewalk_settings = json.load(file)
except (OSError, IOError, ValueError):
api.current_logger().error(
"No spacewalk settings found in %s - can't identify the last used CLN mirror",
spacewalk_json_path,
)

mirror_url = spacewalk_settings.get(
self.CLN_REPO_ID % get_target_major_version(), {}
).get("url", [self.DEFAULT_CLN_MIRROR])[0]

# pin mirror
mirrorlist_path = os.path.join(target_userspace, 'etc/mirrorlist')
with open(mirrorlist_path, 'w') as file:
file.write(mirror_url + '\n')
api.current_logger().info("Pin CLN mirror %s in %s", mirror_url, mirrorlist_path)

up2date_path = os.path.join(target_userspace, 'etc/sysconfig/rhn/up2date')
with open(up2date_path, 'a+') as file:
file.write('\nmirrorURL[comment]=Set mirror URL to /etc/mirrorlist\nmirrorURL=file:///etc/mirrorlist\n')
api.current_logger().info("Updated up2date_path %s", up2date_path)
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
import os
import json

from leapp.actors import Actor
from leapp.libraries.stdlib import api
from leapp.tags import IPUWorkflowTag, TargetTransactionChecksPhaseTag
from leapp.tags import FirstBootPhaseTag, IPUWorkflowTag
from leapp.libraries.stdlib import CalledProcessError
from leapp.libraries.common.cllaunch import run_on_cloudlinux
from leapp.libraries.common.cln_switch import cln_switch
from leapp.libraries.common.config.version import get_source_major_version
from leapp.libraries.common.cln_switch import cln_switch, get_target_userspace_path
from leapp import reporting
from leapp.reporting import Report
from leapp.libraries.common.config.version import get_target_major_version


DEFAULT_CLN_MIRROR = "https://xmlrpc.cln.cloudlinux.com/XMLRPC/"


class SwitchClnChannelReset(Actor):
class SwitchClnChannelDownload(Actor):
"""
Reset the CLN channel to CL7 to keep the system state consistent before the main upgrade phase.
Permanently switch CLN channel to target os version.
"""

name = "switch_cln_channel_reset"
name = "switch_cln_channel"
consumes = ()
produces = (Report,)
tags = (IPUWorkflowTag, TargetTransactionChecksPhaseTag.After)
tags = (FirstBootPhaseTag, IPUWorkflowTag)

@run_on_cloudlinux
def process(self):
try:
cln_switch(target=get_source_major_version())
cln_switch(target=int(get_target_major_version()))
except CalledProcessError as e:
reporting.create_report(
[
reporting.Title(
"Failed to switch CloudLinux Network channel."
"Failed to switch CloudLinux Network channel from 7 to 8."
),
reporting.Summary(
"Command {} failed with exit code {}."
Expand Down
Loading
Loading