Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert GRUB install device before conversion #7

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 15 additions & 24 deletions debian11to12/upgrader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,37 @@
from pleskdistup import actions
from pleskdistup.common import action, feedback
from pleskdistup.phase import Phase
from pleskdistup.upgrader import DistUpgrader, DistUpgraderFactory, PathType, SystemDescription
from pleskdistup.upgrader import dist, DistUpgrader, DistUpgraderFactory, PathType

import debian11to12.config


class Debian11to12Upgrader(DistUpgrader):
_os_from_name = "Debian"
_os_from_version = "11"
_os_to_name = "Debian"
_os_to_version = "12"
_distro_from = dist.Debian("11")
_distro_to = dist.Debian("12")


def __init__(self):
super().__init__()

def __repr__(self) -> str:
attrs = ", ".join(f"{k}={getattr(self, k)!r}" for k in (
"_os_from_name", "_os_from_version",
"_os_to_name", "_os_to_version",
))
return f"{self.__class__.__name__}({attrs})"
return f"{self.__class__.__name__}(From {self._distro_from}, To {self._distro_to})"

def __str__(self) -> str:
return f"{self.__class__.__name__}"

@classmethod
def supports(
cls,
from_system: typing.Optional[SystemDescription] = None,
to_system: typing.Optional[SystemDescription] = None,
from_system: typing.Optional[dist.Distro] = None,
to_system: typing.Optional[dist.Distro] = None
) -> bool:
def matching_system(system: SystemDescription, os_name: str, os_version: str) -> bool:
return (
(system.os_name is None or system.os_name == os_name)
and (system.os_version is None or system.os_version == os_version)
)

return (
(from_system is None or matching_system(from_system, cls._os_from_name, cls._os_from_version))
and (to_system is None or matching_system(to_system, cls._os_to_name, cls._os_to_version))
(from_system is None or cls._distro_from == from_system)
and (to_system is None or cls._distro_to == to_system)
)


@property
def upgrader_name(self) -> str:
return "Plesk::Debian11to12Upgrader"
Expand Down Expand Up @@ -78,7 +68,7 @@ def construct_actions(
options: typing.Any,
phase: Phase
) -> typing.Dict[str, typing.List[action.ActiveAction]]:
new_os = f"{self._os_to_name} {self._os_to_version}"
new_os = f"{self._distro_to}"
return {
"Prepare": [
actions.HandleConversionStatus(options.status_flag_path, options.completion_flag_path),
Expand Down Expand Up @@ -137,10 +127,11 @@ def get_check_actions(self, options: typing.Any, phase: Phase) -> typing.List[ac
actions.AssertMinPhpVersion("7.4"),
actions.AssertDpkgNotLocked(),
actions.AssertNotInContainer(),
actions.AssertGrubInstallDeviceExists(),
]

def parse_args(self, args: typing.Sequence[str]) -> None:
DESC_MESSAGE = f"""Use this upgrader to dist-upgrade an {self._os_from_name} {self._os_from_version} server with Plesk to {self._os_to_name} {self._os_to_version}. The process consists of the following general stages:
DESC_MESSAGE = f"""Use this upgrader to dist-upgrade an {self._distro_from} server with Plesk to {self._distro_to} The process consists of the following general stages:

-- Preparation (about 5 minutes) - The OS is prepared for the conversion.
-- Conversion (about 15 minutes) - Plesk and system dist-upgrade is performed.
Expand Down Expand Up @@ -179,8 +170,8 @@ def __str__(self) -> str:

def supports(
self,
from_system: typing.Optional[SystemDescription] = None,
to_system: typing.Optional[SystemDescription] = None
from_system: typing.Optional[dist.Distro] = None,
to_system: typing.Optional[dist.Distro] = None
) -> bool:
return Debian11to12Upgrader.supports(from_system, to_system)

Expand Down
2 changes: 1 addition & 1 deletion dist-upgrader
Submodule dist-upgrader updated 71 files
+26 −0 .github/workflows/flake8.yml
+25 −0 .github/workflows/mypy.yml
+22 −0 .github/workflows/tests.yml
+1 −1 BUCK
+1 −1 LICENSE
+1 −0 README.md
+1 −1 buck.defs.py
+0 −8 defs.py
+6 −0 mypy.ini
+1 −1 pleskdistup/BUCK
+1 −1 pleskdistup/__init__.py
+3 −1 pleskdistup/actions/__init__.py
+126 −20 pleskdistup/actions/common.py
+543 −3 pleskdistup/actions/common_checks.py
+246 −15 pleskdistup/actions/distupgrade.py
+93 −0 pleskdistup/actions/emails.py
+279 −2 pleskdistup/actions/extensions.py
+31 −0 pleskdistup/actions/grub.py
+1 −1 pleskdistup/actions/mariadb.py
+5 −1 pleskdistup/actions/packages.py
+126 −35 pleskdistup/actions/plesk.py
+88 −5 pleskdistup/actions/spamassassin.py
+168 −3 pleskdistup/actions/systemd.py
+1 −1 pleskdistup/common/BUCK
+1 −1 pleskdistup/common/LICENSE
+3 −1 pleskdistup/common/src/__init__.py
+33 −15 pleskdistup/common/src/action.py
+144 −47 pleskdistup/common/src/dist.py
+11 −1 pleskdistup/common/src/dpkg.py
+11 −2 pleskdistup/common/src/feedback.py
+33 −14 pleskdistup/common/src/files.py
+159 −24 pleskdistup/common/src/leapp_configs.py
+35 −11 pleskdistup/common/src/log.py
+4 −4 pleskdistup/common/src/mariadb.py
+5 −5 pleskdistup/common/src/motd.py
+25 −15 pleskdistup/common/src/packages.py
+32 −0 pleskdistup/common/src/php.py
+123 −9 pleskdistup/common/src/plesk.py
+43 −0 pleskdistup/common/src/postgres.py
+125 −13 pleskdistup/common/src/rpm.py
+62 −7 pleskdistup/common/src/systemd.py
+1 −1 pleskdistup/common/src/util.py
+116 −7 pleskdistup/common/src/version.py
+32 −4 pleskdistup/common/src/writers.py
+84 −102 pleskdistup/common/tests/actionstests.py
+32 −25 pleskdistup/common/tests/distrotests.py
+1 −1 pleskdistup/common/tests/feedbacktests.py
+1 −1 pleskdistup/common/tests/filestests.py
+568 −5 pleskdistup/common/tests/leapp_configs_tests.py
+47 −0 pleskdistup/common/tests/logtests.py
+1 −1 pleskdistup/common/tests/mariadbtests.py
+9 −8 pleskdistup/common/tests/motdtests.py
+176 −0 pleskdistup/common/tests/phptests.py
+130 −0 pleskdistup/common/tests/plesktests.py
+177 −15 pleskdistup/common/tests/rpmtests.py
+1 −1 pleskdistup/common/tests/test_main.py
+1 −1 pleskdistup/common/tests/testcase.py
+1 −1 pleskdistup/common/tests/utiltests.py
+137 −2 pleskdistup/common/tests/versiontests.py
+1 −1 pleskdistup/config.py
+5 −2 pleskdistup/convert.py
+1 −1 pleskdistup/debian/__init__.py
+218 −96 pleskdistup/main.py
+11 −2 pleskdistup/messages.py
+1 −1 pleskdistup/phase.py
+5 −4 pleskdistup/registry.py
+1 −1 pleskdistup/resume.py
+0 −23 pleskdistup/sysdesc.py
+1 −1 pleskdistup/ubuntu/__init__.py
+6 −18 pleskdistup/upgrader.py
+1 −1 product.defs.py
Loading