diff options
author | zhuzaifangxuele <52022596+zhuzaifangxuele@users.noreply.github.com> | 2021-09-14 02:21:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-13 13:21:28 -0500 |
commit | f4c47e3e25d1fb79e2673e37f8fc67750d025be2 (patch) | |
tree | d3fd670589ff11d203afd2973f926cc0bff44120 /cloudinit | |
parent | 2ce857248162957a785af61c135ca8433fdbbcde (diff) | |
download | vyos-cloud-init-f4c47e3e25d1fb79e2673e37f8fc67750d025be2.tar.gz vyos-cloud-init-f4c47e3e25d1fb79e2673e37f8fc67750d025be2.zip |
Support openEuler OS (#1012)
openEuler Homepage: https://www.openeuler.org/en/
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/config/cc_ntp.py | 4 | ||||
-rw-r--r-- | cloudinit/config/cc_yum_add_repo.py | 4 | ||||
-rwxr-xr-x | cloudinit/distros/__init__.py | 2 | ||||
-rw-r--r-- | cloudinit/distros/openEuler.py | 9 | ||||
-rw-r--r-- | cloudinit/net/sysconfig.py | 2 | ||||
-rw-r--r-- | cloudinit/tests/test_util.py | 17 | ||||
-rw-r--r-- | cloudinit/util.py | 4 |
7 files changed, 34 insertions, 8 deletions
diff --git a/cloudinit/config/cc_ntp.py b/cloudinit/config/cc_ntp.py index e2231cbb..f4468c9d 100644 --- a/cloudinit/config/cc_ntp.py +++ b/cloudinit/config/cc_ntp.py @@ -25,8 +25,8 @@ frequency = PER_INSTANCE NTP_CONF = '/etc/ntp.conf' NR_POOL_SERVERS = 4 distros = ['almalinux', 'alpine', 'centos', 'cloudlinux', 'debian', - 'eurolinux', 'fedora', 'opensuse', 'photon', 'rhel', 'rocky', - 'sles', 'ubuntu', 'virtuozzo'] + 'eurolinux', 'fedora', 'openEuler', 'opensuse', 'photon', + 'rhel', 'rocky', 'sles', 'ubuntu', 'virtuozzo'] NTP_CLIENT_CONFIG = { 'chrony': { diff --git a/cloudinit/config/cc_yum_add_repo.py b/cloudinit/config/cc_yum_add_repo.py index 899cb082..bcca86cb 100644 --- a/cloudinit/config/cc_yum_add_repo.py +++ b/cloudinit/config/cc_yum_add_repo.py @@ -19,7 +19,7 @@ entry, the config entry will be skipped. **Module frequency:** per always **Supported distros:** almalinux, centos, cloudlinux, eurolinux, fedora, - photon, rhel, rocky, virtuozzo + openEuler, photon, rhel, rocky, virtuozzo **Config keys**:: @@ -38,7 +38,7 @@ from configparser import ConfigParser from cloudinit import util distros = ['almalinux', 'centos', 'cloudlinux', 'eurolinux', 'fedora', - 'photon', 'rhel', 'rocky', 'virtuozzo'] + 'openEuler', 'photon', 'rhel', 'rocky', 'virtuozzo'] def _canonicalize_id(repo_id): diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index a0526948..63e78591 100755 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -50,7 +50,7 @@ OSFAMILIES = { 'freebsd': ['freebsd'], 'gentoo': ['gentoo'], 'redhat': ['almalinux', 'amazon', 'centos', 'cloudlinux', 'eurolinux', - 'fedora', 'photon', 'rhel', 'rocky', 'virtuozzo'], + 'fedora', 'openEuler', 'photon', 'rhel', 'rocky', 'virtuozzo'], 'suse': ['opensuse', 'sles'], } diff --git a/cloudinit/distros/openEuler.py b/cloudinit/distros/openEuler.py new file mode 100644 index 00000000..edb3165d --- /dev/null +++ b/cloudinit/distros/openEuler.py @@ -0,0 +1,9 @@ +# This file is part of cloud-init. See LICENSE file for license information. + +from cloudinit.distros import rhel + + +class Distro(rhel.Distro): + pass + +# vi: ts=4 expandtab diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py index 7b8e4da7..ef4543b4 100644 --- a/cloudinit/net/sysconfig.py +++ b/cloudinit/net/sysconfig.py @@ -19,7 +19,7 @@ from .network_state import ( LOG = logging.getLogger(__name__) KNOWN_DISTROS = ['almalinux', 'centos', 'cloudlinux', 'eurolinux', 'fedora', - 'rhel', 'rocky', 'suse', 'virtuozzo'] + 'openEuler', 'rhel', 'rocky', 'suse', 'virtuozzo'] NM_CFG_FILE = "/etc/NetworkManager/NetworkManager.conf" diff --git a/cloudinit/tests/test_util.py b/cloudinit/tests/test_util.py index f11cfb27..977ad8e0 100644 --- a/cloudinit/tests/test_util.py +++ b/cloudinit/tests/test_util.py @@ -200,6 +200,15 @@ OS_RELEASE_CLOUDLINUX_8 = dedent("""\ BUG_REPORT_URL="https://www.cloudlinux.com/support" """) +OS_RELEASE_OPENEULER_20 = dedent("""\ + NAME="openEuler" + VERSION="20.03 (LTS-SP2)" + ID="openEuler" + VERSION_ID="20.03" + PRETTY_NAME="openEuler 20.03 (LTS-SP2)" + ANSI_COLOR="0;31" +""") + REDHAT_RELEASE_CENTOS_6 = "CentOS release 6.10 (Final)" REDHAT_RELEASE_CENTOS_7 = "CentOS Linux release 7.5.1804 (Core)" REDHAT_RELEASE_REDHAT_6 = ( @@ -719,6 +728,14 @@ class TestGetLinuxDistro(CiTestCase): self.assertEqual(('debian', '9', 'stretch'), dist) @mock.patch('cloudinit.util.load_file') + def test_get_linux_openeuler(self, m_os_release, m_path_exists): + """Verify get the correct name and release name on Openeuler.""" + m_os_release.return_value = OS_RELEASE_OPENEULER_20 + m_path_exists.side_effect = TestGetLinuxDistro.os_release_exists + dist = util.get_linux_distro() + self.assertEqual(('openEuler', '20.03', 'LTS-SP2'), dist) + + @mock.patch('cloudinit.util.load_file') def test_get_linux_opensuse(self, m_os_release, m_path_exists): """Verify we get the correct name and machine arch on openSUSE prior to openSUSE Leap 15. diff --git a/cloudinit/util.py b/cloudinit/util.py index 894245bf..9662b30b 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -549,8 +549,8 @@ def system_info(): linux_dist = info['dist'][0].lower() if linux_dist in ( 'almalinux', 'alpine', 'arch', 'centos', 'cloudlinux', - 'debian', 'eurolinux', 'fedora', 'photon', 'rhel', 'rocky', - 'suse', 'virtuozzo'): + 'debian', 'eurolinux', 'fedora', 'openEuler', 'photon', + 'rhel', 'rocky', 'suse', 'virtuozzo'): var = linux_dist elif linux_dist in ('ubuntu', 'linuxmint', 'mint'): var = 'ubuntu' |