Skip to content

Commit

Permalink
Add an option to remove leapp configurations, but keep them by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Sandakov committed Jan 2, 2025
1 parent 5665584 commit 7dd51a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 5 additions & 3 deletions cloudlinux7to8/actions/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
class LeappInstallation(action.ActiveAction):
pkgs_to_install: typing.List[str]
elevate_release_rpm_url: str
remove_logs_on_finish: bool

def __init__(self, elevate_release_rpm_url: str, pkgs_to_install: typing.List[str]):
def __init__(self, elevate_release_rpm_url: str, pkgs_to_install: typing.List[str], remove_logs_on_finish: bool = False):
self.name = "installing leapp"
self.pkgs_to_install = pkgs_to_install
self.elevate_release_rpm_url = elevate_release_rpm_url
self.remove_logs_on_finish = remove_logs_on_finish

def _prepare_action(self) -> action.ActionResult:
if not rpm.is_package_installed("elevate-release"):
Expand Down Expand Up @@ -58,11 +60,11 @@ def remove_all(self, include_logs: bool = True) -> None:
shutil.rmtree(directory)

def _post_action(self) -> action.ActionResult:
self.remove_all()
self.remove_all(include_logs=self.remove_leapp_logs)
return action.ActionResult()

def _revert_action(self) -> action.ActionResult:
self.remove_all(False)
self.remove_all(include_logs=False)
return action.ActionResult()

def estimate_prepare_time(self) -> int:
Expand Down
7 changes: 6 additions & 1 deletion cloudlinux7to8/upgrader.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self):
self.disable_spamassasin_plugins = False
self.amavis_upgrade_allowed = False
self.allow_raid_devices = False
self.remove_leapp_logs = False

def __repr__(self) -> str:
attrs = ", ".join(f"{k}={getattr(self, k)!r}" for k in (
Expand Down Expand Up @@ -113,7 +114,8 @@ def construct_actions(
"leapp-deps-0.17.0-1.el7",
"leapp-upgrade-el7toel8-0.20.0-2.el7",
"leapp-upgrade-el7toel8-deps-0.20.0-2.el7",
]
],
remove_logs_on_finish=self.remove_leapp_logs
),
],
"Prepare configurations": [
Expand Down Expand Up @@ -309,13 +311,16 @@ def parse_args(self, args: typing.Sequence[str]) -> None:
help="Allow to upgrade amavis antivirus even if there is not enough RAM available.")
parser.add_argument("--allow-raid-devices", action="store_true", dest="allow_raid_devices", default=False,
help="Allow to have direct RAID devices in /etc/fstab. This could lead to unbootable system after the conversion so use the option on your own risk.")
parser.add_argument("--remove-leapp-logs", action="store_true", dest="remove_leapp_logs", default=False,
help="Remove leapp logs after the conversion. By default, the logs are removed after the conversion.")
options = parser.parse_args(args)

self.upgrade_postgres_allowed = options.upgrade_postgres_allowed
self.remove_unknown_perl_modules = options.remove_unknown_perl_modules
self.disable_spamassasin_plugins = options.disable_spamassasin_plugins
self.amavis_upgrade_allowed = options.amavis_upgrade_allowed
self.allow_raid_devices = options.allow_raid_devices
self.remove_leapp_logs = options.remove_leapp_logs


class CloudLinux7to8Factory(DistUpgraderFactory):
Expand Down

0 comments on commit 7dd51a4

Please sign in to comment.