From 6f9914fc5599df66b94229ddf0eb61c34493d074 Mon Sep 17 00:00:00 2001 From: Mikhail Sandakov Date: Mon, 7 Oct 2024 16:27:17 +0300 Subject: [PATCH] Introduce an action to create a leapp mapping and abopt it on finishing stage --- centos2almaconverter/actions/packages.py | 26 ++++++++++++++++++++++++ centos2almaconverter/upgrader.py | 1 + 2 files changed, 27 insertions(+) diff --git a/centos2almaconverter/actions/packages.py b/centos2almaconverter/actions/packages.py index c757908..1086659 100644 --- a/centos2almaconverter/actions/packages.py +++ b/centos2almaconverter/actions/packages.py @@ -456,3 +456,29 @@ def _do_check(self) -> bool: return False return True + +class HandleInternetxRepository(action.ActiveAction): + KNOWN_INTERNETX_REPO_FILES = ["internetx.repo"] + + def __init__(self): + self.name = "handling InternetX repository" + + def is_required(self) -> bool: + return len(files.find_files_case_insensitive("/etc/yum.repos.d", self.KNOWN_INTERNETX_REPO_FILES)) > 0 + + def _prepare_action(self) -> action.ActionResult: + for file in files.find_files_case_insensitive("/etc/yum.repos.d", self.KNOWN_INTERNETX_REPO_FILES): + files.backup_file(file) + leapp_configs.add_repositories_mapping([file]) + return action.ActionResult() + + def _post_action(self) -> action.ActionResult: + for file in files.find_files_case_insensitive("/etc/yum.repos.d", self.KNOWN_INTERNETX_REPO_FILES): + files.remove_backup(file) + leapp_configs.adopt_repositories(file) + return action.ActionResult() + + def _revert_action(self) -> action.ActionResult: + for file in files.find_files_case_insensitive("/etc/yum.repos.d", self.KNOWN_INTERNETX_REPO_FILES): + files.restore_file_from_backup(file) + return action.ActionResult() diff --git a/centos2almaconverter/upgrader.py b/centos2almaconverter/upgrader.py index 5f1b892..f1970af 100644 --- a/centos2almaconverter/upgrader.py +++ b/centos2almaconverter/upgrader.py @@ -158,6 +158,7 @@ def construct_actions( common_actions.DisableSelinuxDuringUpgrade(), centos2alma_actions.RestoreMissingNginx(), common_actions.ReinstallAmavisAntivirus(), + centos2alma_actions.HandleInternetxRepository(), ], "First plesk start": [ common_actions.StartPleskBasicServices(),