try to get os info from redhat-release firstly

This commit is contained in:
Lili Deng 2023-02-08 16:56:23 +08:00 коммит произвёл LiliDeng
Родитель eef319fa0f
Коммит 68bc25460b
2 изменённых файлов: 26 добавлений и 18 удалений

Просмотреть файл

@ -1472,22 +1472,29 @@ class Redhat(Fedora):
return 0 == result.exit_code
def _get_information(self) -> OsInformation:
cmd_result = self._node.execute(
cmd="cat /etc/redhat-release", no_error_log=True, expected_exit_code=0
)
full_version = cmd_result.stdout
matches = self.__legacy_redhat_information_pattern.match(full_version)
assert matches, f"cannot match version information from: {full_version}"
assert matches.group("vendor")
information = OsInformation(
version=self._parse_version(matches.group("version")),
vendor=matches.group("vendor"),
release=matches.group("version"),
codename=matches.group("codename"),
full_version=full_version,
)
# remove Linux Server in vendor
information.vendor = get_matched_str(information.vendor, self.__vendor_pattern)
try:
cmd_result = self._node.execute(
cmd="cat /etc/redhat-release", no_error_log=True, expected_exit_code=0
)
full_version = cmd_result.stdout
matches = self.__legacy_redhat_information_pattern.match(full_version)
assert matches, f"cannot match version information from: {full_version}"
assert matches.group("vendor")
information = OsInformation(
version=self._parse_version(matches.group("version")),
vendor=matches.group("vendor"),
release=matches.group("version"),
codename=matches.group("codename"),
full_version=full_version,
)
except Exception:
information = super(Fedora, self)._get_information()
# remove Linux Server in vendor
information.vendor = get_matched_str(
information.vendor, self.__vendor_pattern
)
return information
def _update_packages(self, packages: Optional[List[str]] = None) -> None:

Просмотреть файл

@ -143,6 +143,7 @@ class Pktgen(Tool):
raise UnsupportedKernelException(self.node.os)
# ['4', '18', '0', '305', '40', '1', 'el8_4', 'x86_64']
# ['4', '18', '0', '240', 'el8', 'x86_64']
parts = kernel_information.version_parts[:]
# Full example:
@ -151,8 +152,8 @@ class Pktgen(Tool):
# 4.18.0-240.1.1.el8_3.centos.plus.x86_64.rpm",
rpm_location = (
f"https://koji.mbox.centos.org/pkgs/packages/kernel-plus/4.18.0/"
f"{'.'.join(parts[3:7])}.centos.plus/{parts[7]}/kernel-plus-modules-"
f"internal-4.18.0-{'.'.join(parts[3:7])}.centos.plus.{parts[7]}.rpm"
f"{'.'.join(parts[3:-1])}.centos.plus/{parts[-1]}/kernel-plus-modules-"
f"internal-4.18.0-{'.'.join(parts[3:-1])}.centos.plus.{parts[-1]}.rpm"
)
# Install pkggen from CentOS for redhat, because there is no free
# download for Redhat.