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

Add OSMorphing Support for Amazon Linux #269

Merged
merged 1 commit into from
Mar 18, 2024
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
21 changes: 21 additions & 0 deletions coriolis/osmorphing/amazon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2023 Cloudbase Solutions Srl
# All Rights Reserved.

from coriolis.osmorphing.osdetect import amazon as amazon_detect
from coriolis.osmorphing import redhat


AMAZON_DISTRO_NAME_IDENTIFIER = amazon_detect.AMAZON_DISTRO_NAME


class BaseAmazonLinuxOSMorphingTools(redhat.BaseRedHatMorphingTools):

UEFI_GRUB_LOCATION = "/boot/efi/EFI/amzn"

@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)
27 changes: 27 additions & 0 deletions coriolis/osmorphing/osdetect/amazon.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion coriolis/osmorphing/osdetect/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from coriolis import constants
from coriolis import exception
from coriolis.osmorphing.osdetect import amazon
from coriolis.osmorphing.osdetect import base
from coriolis.osmorphing.osdetect import centos
from coriolis.osmorphing.osdetect import coreos
Expand All @@ -17,11 +18,11 @@
from coriolis.osmorphing.osdetect import ubuntu
from coriolis.osmorphing.osdetect import windows


LOG = logging.getLogger(__name__)


LINUX_OS_DETECTION_TOOLS = [
amazon.AmazonLinuxOSDetectTools,
centos.CentOSOSDetectTools,
coreos.CoreOSOSDetectTools,
debian.DebianOSDetectTools,
Expand Down