Fix distro resolution for RedHat

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
This commit is contained in:
Vitaly Kuznetsov 2021-01-26 16:09:39 +01:00
parent bed6404fed
commit d1df06d88f
2 changed files with 71 additions and 2 deletions

View File

@ -0,0 +1,64 @@
From 3420fef144cf9a5be62cfae16f64c298ca397a17 Mon Sep 17 00:00:00 2001
From: Paula Gombar <gombarica@gmail.com>
Date: Wed, 2 Dec 2020 21:36:41 -0800
Subject: [PATCH] Fix distro resolution for RedHat (#2083)
vkuznets: cherry-picking the primary change of the commit (adding 'rhel')
only, pylint changes require additional commits.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
azurelinuxagent/common/osutil/factory.py | 4 +---
tests/common/osutil/test_factory.py | 14 ++++++++++++++
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/azurelinuxagent/common/osutil/factory.py b/azurelinuxagent/common/osutil/factory.py
index 69f8430052d5..caecaa0887e2 100644
--- a/azurelinuxagent/common/osutil/factory.py
+++ b/azurelinuxagent/common/osutil/factory.py
@@ -97,9 +97,7 @@ def _get_osutil(distro_name, distro_code_name, distro_version, distro_full_name)
else:
return DebianOSBaseUtil()
- if distro_name == "redhat" \
- or distro_name == "centos" \
- or distro_name == "oracle":
+ if distro_name in ("redhat", "rhel", "centos", "oracle"):
if Version(distro_version) < Version("7"):
return Redhat6xOSUtil()
else:
diff --git a/tests/common/osutil/test_factory.py b/tests/common/osutil/test_factory.py
index aa7daebcf25f..2ac0849f75c9 100644
--- a/tests/common/osutil/test_factory.py
+++ b/tests/common/osutil/test_factory.py
@@ -188,6 +188,13 @@ class TestOsUtilFactory(AgentTestCase):
self.assertTrue(type(ret) == Redhat6xOSUtil)
self.assertEquals(ret.get_service_name(), "waagent")
+ ret = _get_osutil(distro_name="rhel",
+ distro_code_name="",
+ distro_full_name="",
+ distro_version="6")
+ self.assertTrue(type(ret) == Redhat6xOSUtil)
+ self.assertEquals(ret.get_service_name(), "waagent")
+
ret = _get_osutil(distro_name="centos",
distro_code_name="",
distro_full_name="",
@@ -209,6 +216,13 @@ class TestOsUtilFactory(AgentTestCase):
self.assertTrue(type(ret) == RedhatOSUtil)
self.assertEquals(ret.get_service_name(), "waagent")
+ ret = _get_osutil(distro_name="rhel",
+ distro_code_name="",
+ distro_full_name="",
+ distro_version="7")
+ self.assertTrue(type(ret) == RedhatOSUtil)
+ self.assertEquals(ret.get_service_name(), "waagent")
+
ret = _get_osutil(distro_name="centos",
distro_code_name="",
distro_full_name="",
--
2.29.2

View File

@ -3,7 +3,7 @@
Name: WALinuxAgent Name: WALinuxAgent
Version: 2.2.52 Version: 2.2.52
Release: 3%{?dist} Release: 4%{?dist}
Summary: The Microsoft Azure Linux Agent Summary: The Microsoft Azure Linux Agent
License: ASL 2.0 License: ASL 2.0
@ -15,6 +15,7 @@ Source1: module-setup.sh
Patch0: 0001-update-array.tostring-and-json.loads-without-encodin.patch Patch0: 0001-update-array.tostring-and-json.loads-without-encodin.patch
Patch1: 0002-handle-py3.9-check-in-future.py.patch Patch1: 0002-handle-py3.9-check-in-future.py.patch
Patch2: 0003-fix-pylint.patch Patch2: 0003-fix-pylint.patch
Patch3: 0004-Fix-distro-resolution-for-RedHat-2083.patch
BuildArch: noarch BuildArch: noarch
@ -61,6 +62,7 @@ Udev rules specific to Microsoft Azure Virtual Machines.
%patch0 -p1 %patch0 -p1
%patch1 -p1 %patch1 -p1
%patch2 -p1 %patch2 -p1
%patch3 -p1
%build %build
%py3_build %py3_build
@ -123,10 +125,13 @@ install -m0755 -D -t %{buildroot}%{_prefix}/lib/dracut/modules.d/%{dracut_modnam
%endif %endif
%changelog %changelog
* Tue Jan 26 2021 Vitaly Kuznetsov <vkuznets@redhat.com> - 2.2.52-4
- Fix distro resolution for RedHat
* Mon Jan 25 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.52-3 * Mon Jan 25 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.52-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Fri Jan 15 2021 italy Kuznetsov <vkuznets@redhat.com> - 2.2.52-2 * Fri Jan 15 2021 Vitaly Kuznetsov <vkuznets@redhat.com> - 2.2.52-2
- Add udev rules to initramfs (#1909287) - Add udev rules to initramfs (#1909287)
* Wed Dec 09 2020 Vitaly Kuznetsov <vkuznets@redhat.com> - 2.2.52-1 * Wed Dec 09 2020 Vitaly Kuznetsov <vkuznets@redhat.com> - 2.2.52-1