Skip to content

Commit

Permalink
Enable CentOS Stream detection
Browse files Browse the repository at this point in the history
Enables detection and validates `CentOS Stream` for OSMorphing
  • Loading branch information
Dany9966 committed Aug 18, 2023
1 parent 06472f5 commit 8d06b53
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 4 additions & 2 deletions coriolis/osmorphing/centos.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@


CENTOS_DISTRO_IDENTIFIER = centos_detect.CENTOS_DISTRO_IDENTIFIER
CENTOS_STREAM_DISTRO_IDENTIFIER = centos_detect.CENTOS_STREAM_DISTRO_IDENTIFIER


class BaseCentOSMorphingTools(redhat.BaseRedHatMorphingTools):

@classmethod
def check_os_supported(cls, detected_os_info):
if detected_os_info['distribution_name'] != (
CENTOS_DISTRO_IDENTIFIER):
supported_oses = [
CENTOS_STREAM_DISTRO_IDENTIFIER, CENTOS_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)
13 changes: 8 additions & 5 deletions coriolis/osmorphing/osdetect/centos.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import re

from oslo_log import log as logging

from coriolis import constants
from coriolis.osmorphing.osdetect import base


LOG = logging.getLogger(__name__)
CENTOS_DISTRO_IDENTIFIER = "CentOS"
CENTOS_STREAM_DISTRO_IDENTIFIER = "CentOS Stream"


class CentOSOSDetectTools(base.BaseLinuxOSDetectTools):
Expand All @@ -22,19 +22,22 @@ def detect_os(self):
release_info = self._read_file(
redhat_release_path).decode().splitlines()
if release_info:
m = re.match(r"^(.*) release ([0-9].*) \((.*)\).*$",
m = re.match(r"^(.*) release ([0-9](\.[0-9])*)( \(.*\))?.*$",
release_info[0].strip())
if m:
distro, version, _ = m.groups()
distro, version, _, _ = m.groups()
if CENTOS_DISTRO_IDENTIFIER not in distro:
LOG.debug(
"Distro does not appear to be a CentOS: %s", distro)
return {}

distribution_name = CENTOS_DISTRO_IDENTIFIER
if CENTOS_STREAM_DISTRO_IDENTIFIER in distro:
distribution_name = CENTOS_STREAM_DISTRO_IDENTIFIER
info = {
"os_type": constants.OS_TYPE_LINUX,
"distribution_name": CENTOS_DISTRO_IDENTIFIER,
"distribution_name": distribution_name,
"release_version": version,
"friendly_release_name": "%s Version %s" % (
CENTOS_DISTRO_IDENTIFIER, version)}
distribution_name, version)}
return info

0 comments on commit 8d06b53

Please sign in to comment.