diff --git a/coriolis/osmorphing/amazon.py b/coriolis/osmorphing/amazon.py new file mode 100644 index 000000000..4c67c418b --- /dev/null +++ b/coriolis/osmorphing/amazon.py @@ -0,0 +1,18 @@ +# Copyright 2023 Cloudbase Solutions Srl +# All Rights Reserved. + +from coriolis.osmorphing import redhat +from coriolis.osmorphing.osdetect import amazon as amazon_detect + + +AMAZON_DISTRO_NAME_IDENTIFIER = amazon_detect.AMAZON_DISTRO_NAME + + +class BaseAmazonLinuxOSMorphingTools(redhat.BaseRedHatMorphingTools): + @classmethod + def check_os_supported(cls, detected_os_info): + if detected_os_info['distribution_name'] != ( + AMAZON_DISTRO_NAME_IDENTIFIER): + return False + return cls._version_supported_util( + detected_os_info['release_version'], minimum=2) diff --git a/coriolis/osmorphing/osdetect/amazon.py b/coriolis/osmorphing/osdetect/amazon.py new file mode 100644 index 000000000..887e2f171 --- /dev/null +++ b/coriolis/osmorphing/osdetect/amazon.py @@ -0,0 +1,27 @@ +# Copyright 2023 Cloudbase Solutions Srl +# All Rights Reserved. + +from coriolis import constants +from coriolis.osmorphing.osdetect import base + + +AMAZON_DISTRO_IDENTIFIER = "amzn" +AMAZON_DISTRO_NAME = "Amazon Linux" + + +class AmazonLinuxOSDetectTools(base.BaseLinuxOSDetectTools): + + def detect_os(self): + info = {} + os_release = self._get_os_release() + osid = os_release.get("ID") + osname = os_release.get("NAME") + if osid == AMAZON_DISTRO_IDENTIFIER or osname == AMAZON_DISTRO_NAME: + version = os_release.get("VERSION") + friendly_name = "%s %s" % (AMAZON_DISTRO_NAME, version) + info = { + "os_type": constants.OS_TYPE_LINUX, + "distribution_name": AMAZON_DISTRO_NAME, + "release_version": version, + "friendly_release_name": friendly_name} + return info diff --git a/coriolis/osmorphing/osdetect/manager.py b/coriolis/osmorphing/osdetect/manager.py index dee136e9a..3ed01e781 100644 --- a/coriolis/osmorphing/osdetect/manager.py +++ b/coriolis/osmorphing/osdetect/manager.py @@ -6,6 +6,7 @@ from coriolis import constants from coriolis import exception from coriolis.osmorphing.osdetect import base +from coriolis.osmorphing.osdetect import amazon from coriolis.osmorphing.osdetect import centos from coriolis.osmorphing.osdetect import coreos from coriolis.osmorphing.osdetect import debian @@ -22,6 +23,7 @@ LINUX_OS_DETECTION_TOOLS = [ + amazon.AmazonLinuxOSDetectTools, centos.CentOSOSDetectTools, coreos.CoreOSOSDetectTools, debian.DebianOSDetectTools,