forked from AlmaLinux/leapp-repository
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from cloudlinux/clos-3211-local-cln-switch
Switch CLN channel locally until the last stage of the upgrade
- Loading branch information
Showing
11 changed files
with
163 additions
and
286 deletions.
There are no files selected for viewing
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
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
61 changes: 0 additions & 61 deletions
61
repos/system_upgrade/cloudlinux/actors/checkrhnclienttools/actor.py
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
repos/system_upgrade/cloudlinux/actors/checkrhnclienttools/libraries/version.py
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
repos/system_upgrade/cloudlinux/actors/copycllicense/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,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
59
repos/system_upgrade/cloudlinux/actors/pinclnmirror/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,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) |
19 changes: 10 additions & 9 deletions
19
...nux/actors/switchclnchannelreset/actor.py → ...oudlinux/actors/switchclnchannel/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
Oops, something went wrong.