diff options
author | wynnfeng <120650497+wynnfeng@users.noreply.github.com> | 2023-02-19 01:12:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-18 10:12:38 -0700 |
commit | b01b5c2adc64e64f817253ce014b15ad46a1f94d (patch) | |
tree | 29dcf9bda1158dd4367ea736c6aa5662f4f3c22f | |
parent | 9043f828a50a012ab79275a1d57284e2d69f017a (diff) | |
download | cloud-init-git-b01b5c2adc64e64f817253ce014b15ad46a1f94d.tar.gz |
add OpenCloudOS and TencentOS support (#1964)
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | cloudinit/config/cc_ntp.py | 2 | ||||
-rw-r--r-- | cloudinit/config/cc_yum_add_repo.py | 2 | ||||
-rw-r--r-- | cloudinit/distros/OpenCloudOS.py | 9 | ||||
-rw-r--r-- | cloudinit/distros/TencentOS.py | 9 | ||||
-rw-r--r-- | cloudinit/distros/__init__.py | 1 | ||||
-rw-r--r-- | cloudinit/net/sysconfig.py | 2 | ||||
-rw-r--r-- | cloudinit/util.py | 2 | ||||
-rw-r--r-- | config/cloud.cfg.tmpl | 8 | ||||
-rw-r--r-- | systemd/cloud-init-generator.tmpl | 2 | ||||
-rw-r--r-- | systemd/cloud-init.service.tmpl | 5 | ||||
-rw-r--r-- | tests/unittests/test_cli.py | 4 | ||||
-rw-r--r-- | tests/unittests/test_util.py | 48 | ||||
-rw-r--r-- | tools/.github-cla-signers | 1 | ||||
-rwxr-xr-x | tools/render-cloudcfg | 2 |
15 files changed, 89 insertions, 10 deletions
@@ -39,7 +39,7 @@ get in contact with that distribution and send them our way! | Supported OSes | Supported Public Clouds | Supported Private Clouds | |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| --- | --- | -| Alpine Linux<br />Arch Linux<br />Container-Optimized OS<br />Debian<br />DragonFlyBSD<br />Fedora<br />FreeBSD<br />Gentoo Linux<br />NetBSD<br />OpenBSD<br />openEuler<br />OpenMandriva<br />RHEL/CentOS/AlmaLinux/Rocky/PhotonOS/Virtuozzo/EuroLinux/CloudLinux/MIRACLE LINUX/MarinerOS<br />SLES/openSUSE<br />Ubuntu<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> | Amazon Web Services<br />Microsoft Azure<br />Google Cloud Platform<br />Oracle Cloud Infrastructure<br />Softlayer<br />Rackspace Public Cloud<br />IBM Cloud<br />DigitalOcean<br />Bigstep<br />Hetzner<br />Joyent<br />CloudSigma<br />Alibaba Cloud<br />Huawei Cloud<br />OVH<br />OpenNebula<br />Exoscale<br />Scaleway<br />CloudStack<br />AltCloud<br />SmartOS<br />HyperOne<br />Vultr<br />Rootbox<br /> | Bare metal installs<br />OpenStack<br />LXD<br />KVM<br />Metal-as-a-Service (MAAS)<br />VMware<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />| +| Alpine Linux<br />Arch Linux<br />Container-Optimized OS<br />Debian<br />DragonFlyBSD<br />Fedora<br />FreeBSD<br />Gentoo Linux<br />NetBSD<br />OpenBSD<br />openEuler<br />OpenCloudOS<br />OpenMandriva<br />RHEL/CentOS/AlmaLinux/Rocky/PhotonOS/Virtuozzo/EuroLinux/CloudLinux/MIRACLE LINUX/MarinerOS<br />SLES/openSUSE<br />TencentOS<br />Ubuntu<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> | Amazon Web Services<br />Microsoft Azure<br />Google Cloud Platform<br />Oracle Cloud Infrastructure<br />Softlayer<br />Rackspace Public Cloud<br />IBM Cloud<br />DigitalOcean<br />Bigstep<br />Hetzner<br />Joyent<br />CloudSigma<br />Alibaba Cloud<br />Huawei Cloud<br />OVH<br />OpenNebula<br />Exoscale<br />Scaleway<br />CloudStack<br />AltCloud<br />SmartOS<br />HyperOne<br />Vultr<br />Rootbox<br /> | Bare metal installs<br />OpenStack<br />LXD<br />KVM<br />Metal-as-a-Service (MAAS)<br />VMware<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />| ## To start developing cloud-init diff --git a/cloudinit/config/cc_ntp.py b/cloudinit/config/cc_ntp.py index 93951db4..b5620f37 100644 --- a/cloudinit/config/cc_ntp.py +++ b/cloudinit/config/cc_ntp.py @@ -37,6 +37,7 @@ distros = [ "miraclelinux", "openbsd", "openEuler", + "OpenCloudOS", "openmandriva", "opensuse", "opensuse-microos", @@ -48,6 +49,7 @@ distros = [ "sle_hpc", "sle-micro", "sles", + "TencentOS", "ubuntu", "virtuozzo", ] diff --git a/cloudinit/config/cc_yum_add_repo.py b/cloudinit/config/cc_yum_add_repo.py index cf81b844..3087b22c 100644 --- a/cloudinit/config/cc_yum_add_repo.py +++ b/cloudinit/config/cc_yum_add_repo.py @@ -33,10 +33,12 @@ distros = [ "fedora", "mariner", "openEuler", + "OpenCloudOS", "openmandriva", "photon", "rhel", "rocky", + "TencentOS", "virtuozzo", ] diff --git a/cloudinit/distros/OpenCloudOS.py b/cloudinit/distros/OpenCloudOS.py new file mode 100644 index 00000000..53c7a333 --- /dev/null +++ b/cloudinit/distros/OpenCloudOS.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): + def __init__(self, name, cfg, paths): + super(Distro, self).__init__(name, cfg, paths) + self.osfamily = "OpenCloudOS" diff --git a/cloudinit/distros/TencentOS.py b/cloudinit/distros/TencentOS.py new file mode 100644 index 00000000..53c7a333 --- /dev/null +++ b/cloudinit/distros/TencentOS.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): + def __init__(self, name, cfg, paths): + super(Distro, self).__init__(name, cfg, paths) + self.osfamily = "OpenCloudOS" diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 8f034211..940b689e 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -73,6 +73,7 @@ OSFAMILIES = { "sles", ], "openEuler": ["openEuler"], + "OpenCloudOS": ["OpenCloudOS", "TencentOS"], } LOG = logging.getLogger(__name__) diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py index 453c0522..d4daa78f 100644 --- a/cloudinit/net/sysconfig.py +++ b/cloudinit/net/sysconfig.py @@ -27,10 +27,12 @@ KNOWN_DISTROS = [ "fedora", "miraclelinux", "openEuler", + "OpenCloudOS", "openmandriva", "rhel", "rocky", "suse", + "TencentOS", "virtuozzo", ] diff --git a/cloudinit/util.py b/cloudinit/util.py index af65022f..53a72b13 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -639,11 +639,13 @@ def _get_variant(info): "mariner", "miraclelinux", "openeuler", + "opencloudos", "openmandriva", "photon", "rhel", "rocky", "suse", + "tencentos", "virtuozzo", ): variant = linux_dist diff --git a/config/cloud.cfg.tmpl b/config/cloud.cfg.tmpl index d148dd5d..7238c102 100644 --- a/config/cloud.cfg.tmpl +++ b/config/cloud.cfg.tmpl @@ -35,7 +35,7 @@ disable_root: false disable_root: true {% endif %} -{% if variant in ["alpine", "amazon", "fedora", "openEuler", "openmandriva", "photon"] or is_rhel %} +{% if variant in ["alpine", "amazon", "fedora", "openEuler", "OpenCloudOS", "openmandriva", "photon", "TencentOS"] or is_rhel %} {% if is_rhel %} mount_default_fields: [~, ~, 'auto', 'defaults,nofail,x-systemd.requires=cloud-init.service,_netdev', '0', '2'] {% else %} @@ -200,8 +200,8 @@ cloud_final_modules: system_info: # This will affect which distro class gets used {% if variant in ["alpine", "amazon", "arch", "debian", "fedora", "freebsd", - "gentoo", "netbsd", "mariner", "openbsd", "openEuler", - "openmandriva", "photon", "suse", "ubuntu"] or is_rhel %} + "gentoo", "netbsd", "mariner", "openbsd", "openEuler", "OpenCloudOS", + "openmandriva", "photon", "suse", "TencentOS", "ubuntu"] or is_rhel %} distro: {{ variant }} {% elif variant in ["dragonfly"] %} distro: dragonflybsd @@ -255,7 +255,7 @@ system_info: security: http://ports.ubuntu.com/ubuntu-ports ssh_svcname: ssh {% elif variant in ["alpine", "amazon", "arch", "fedora", - "gentoo", "openEuler", "openmandriva", "suse"] or is_rhel %} + "gentoo", "openEuler", "OpenCloudOS", "openmandriva", "suse", "TencentOS"] or is_rhel %} # Default user name + that default users groups (if added/used) default_user: {% if variant == "amazon" %} diff --git a/systemd/cloud-init-generator.tmpl b/systemd/cloud-init-generator.tmpl index f8121e99..d71e3b89 100644 --- a/systemd/cloud-init-generator.tmpl +++ b/systemd/cloud-init-generator.tmpl @@ -21,7 +21,7 @@ CLOUD_SYSTEM_TARGET="/usr/lib/systemd/system/cloud-init.target" CLOUD_SYSTEM_TARGET="/lib/systemd/system/cloud-init.target" {% endif %} {% if variant in ["almalinux", "centos", "cloudlinux", "eurolinux", "fedora", - "miraclelinux", "openEuler", "openmandriva", "rhel", "rocky", "virtuozzo"] %} + "miraclelinux", "openEuler", "OpenCloudOS", "openmandriva", "rhel", "rocky", "TencentOS", "virtuozzo"] %} dsidentify="/usr/libexec/cloud-init/ds-identify" {% else %} dsidentify="/usr/lib/cloud-init/ds-identify" diff --git a/systemd/cloud-init.service.tmpl b/systemd/cloud-init.service.tmpl index ac589821..1b1f9a86 100644 --- a/systemd/cloud-init.service.tmpl +++ b/systemd/cloud-init.service.tmpl @@ -13,8 +13,9 @@ After=systemd-networkd-wait-online.service After=networking.service {% endif %} {% if variant in ["almalinux", "centos", "cloudlinux", "eurolinux", "fedora", - "miraclelinux", "openEuler", "openmandriva", "rhel", "rocky", - "suse", "virtuozzo"] %} + "miraclelinux", "openEuler", "OpenCloudOS", "openmandriva", "rhel", "rocky", + "suse", "TencentOS", "virtuozzo"] %} + After=network.service After=NetworkManager.service After=NetworkManager-wait-online.service diff --git a/tests/unittests/test_cli.py b/tests/unittests/test_cli.py index 95469ce0..2d57ba04 100644 --- a/tests/unittests/test_cli.py +++ b/tests/unittests/test_cli.py @@ -249,10 +249,10 @@ class TestCLI: "**Supported distros:** almalinux, alpine, centos, " "cloudlinux, cos, debian, eurolinux, fedora, freebsd, " "mariner, miraclelinux, " - "openbsd, openEuler, openmandriva, " + "openbsd, openEuler, OpenCloudOS, openmandriva, " "opensuse, opensuse-microos, opensuse-tumbleweed, " "opensuse-leap, photon, rhel, rocky, sle_hpc, " - "sle-micro, sles, ubuntu, virtuozzo", + "sle-micro, sles, TencentOS, ubuntu, virtuozzo", "**Config schema**:\n **resize_rootfs:** " "(``true``/``false``/``noblock``)", "**Examples**::\n\n runcmd:\n - [ ls, -l, / ]\n", diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py index eed387d5..1be778c6 100644 --- a/tests/unittests/test_util.py +++ b/tests/unittests/test_util.py @@ -269,6 +269,36 @@ OS_RELEASE_OPENEULER_20 = dedent( """ ) +OS_RELEASE_OPENCLOUDOS_8 = dedent( + """\ + NAME="OpenCloudOS" + VERSION="8.6" + ID="OpenCloudOS" + ID_LIKE="rhel fedora" + VERSION_ID="8.6" + PLATFORM_ID="platform:oc8" + PRETTY_NAME="OpenCloudOS 8.6" + ANSI_COLOR="0;31" + CPE_NAME="cpe:/o:opencloudos:opencloudos:8" + HOME_URL="https://www.opencloudos.org/" + BUG_REPORT_URL="https://bugs.opencloudos.tech/" +""" +) + +OS_RELEASE_TENCENTOS_3 = dedent( + """\ + NAME="TencentOS" + VERSION="3.1" + ID="TencentOS" + ID_LIKE="rhel fedora centos" + VERSION_ID="3.1" + PLATFORM_ID="platform:el3" + PRETTY_NAME="TencentOS 3.1" + ANSI_COLOR="0;31" + CPE_NAME="cpe:/o:tencentos:tencentos:3" +""" +) + REDHAT_RELEASE_CENTOS_6 = "CentOS release 6.10 (Final)" REDHAT_RELEASE_CENTOS_7 = "CentOS Linux release 7.5.1804 (Core)" REDHAT_RELEASE_REDHAT_6 = ( @@ -1130,6 +1160,22 @@ class TestGetLinuxDistro(CiTestCase): self.assertEqual(("openEuler", "20.03", "LTS-SP2"), dist) @mock.patch(M_PATH + "load_file") + def test_get_linux_opencloudos(self, m_os_release, m_path_exists): + """Verify get the correct name and release name on OpenCloudOS.""" + m_os_release.return_value = OS_RELEASE_OPENCLOUDOS_8 + m_path_exists.side_effect = TestGetLinuxDistro.os_release_exists + dist = util.get_linux_distro() + self.assertEqual(("OpenCloudOS", "8.6", ""), dist) + + @mock.patch(M_PATH + "load_file") + def test_get_linux_tencentos(self, m_os_release, m_path_exists): + """Verify get the correct name and release name on TencentOS.""" + m_os_release.return_value = OS_RELEASE_TENCENTOS_3 + m_path_exists.side_effect = TestGetLinuxDistro.os_release_exists + dist = util.get_linux_distro() + self.assertEqual(("TencentOS", "3.1", ""), dist) + + @mock.patch(M_PATH + "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. @@ -1245,10 +1291,12 @@ class TestGetVariant: ({"system": "linux", "dist": ("fedora",)}, "fedora"), ({"system": "linux", "dist": ("mariner",)}, "mariner"), ({"system": "linux", "dist": ("openEuler",)}, "openeuler"), + ({"system": "linux", "dist": ("OpenCloudOS",)}, "opencloudos"), ({"system": "linux", "dist": ("photon",)}, "photon"), ({"system": "linux", "dist": ("rhel",)}, "rhel"), ({"system": "linux", "dist": ("rocky",)}, "rocky"), ({"system": "linux", "dist": ("suse",)}, "suse"), + ({"system": "linux", "dist": ("TencentOS",)}, "tencentos"), ({"system": "linux", "dist": ("virtuozzo",)}, "virtuozzo"), ({"system": "linux", "dist": ("ubuntu",)}, "ubuntu"), ({"system": "linux", "dist": ("linuxmint",)}, "ubuntu"), diff --git a/tools/.github-cla-signers b/tools/.github-cla-signers index a0458209..69e199b1 100644 --- a/tools/.github-cla-signers +++ b/tools/.github-cla-signers @@ -135,6 +135,7 @@ vteratipally Vultaire WebSpider wschoot +wynnfeng xiachen-rh xiaoge1001 xnox diff --git a/tools/render-cloudcfg b/tools/render-cloudcfg index c04daead..6551875f 100755 --- a/tools/render-cloudcfg +++ b/tools/render-cloudcfg @@ -26,11 +26,13 @@ def main(): "netbsd", "openbsd", "openEuler", + "OpenCloudOS", "openmandriva", "photon", "rhel", "suse", "rocky", + "TencentOS", "ubuntu", "unknown", "virtuozzo", |