Skip to content
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
3 changes: 1 addition & 2 deletions coriolis/osmorphing/amazon.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
from oslo_log import log as logging

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


AMAZON_DISTRO_NAME_IDENTIFIER = amazon_detect.AMAZON_DISTRO_NAME
AMAZON_DISTRO_NAME_IDENTIFIER = "Amazon Linux"

LOG = logging.getLogger(__name__)

Expand Down
15 changes: 10 additions & 5 deletions coriolis/osmorphing/centos.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
from oslo_log import log as logging

from coriolis import exception
from coriolis.osmorphing.osdetect import centos as centos_detect
from coriolis.osmorphing import redhat
from coriolis import utils


CENTOS_DISTRO_IDENTIFIER = centos_detect.CENTOS_DISTRO_IDENTIFIER
CENTOS_STREAM_DISTRO_IDENTIFIER = centos_detect.CENTOS_STREAM_DISTRO_IDENTIFIER
CENTOS_DISTRO_IDENTIFIER = "CentOS"
CENTOS_STREAM_DISTRO_IDENTIFIER = "CentOS Stream"
CENTOS_LINUX_DISTRO_IDENTIFIER = "CentOS Linux"
ALMALINUX_DISTRO_IDENTIFIER = "AlmaLinux"

LOG = logging.getLogger(__name__)

Expand All @@ -22,11 +23,15 @@ class BaseCentOSMorphingTools(redhat.BaseRedHatMorphingTools):
@classmethod
def check_os_supported(cls, detected_os_info):
supported_oses = [
CENTOS_STREAM_DISTRO_IDENTIFIER, CENTOS_DISTRO_IDENTIFIER]
CENTOS_STREAM_DISTRO_IDENTIFIER,
CENTOS_DISTRO_IDENTIFIER,
CENTOS_LINUX_DISTRO_IDENTIFIER,
ALMALINUX_DISTRO_IDENTIFIER,
]
if detected_os_info['distribution_name'] not in supported_oses:
return False
return cls._version_supported_util(
detected_os_info['release_version'], minimum=6)
detected_os_info['release_version'], minimum=7)

def enable_repos(self, repo_names):
"""Enable repositories for CentOS.
Expand Down
11 changes: 6 additions & 5 deletions coriolis/osmorphing/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from oslo_log import log as logging

from coriolis import exception
from coriolis.osmorphing.osdetect import oracle as oracle_detect
from coriolis.osmorphing import redhat
from coriolis import utils


ORACLE_DISTRO_IDENTIFIER = oracle_detect.ORACLE_DISTRO_IDENTIFIER
ORACLE_DISTRO_IDENTIFIER = "Oracle Linux"
ORACLE_LINUX_SERVER_DISTRO_IDENTIFIER = "Oracle Linux Server"

LOG = logging.getLogger(__name__)

Expand All @@ -18,11 +18,12 @@ class BaseOracleMorphingTools(redhat.BaseRedHatMorphingTools):

@classmethod
def check_os_supported(cls, detected_os_info):
if detected_os_info['distribution_name'] != (
ORACLE_DISTRO_IDENTIFIER):
if detected_os_info['distribution_name'] not in (
ORACLE_DISTRO_IDENTIFIER,
ORACLE_LINUX_SERVER_DISTRO_IDENTIFIER):
return False
return cls._version_supported_util(
detected_os_info['release_version'], minimum=6)
detected_os_info['release_version'], minimum=7)

def enable_repos(self, repo_names):
"""Enable repositories for Oracle Linux.
Expand Down
27 changes: 0 additions & 27 deletions coriolis/osmorphing/osdetect/amazon.py

This file was deleted.

37 changes: 37 additions & 0 deletions coriolis/osmorphing/osdetect/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
import abc
import os

from oslo_log import log as logging
from six import with_metaclass

from coriolis import constants
from coriolis import exception
from coriolis import utils

LOG = logging.getLogger(__name__)

