Skip to content

Commit

Permalink
add OpenCloudOS and TencentOS support (#1964)
Browse files Browse the repository at this point in the history
  • Loading branch information
wynnfeng authored Feb 18, 2023
1 parent 9043f82 commit b01b5c2
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions cloudinit/config/cc_ntp.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"miraclelinux",
"openbsd",
"openEuler",
"OpenCloudOS",
"openmandriva",
"opensuse",
"opensuse-microos",
Expand All @@ -48,6 +49,7 @@
"sle_hpc",
"sle-micro",
"sles",
"TencentOS",
"ubuntu",
"virtuozzo",
]
Expand Down
2 changes: 2 additions & 0 deletions cloudinit/config/cc_yum_add_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@
"fedora",
"mariner",
"openEuler",
"OpenCloudOS",
"openmandriva",
"photon",
"rhel",
"rocky",
"TencentOS",
"virtuozzo",
]

Expand Down
9 changes: 9 additions & 0 deletions cloudinit/distros/OpenCloudOS.py
Original file line number Diff line number Diff line change
@@ -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"
9 changes: 9 additions & 0 deletions cloudinit/distros/TencentOS.py
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions cloudinit/distros/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"sles",
],
"openEuler": ["openEuler"],
"OpenCloudOS": ["OpenCloudOS", "TencentOS"],
}

LOG = logging.getLogger(__name__)
Expand Down
2 changes: 2 additions & 0 deletions cloudinit/net/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
"fedora",
"miraclelinux",
"openEuler",
"OpenCloudOS",
"openmandriva",
"rhel",
"rocky",
"suse",
"TencentOS",
"virtuozzo",
]

Expand Down
2 changes: 2 additions & 0 deletions cloudinit/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,11 +639,13 @@ def _get_variant(info):
"mariner",
"miraclelinux",
"openeuler",
"opencloudos",
"openmandriva",
"photon",
"rhel",
"rocky",
"suse",
"tencentos",
"virtuozzo",
):
variant = linux_dist
Expand Down
8 changes: 4 additions & 4 deletions config/cloud.cfg.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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" %}
Expand Down
2 changes: 1 addition & 1 deletion systemd/cloud-init-generator.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions systemd/cloud-init.service.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/unittests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ def test_wb_schema_subcommand_parser(self, capsys):
"**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",
Expand Down
48 changes: 48 additions & 0 deletions tests/unittests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,36 @@
"""
)

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 = (
Expand Down Expand Up @@ -1129,6 +1159,22 @@ def test_get_linux_openeuler(self, m_os_release, m_path_exists):
dist = util.get_linux_distro()
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
Expand Down Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions tools/.github-cla-signers
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ vteratipally
Vultaire
WebSpider
wschoot
wynnfeng
xiachen-rh
xiaoge1001
xnox
Expand Down
2 changes: 2 additions & 0 deletions tools/render-cloudcfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ def main():
"netbsd",
"openbsd",
"openEuler",
"OpenCloudOS",
"openmandriva",
"photon",
"rhel",
"suse",
"rocky",
"TencentOS",
"ubuntu",
"unknown",
"virtuozzo",
Expand Down

0 comments on commit b01b5c2

Please sign in to comment.