diff --git a/cloudlinux7to8/actions/installation.py b/cloudlinux7to8/actions/installation.py index df92b4f..d010fcd 100644 --- a/cloudlinux7to8/actions/installation.py +++ b/cloudlinux7to8/actions/installation.py @@ -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"): @@ -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: diff --git a/cloudlinux7to8/upgrader.py b/cloudlinux7to8/upgrader.py index 53efaa7..3ce10de 100644 --- a/cloudlinux7to8/upgrader.py +++ b/cloudlinux7to8/upgrader.py @@ -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 ( @@ -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": [ @@ -309,6 +311,8 @@ 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 @@ -316,6 +320,7 @@ def parse_args(self, args: typing.Sequence[str]) -> None: 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):