From 0ed00ad9cdebc2d4dabd8bd6d7c901584963def5 Mon Sep 17 00:00:00 2001 From: Haruki TSURUMOTO Date: Tue, 7 Dec 2021 23:23:45 +0900 Subject: Add miraclelinux support (#1128) --- README.md | 2 +- cloudinit/config/cc_ntp.py | 4 ++-- cloudinit/config/cc_yum_add_repo.py | 2 +- cloudinit/distros/__init__.py | 3 ++- cloudinit/distros/miraclelinux.py | 8 ++++++++ cloudinit/net/sysconfig.py | 3 ++- cloudinit/util.py | 4 ++-- config/cloud.cfg.tmpl | 6 +++--- systemd/cloud-init-generator.tmpl | 2 +- systemd/cloud-init.service.tmpl | 2 +- tests/unittests/test_cli.py | 5 +++-- tests/unittests/test_util.py | 38 +++++++++++++++++++++++++++++++++++++ tools/.github-cla-signers | 1 + tools/read-dependencies | 4 ++++ tools/render-cloudcfg | 2 +- 15 files changed, 70 insertions(+), 16 deletions(-) create mode 100644 cloudinit/distros/miraclelinux.py diff --git a/README.md b/README.md index 27098b11..f2a745f8 100644 --- a/README.md +++ b/README.md @@ -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
ArchLinux
Debian
DragonFlyBSD
Fedora
FreeBSD
Gentoo Linux
NetBSD
OpenBSD
openEuler
RHEL/CentOS/AlmaLinux/Rocky/PhotonOS/Virtuozzo/EuroLinux/CloudLinux
SLES/openSUSE
Ubuntu










| Amazon Web Services
Microsoft Azure
Google Cloud Platform
Oracle Cloud Infrastructure
Softlayer
Rackspace Public Cloud
IBM Cloud
DigitalOcean
Bigstep
Hetzner
Joyent
CloudSigma
Alibaba Cloud
OVH
OpenNebula
Exoscale
Scaleway
CloudStack
AltCloud
SmartOS
HyperOne
Vultr
Rootbox
| Bare metal installs
OpenStack
LXD
KVM
Metal-as-a-Service (MAAS)
VMware















| +| Alpine Linux
ArchLinux
Debian
DragonFlyBSD
Fedora
FreeBSD
Gentoo Linux
NetBSD
OpenBSD
openEuler
RHEL/CentOS/AlmaLinux/Rocky/PhotonOS/Virtuozzo/EuroLinux/CloudLinux/MIRACLE LINUX
SLES/openSUSE
Ubuntu










| Amazon Web Services
Microsoft Azure
Google Cloud Platform
Oracle Cloud Infrastructure
Softlayer
Rackspace Public Cloud
IBM Cloud
DigitalOcean
Bigstep
Hetzner
Joyent
CloudSigma
Alibaba Cloud
OVH
OpenNebula
Exoscale
Scaleway
CloudStack
AltCloud
SmartOS
HyperOne
Vultr
Rootbox
| Bare metal installs
OpenStack
LXD
KVM
Metal-as-a-Service (MAAS)
VMware















| ## To start developing cloud-init diff --git a/cloudinit/config/cc_ntp.py b/cloudinit/config/cc_ntp.py index 9c085a04..c55d5d86 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', 'openEuler', 'opensuse', 'photon', - 'rhel', 'rocky', 'sles', 'ubuntu', 'virtuozzo'] + 'eurolinux', 'fedora', 'miraclelinux', '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 d66d3ae4..046a2852 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:** always **Supported distros:** almalinux, centos, cloudlinux, eurolinux, fedora, - openEuler, photon, rhel, rocky, virtuozzo + miraclelinux, openEuler, photon, rhel, rocky, virtuozzo **Config keys**:: diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index fe44f20e..742804ea 100755 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -50,7 +50,8 @@ OSFAMILIES = { 'freebsd': ['freebsd'], 'gentoo': ['gentoo'], 'redhat': ['almalinux', 'amazon', 'centos', 'cloudlinux', 'eurolinux', - 'fedora', 'openEuler', 'photon', 'rhel', 'rocky', 'virtuozzo'], + 'fedora', 'miraclelinux', 'openEuler', 'photon', 'rhel', + 'rocky', 'virtuozzo'], 'suse': ['opensuse', 'sles'], } diff --git a/cloudinit/distros/miraclelinux.py b/cloudinit/distros/miraclelinux.py new file mode 100644 index 00000000..c7753387 --- /dev/null +++ b/cloudinit/distros/miraclelinux.py @@ -0,0 +1,8 @@ +# 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 ef4543b4..85342219 100644 --- a/cloudinit/net/sysconfig.py +++ b/cloudinit/net/sysconfig.py @@ -19,7 +19,8 @@ from .network_state import ( LOG = logging.getLogger(__name__) KNOWN_DISTROS = ['almalinux', 'centos', 'cloudlinux', 'eurolinux', 'fedora', - 'openEuler', 'rhel', 'rocky', 'suse', 'virtuozzo'] + 'miraclelinux', 'openEuler', 'rhel', 'rocky', 'suse', + 'virtuozzo'] NM_CFG_FILE = "/etc/NetworkManager/NetworkManager.conf" diff --git a/cloudinit/util.py b/cloudinit/util.py index 1b462a38..cad087a1 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -540,8 +540,8 @@ def _get_variant(info): linux_dist = info['dist'][0].lower() if linux_dist in ( 'almalinux', 'alpine', 'arch', 'centos', 'cloudlinux', - 'debian', 'eurolinux', 'fedora', 'openeuler', 'photon', - 'rhel', 'rocky', 'suse', 'virtuozzo'): + 'debian', 'eurolinux', 'fedora', 'miraclelinux', 'openeuler', + 'photon', 'rhel', 'rocky', 'suse', 'virtuozzo'): variant = linux_dist elif linux_dist in ('ubuntu', 'linuxmint', 'mint'): variant = 'ubuntu' diff --git a/config/cloud.cfg.tmpl b/config/cloud.cfg.tmpl index b66bbe60..741b23d5 100644 --- a/config/cloud.cfg.tmpl +++ b/config/cloud.cfg.tmpl @@ -33,7 +33,7 @@ disable_root: true {% endif %} {% if variant in ["almalinux", "alpine", "amazon", "centos", "cloudlinux", "eurolinux", - "fedora", "openEuler", "rhel", "rocky", "virtuozzo"] %} + "fedora", "miraclelinux", "openEuler", "rhel", "rocky", "virtuozzo"] %} mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2'] {% if variant == "amazon" %} resize_rootfs: noblock @@ -176,7 +176,7 @@ cloud_final_modules: system_info: # This will affect which distro class gets used {% if variant in ["almalinux", "alpine", "amazon", "arch", "centos", "cloudlinux", "debian", - "eurolinux", "fedora", "freebsd", "netbsd", "openbsd", "openEuler", + "eurolinux", "fedora", "freebsd", "netbsd", "miraclelinux", "openbsd", "openEuler", "photon", "rhel", "rocky", "suse", "ubuntu", "virtuozzo"] %} distro: {{ variant }} {% elif variant in ["dragonfly"] %} @@ -231,7 +231,7 @@ system_info: security: http://ports.ubuntu.com/ubuntu-ports ssh_svcname: ssh {% elif variant in ["almalinux", "alpine", "amazon", "arch", "centos", "cloudlinux", "eurolinux", - "fedora", "openEuler", "rhel", "rocky", "suse", "virtuozzo"] %} + "fedora", "miraclelinux", "openEuler", "rhel", "rocky", "suse", "virtuozzo"] %} # 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 7d1e7256..74d47428 100644 --- a/systemd/cloud-init-generator.tmpl +++ b/systemd/cloud-init-generator.tmpl @@ -84,7 +84,7 @@ default() { check_for_datasource() { local ds_rc="" {% if variant in ["almalinux", "centos", "cloudlinux", "eurolinux", "fedora", - "openEuler", "rhel", "rocky", "virtuozzo"] %} + "miraclelinux", "openEuler", "rhel", "rocky", "virtuozzo"] %} local dsidentify="/usr/libexec/cloud-init/ds-identify" {% else %} local dsidentify="/usr/lib/cloud-init/ds-identify" diff --git a/systemd/cloud-init.service.tmpl b/systemd/cloud-init.service.tmpl index de3f3d91..e71e5679 100644 --- a/systemd/cloud-init.service.tmpl +++ b/systemd/cloud-init.service.tmpl @@ -13,7 +13,7 @@ After=systemd-networkd-wait-online.service After=networking.service {% endif %} {% if variant in ["almalinux", "centos", "cloudlinux", "eurolinux", "fedora", - "openEuler", "rhel", "rocky", "virtuozzo"] %} + "miraclelinux", "openEuler", "rhel", "rocky", "virtuozzo"] %} After=network.service After=NetworkManager.service {% endif %} diff --git a/tests/unittests/test_cli.py b/tests/unittests/test_cli.py index d0162673..e30e89a7 100644 --- a/tests/unittests/test_cli.py +++ b/tests/unittests/test_cli.py @@ -236,8 +236,9 @@ class TestCLI(test_helpers.FilesystemMockingTestCase): "**Supported distros:** all", ( "**Supported distros:** almalinux, alpine, centos, " - "cloudlinux, debian, eurolinux, fedora, openEuler, " - "opensuse, photon, rhel, rocky, sles, ubuntu, virtuozzo" + "cloudlinux, debian, eurolinux, fedora, miraclelinux, " + "openEuler, opensuse, photon, rhel, rocky, sles, ubuntu, " + "virtuozzo" ), "**Config schema**:\n **resize_rootfs:** " "(true/false/noblock)", diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py index 1290cbc6..3b76ead8 100644 --- a/tests/unittests/test_util.py +++ b/tests/unittests/test_util.py @@ -185,6 +185,25 @@ OS_RELEASE_EUROLINUX_8 = dedent( """ ) +OS_RELEASE_MIRACLELINUX_8 = dedent( + """\ + NAME="MIRACLE LINUX" + VERSION="8.4 (Peony)" + ID="miraclelinux" + ID_LIKE="rhel fedora" + PLATFORM_ID="platform:el8" + VERSION_ID="8" + PRETTY_NAME="MIRACLE LINUX 8.4 (Peony)" + ANSI_COLOR="0;31" + CPE_NAME="cpe:/o:cybertrust_japan:miracle_linux:8" + HOME_URL="https://www.cybertrust.co.jp/miracle-linux/" + DOCUMENTATION_URL="https://www.miraclelinux.com/support/miraclelinux8" + BUG_REPORT_URL="https://bugzilla.asianux.com/" + MIRACLELINUX_SUPPORT_PRODUCT="MIRACLE LINUX" + MIRACLELINUX_SUPPORT_PRODUCT_VERSION="8" +""" +) + OS_RELEASE_ROCKY_8 = dedent( """\ NAME="Rocky Linux" @@ -255,6 +274,7 @@ REDHAT_RELEASE_REDHAT_7 = "Red Hat Enterprise Linux Server release 7.5 (Maipo)" REDHAT_RELEASE_ALMALINUX_8 = "AlmaLinux release 8.3 (Purple Manul)" REDHAT_RELEASE_EUROLINUX_7 = "EuroLinux release 7.9 (Minsk)" REDHAT_RELEASE_EUROLINUX_8 = "EuroLinux release 8.4 (Vaduz)" +REDHAT_RELEASE_MIRACLELINUX_8 = "MIRACLE LINUX release 8.4 (Peony)" REDHAT_RELEASE_ROCKY_8 = "Rocky Linux release 8.3 (Green Obsidian)" REDHAT_RELEASE_VIRTUOZZO_8 = "Virtuozzo Linux release 8" REDHAT_RELEASE_CLOUDLINUX_8 = "CloudLinux release 8.4 (Valery Rozhdestvensky)" @@ -754,6 +774,24 @@ class TestGetLinuxDistro(CiTestCase): dist = util.get_linux_distro() self.assertEqual(('eurolinux', '8.4', 'Vaduz'), dist) + @mock.patch('cloudinit.util.load_file') + def test_get_linux_miraclelinux8_rhrelease(self, m_os_release, + m_path_exists): + """Verify miraclelinux 8 read from redhat-release.""" + m_os_release.return_value = REDHAT_RELEASE_MIRACLELINUX_8 + m_path_exists.side_effect = TestGetLinuxDistro.redhat_release_exists + dist = util.get_linux_distro() + self.assertEqual(('miracle', '8.4', 'Peony'), dist) + + @mock.patch('cloudinit.util.load_file') + def test_get_linux_miraclelinux8_osrelease(self, m_os_release, + m_path_exists): + """Verify miraclelinux 8 read from os-release.""" + m_os_release.return_value = OS_RELEASE_MIRACLELINUX_8 + m_path_exists.side_effect = TestGetLinuxDistro.os_release_exists + dist = util.get_linux_distro() + self.assertEqual(('miraclelinux', '8', 'Peony'), dist) + @mock.patch('cloudinit.util.load_file') def test_get_linux_rocky8_rhrelease(self, m_os_release, m_path_exists): """Verify rocky linux 8 read from redhat-release.""" diff --git a/tools/.github-cla-signers b/tools/.github-cla-signers index 492ed15e..a2da8a62 100644 --- a/tools/.github-cla-signers +++ b/tools/.github-cla-signers @@ -73,6 +73,7 @@ timothegenzmer tnt-dev tomponline tsanghan +tSU-RooT vteratipally Vultaire WebSpider diff --git a/tools/read-dependencies b/tools/read-dependencies index 810154e4..efa5879c 100755 --- a/tools/read-dependencies +++ b/tools/read-dependencies @@ -24,6 +24,7 @@ DEFAULT_REQUIREMENTS = 'requirements.txt' DISTRO_PKG_TYPE_MAP = { 'centos': 'redhat', 'eurolinux': 'redhat', + 'miraclelinux': 'redhat', 'rocky': 'redhat', 'redhat': 'redhat', 'debian': 'debian', @@ -70,12 +71,14 @@ DRY_DISTRO_INSTALL_PKG_CMD = { 'rocky': ['yum', 'install', '--assumeyes'], 'centos': ['yum', 'install', '--assumeyes'], 'eurolinux': ['yum', 'install', '--assumeyes'], + 'miraclelinux': ['yum', 'install', '--assumeyes'], 'redhat': ['yum', 'install', '--assumeyes'], } DISTRO_INSTALL_PKG_CMD = { 'rocky': MAYBE_RELIABLE_YUM_INSTALL, 'eurolinux': MAYBE_RELIABLE_YUM_INSTALL, + 'miraclelinux': MAYBE_RELIABLE_YUM_INSTALL, 'centos': MAYBE_RELIABLE_YUM_INSTALL, 'redhat': MAYBE_RELIABLE_YUM_INSTALL, 'debian': ['apt', 'install', '-y'], @@ -89,6 +92,7 @@ DISTRO_INSTALL_PKG_CMD = { CI_SYSTEM_BASE_PKGS = { 'common': ['make', 'sudo', 'tar'], 'eurolinux': ['python3-tox'], + 'miraclelinux': ['python3-tox'], 'redhat': ['python3-tox'], 'centos': ['python3-tox'], 'ubuntu': ['devscripts', 'python3-dev', 'libssl-dev', 'tox', 'sbuild'], diff --git a/tools/render-cloudcfg b/tools/render-cloudcfg index 186d61b7..6642bd58 100755 --- a/tools/render-cloudcfg +++ b/tools/render-cloudcfg @@ -5,7 +5,7 @@ import os import sys VARIANTS = ["almalinux", "alpine", "amazon", "arch", "centos", "cloudlinux", "debian", - "eurolinux", "fedora", "freebsd", "netbsd", "openbsd", "openEuler", "photon", + "eurolinux", "fedora", "freebsd", "miraclelinux", "netbsd", "openbsd", "openEuler", "photon", "rhel", "suse","rocky", "ubuntu", "unknown", "virtuozzo"] -- cgit v1.2.3