From 85326dc722f5ecef33af5064838ad58264427c93 Mon Sep 17 00:00:00 2001 From: Calvin Mwadime Makokha Date: Wed, 8 Nov 2023 15:30:53 +0200 Subject: [PATCH] Update supported Ubuntu versions --- azurelinuxagent/common/osutil/factory.py | 11 +++++------ azurelinuxagent/common/osutil/ubuntu.py | 2 +- tests/common/osutil/test_factory.py | 7 +++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/azurelinuxagent/common/osutil/factory.py b/azurelinuxagent/common/osutil/factory.py index 83123e3f5..c130ebc2a 100644 --- a/azurelinuxagent/common/osutil/factory.py +++ b/azurelinuxagent/common/osutil/factory.py @@ -66,15 +66,14 @@ def _get_osutil(distro_name, distro_code_name, distro_version, distro_full_name) return ClearLinuxUtil() if distro_name == "ubuntu": - if Version(distro_version) in [Version("12.04"), Version("12.10")]: + ubuntu_version = Version(distro_version) + if ubuntu_version in [Version("12.04"), Version("12.10")]: return Ubuntu12OSUtil() - if Version(distro_version) in [Version("14.04"), Version("14.10")]: + if ubuntu_version in [Version("14.04"), Version("14.10")]: return Ubuntu14OSUtil() - if Version(distro_version) in [Version('16.04'), Version('16.10'), Version('17.04')]: + if ubuntu_version in [Version('16.04'), Version('16.10'), Version('17.04')]: return Ubuntu16OSUtil() - if Version(distro_version) in [Version('18.04'), Version('18.10'), - Version('19.04'), Version('19.10'), - Version('20.04')]: + if ubuntu_version >= Version('18.04') and ubuntu_version <= Version('24.04'): return Ubuntu18OSUtil() if distro_full_name == "Snappy Ubuntu Core": return UbuntuSnappyOSUtil() diff --git a/azurelinuxagent/common/osutil/ubuntu.py b/azurelinuxagent/common/osutil/ubuntu.py index 5a21511c9..2b82d8ca3 100644 --- a/azurelinuxagent/common/osutil/ubuntu.py +++ b/azurelinuxagent/common/osutil/ubuntu.py @@ -88,7 +88,7 @@ def unregister_agent_service(self): class Ubuntu18OSUtil(Ubuntu16OSUtil): """ - Ubuntu 18.04, 18.10, 19.04, 19.10, 20.04 + Ubuntu >=18.04 and <=24.04 """ def __init__(self): super(Ubuntu18OSUtil, self).__init__() diff --git a/tests/common/osutil/test_factory.py b/tests/common/osutil/test_factory.py index fbe5e24d3..46bf6a875 100644 --- a/tests/common/osutil/test_factory.py +++ b/tests/common/osutil/test_factory.py @@ -98,6 +98,13 @@ def test_get_osutil_it_should_return_ubuntu(self): self.assertTrue(isinstance(ret, Ubuntu18OSUtil)) self.assertEqual(ret.get_service_name(), "walinuxagent") + ret = _get_osutil(distro_name="ubuntu", + distro_code_name="focal", + distro_version="24.04", + distro_full_name="") + self.assertTrue(isinstance(ret, Ubuntu18OSUtil)) + self.assertEqual(ret.get_service_name(), "walinuxagent") + ret = _get_osutil(distro_name="ubuntu", distro_code_name="", distro_version="10.04",