# Required OS release fields to be returned as declared in the
# 'schemas.CORIOLIS_DETECTED_OS_MORPHING_INFO_SCHEMA' schema:
REQUIRED_DETECTED_OS_FIELDS = [
Expand Down Expand Up @@ -98,3 +102,36 @@ def _exec_cmd_chroot(self, cmd, timeout=None):
except exception.MinionMachineCommandTimeout as ex:
raise exception.OSMorphingSSHOperationTimeout(
cmd=cmd, timeout=timeout) from ex


class LinuxOSDetectUsingOSRelease(BaseLinuxOSDetectTools):
"""OS detection based on the standard /etc/os-release file."""

def detect_os(self):
"""Detect a Linux distro from /etc/os-release."""
os_release = self._get_os_release()
if not os_release:
LOG.warning(
"Could not detect OS from /etc/os-release: os_release dict "
"was not provided")
return {}

distribution_name = os_release.get("NAME")
if not distribution_name:
LOG.warning(
"Could not detect OS from /etc/os-release: NAME is missing")
return {}

version = os_release.get("VERSION_ID")
if not version:
LOG.warning(
"Could not detect OS from /etc/os-release: VERSION_ID is "
"missing")
return {}

return {
"os_type": constants.OS_TYPE_LINUX,
"distribution_name": distribution_name,
"release_version": version,
"friendly_release_name": "%s Version %s" % (
distribution_name, version)}
46 changes: 0 additions & 46 deletions coriolis/osmorphing/osdetect/centos.py

This file was deleted.

13 changes: 2 additions & 11 deletions coriolis/osmorphing/osdetect/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@

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
from coriolis.osmorphing.osdetect import debian
from coriolis.osmorphing.osdetect import openwrt
from coriolis.osmorphing.osdetect import oracle
from coriolis.osmorphing.osdetect import redhat
from coriolis.osmorphing.osdetect import rocky
from coriolis.osmorphing.osdetect import suse
from coriolis.osmorphing.osdetect import ubuntu
from coriolis.osmorphing.osdetect import windows
Expand All @@ -22,16 +17,12 @@


LINUX_OS_DETECTION_TOOLS = [
amazon.AmazonLinuxOSDetectTools,
centos.CentOSOSDetectTools,
coreos.CoreOSOSDetectTools,
debian.DebianOSDetectTools,
openwrt.OpenWRTOSDetectTools,
oracle.OracleOSDetectTools,
redhat.RedHatOSDetectTools,
rocky.RockyLinuxOSDetectTools,
suse.SUSEOSDetectTools,
ubuntu.UbuntuOSDetectTools
ubuntu.UbuntuOSDetectTools,
base.LinuxOSDetectUsingOSRelease,
]

WINDOWS_OS_DETECTION_TOOLS = [windows.WindowsOSDetectTools]
Expand Down
32 changes: 0 additions & 32 deletions coriolis/osmorphing/osdetect/oracle.py

This file was deleted.

40 changes: 0 additions & 40 deletions coriolis/osmorphing/osdetect/redhat.py

This file was deleted.

40 changes: 0 additions & 40 deletions coriolis/osmorphing/osdetect/rocky.py

This file was deleted.

8 changes: 3 additions & 5 deletions coriolis/osmorphing/redhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@

from coriolis import exception
from coriolis.osmorphing import base
from coriolis.osmorphing.osdetect import centos as centos_detect
from coriolis.osmorphing.osdetect import redhat as redhat_detect
from coriolis import utils

RED_HAT_DISTRO_IDENTIFIER = redhat_detect.RED_HAT_DISTRO_IDENTIFIER
RED_HAT_DISTRO_IDENTIFIER = "Red Hat Enterprise Linux"

LOG = logging.getLogger(__name__)

# NOTE: some constants duplicated for backwards-compatibility:
RELEASE_RHEL = RED_HAT_DISTRO_IDENTIFIER
RELEASE_CENTOS = centos_detect.CENTOS_DISTRO_IDENTIFIER
RELEASE_CENTOS = "CentOS"
RELEASE_FEDORA = "Fedora"


Expand Down Expand Up @@ -67,7 +65,7 @@ def check_os_supported(cls, detected_os_info):
RED_HAT_DISTRO_IDENTIFIER):
return False
return cls._version_supported_util(
detected_os_info['release_version'], minimum=6)
detected_os_info['release_version'], minimum=7)

def __init__(self, conn, os_root_dir, os_root_dev,
hypervisor, event_manager, detected_os_info,
Expand Down
Loading
Loading