From b1f359ff61cc0ec88f2b8dac76f784de1cac1dc8 Mon Sep 17 00:00:00 2001 From: Fabian Fulga Date: Fri, 26 Jun 2026 15:29:45 +0300 Subject: [PATCH] Add support for detecting rocky and centos 10 --- coriolis/osmorphing/osdetect/centos.py | 2 +- coriolis/osmorphing/osdetect/rocky.py | 2 +- .../tests/osmorphing/osdetect/test_centos.py | 18 +++++++++++++++ .../tests/osmorphing/osdetect/test_rocky.py | 22 +++++++++++++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/coriolis/osmorphing/osdetect/centos.py b/coriolis/osmorphing/osdetect/centos.py index 4b0ae0199..135a15b2f 100644 --- a/coriolis/osmorphing/osdetect/centos.py +++ b/coriolis/osmorphing/osdetect/centos.py @@ -23,7 +23,7 @@ def detect_os(self): release_info = self._read_file( redhat_release_path).decode().splitlines() if release_info: - m = re.match(r"^(.*) release ([0-9](\.[0-9])*)( \(.*\))?.*$", + m = re.match(r"^(.*) release ([0-9]+(\.[0-9]+)*)( \(.*\))?.*$", release_info[0].strip()) if m: distro, version, _, _ = m.groups() diff --git a/coriolis/osmorphing/osdetect/rocky.py b/coriolis/osmorphing/osdetect/rocky.py index 60f10fd9d..b79ea0ef9 100644 --- a/coriolis/osmorphing/osdetect/rocky.py +++ b/coriolis/osmorphing/osdetect/rocky.py @@ -21,7 +21,7 @@ def detect_os(self): release_info = self._read_file( redhat_release_path).decode().splitlines() if release_info: - m = re.match(r"^(.*) release ([0-9](\.[0-9])*)( \(.*\))?.*$", + m = re.match(r"^(.*) release ([0-9]+(\.[0-9]+)*)( \(.*\))?.*$", release_info[0].strip()) if m: distro, version, _, _ = m.groups() diff --git a/coriolis/tests/osmorphing/osdetect/test_centos.py b/coriolis/tests/osmorphing/osdetect/test_centos.py index 8060c1bc3..a77f80b4d 100644 --- a/coriolis/tests/osmorphing/osdetect/test_centos.py +++ b/coriolis/tests/osmorphing/osdetect/test_centos.py @@ -60,6 +60,24 @@ def test_detect_os_centos_stream(self, mock_read_file, mock_test_path): self.assertEqual(result, expected_info) + @mock.patch.object(base.BaseLinuxOSDetectTools, '_test_path') + @mock.patch.object(base.BaseLinuxOSDetectTools, '_read_file') + def test_detect_os_centos_stream_10(self, mock_read_file, mock_test_path): + mock_test_path.return_value = True + mock_read_file.return_value = b"CentOS Stream release 10" + + expected_info = { + "os_type": centos.constants.OS_TYPE_LINUX, + "distribution_name": centos.CENTOS_STREAM_DISTRO_IDENTIFIER, + "release_version": '10', + "friendly_release_name": "%s Version %s" % ( + centos.CENTOS_STREAM_DISTRO_IDENTIFIER, '10') + } + + result = self.centos_os_detect_tools.detect_os() + + self.assertEqual(result, expected_info) + @mock.patch.object(base.BaseLinuxOSDetectTools, '_test_path') @mock.patch.object(base.BaseLinuxOSDetectTools, '_read_file') def test_detect_os_not_centos(self, mock_read_file, mock_test_path): diff --git a/coriolis/tests/osmorphing/osdetect/test_rocky.py b/coriolis/tests/osmorphing/osdetect/test_rocky.py index b5942756b..fbbcc5637 100644 --- a/coriolis/tests/osmorphing/osdetect/test_rocky.py +++ b/coriolis/tests/osmorphing/osdetect/test_rocky.py @@ -34,6 +34,28 @@ def test_detect_os(self, mock_read_file, mock_test_path): self.assertEqual(result, expected_info) + @mock.patch.object(base.BaseLinuxOSDetectTools, '_test_path') + @mock.patch.object(base.BaseLinuxOSDetectTools, '_read_file') + def test_detect_os_rocky_10(self, mock_read_file, mock_test_path): + mock_test_path.return_value = True + mock_read_file.return_value = ( + b"Rocky Linux release 10.1 (Red Quartz)") + + expected_info = { + "os_type": rocky.constants.OS_TYPE_LINUX, + "distribution_name": rocky.ROCKY_LINUX_DISTRO_IDENTIFIER, + "release_version": '10.1', + "friendly_release_name": "Rocky Linux Version 10.1" + } + + rocky_os_detect_tools = rocky.RockyLinuxOSDetectTools( + mock.sentinel.conn, mock.sentinel.os_root_dir, + mock.sentinel.operation_timeout) + + result = rocky_os_detect_tools.detect_os() + + self.assertEqual(result, expected_info) + @mock.patch.object(base.BaseLinuxOSDetectTools, '_test_path') @mock.patch.object(base.BaseLinuxOSDetectTools, '_read_file') def test_detect_os_no_rocky(self, mock_read_file, mock_test_path):