From 098429a75ea00df1d8a5670e45df6babfc37f327 Mon Sep 17 00:00:00 2001
From: chengquan <chengquan3@huawei.com>
Date: Thu, 8 Aug 2019 16:11:58 +0800
Subject: [PATCH] cloud-init: cloud-init add oe os

reason: add oe into distros

Signed-off-by: chengquan <chengquan3@huawei.com>
---
 cloudinit/config/cc_ntp.py             |  2 +-
 cloudinit/config/cc_resolv_conf.py     |  1 +
 cloudinit/config/cc_rh_subscription.py |  2 +-
 cloudinit/config/cc_spacewalk.py       |  2 +-
 cloudinit/config/cc_yum_add_repo.py    |  2 +-
 cloudinit/distros/__init__.py          |  2 +-
 cloudinit/distros/openeuler.py         | 12 ++++++++++++
 config/cloud.cfg.tmpl                  |  8 ++++----
 systemd/cloud-init-generator.tmpl      |  2 +-
 systemd/cloud-init.service.tmpl        |  2 +-
 tests/unittests/test_cli.py            |  2 +-
 tools/render-cloudcfg                  |  2 +-
 12 files changed, 26 insertions(+), 13 deletions(-)
 create mode 100644 cloudinit/distros/openeuler.py

diff --git a/cloudinit/config/cc_ntp.py b/cloudinit/config/cc_ntp.py
index 8d83433..508f1ed 100644
--- a/cloudinit/config/cc_ntp.py
+++ b/cloudinit/config/cc_ntp.py
@@ -35,7 +35,7 @@ distros = [
     "mariner",
     "miraclelinux",
     "openbsd",
-    "openEuler",
+    "openeuler",
     "OpenCloudOS",
     "openmandriva",
     "opensuse",
diff --git a/cloudinit/config/cc_resolv_conf.py b/cloudinit/config/cc_resolv_conf.py
index d8a7bfa..b642640 100644
--- a/cloudinit/config/cc_resolv_conf.py
+++ b/cloudinit/config/cc_resolv_conf.py
@@ -69,6 +69,7 @@ meta: MetaSchema = {
         "sle_hpc",
         "sle-micro",
         "sles",
+        "openeuler",
     ],
     "frequency": PER_INSTANCE,
     "examples": [
diff --git a/cloudinit/config/cc_rh_subscription.py b/cloudinit/config/cc_rh_subscription.py
index 533862a..d92f760 100644
--- a/cloudinit/config/cc_rh_subscription.py
+++ b/cloudinit/config/cc_rh_subscription.py
@@ -32,7 +32,7 @@ meta: MetaSchema = {
     "name": "Red Hat Subscription",
     "title": "Register Red Hat Enterprise Linux based system",
     "description": MODULE_DESCRIPTION,
-    "distros": ["fedora", "rhel"],
+    "distros": ["fedora", "rhel", "openeuler"],
     "frequency": PER_INSTANCE,
     "examples": [
         dedent(
diff --git a/cloudinit/config/cc_spacewalk.py b/cloudinit/config/cc_spacewalk.py
index c8249e6..bd7a972 100644
--- a/cloudinit/config/cc_spacewalk.py
+++ b/cloudinit/config/cc_spacewalk.py
@@ -25,7 +25,7 @@ meta: MetaSchema = {
     "name": "Spacewalk",
     "title": "Install and configure spacewalk",
     "description": MODULE_DESCRIPTION,
-    "distros": ["rhel", "fedora"],
+    "distros": ["rhel", "fedora", "openeuler"],
     "frequency": PER_INSTANCE,
     "examples": [
         dedent(
diff --git a/cloudinit/config/cc_yum_add_repo.py b/cloudinit/config/cc_yum_add_repo.py
index 097493b..e565a1d 100644
--- a/cloudinit/config/cc_yum_add_repo.py
+++ b/cloudinit/config/cc_yum_add_repo.py
@@ -32,7 +32,7 @@ distros = [
     "eurolinux",
     "fedora",
     "mariner",
-    "openEuler",
+    "openeuler",
     "OpenCloudOS",
     "openmandriva",
     "photon",
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index ec14893..59bafe0 100644
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -72,7 +72,7 @@ OSFAMILIES = {
         "sle-micro",
         "sles",
     ],
-    "openEuler": ["openEuler"],
+    "openeuler": ["openeuler"],
     "OpenCloudOS": ["OpenCloudOS", "TencentOS"],
 }
 
diff --git a/cloudinit/distros/openeuler.py b/cloudinit/distros/openeuler.py
new file mode 100644
index 0000000..7505ca4
--- /dev/null
+++ b/cloudinit/distros/openeuler.py
@@ -0,0 +1,12 @@
+# Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved.
+# This file is part of cloud-init. See LICENSE file for license information.
+
+from cloudinit.distros import rhel
+from cloudinit import log as logging
+
+LOG = logging.getLogger(__name__)
+
+class Distro(rhel.Distro):
+    pass
+
+# vi: ts=4 expandtab
diff --git a/config/cloud.cfg.tmpl b/config/cloud.cfg.tmpl
index 4c05f63..e686770 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", "OpenCloudOS", "openmandriva", "photon", "TencentOS"] 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 %}
@@ -135,7 +135,7 @@ cloud_config_modules:
 {% if is_rhel %}
  - rh_subscription
 {% endif %}
-{% if variant in ["fedora", "mariner", "openmandriva", "photon"] or is_rhel %}
+{% if variant in ["fedora", "mariner", "openmandriva", "photon", "openeuler"] or is_rhel %}
 {% if variant not in ["mariner", "photon"] %}
  - spacewalk
 {% endif %}
@@ -199,7 +199,7 @@ 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", "OpenCloudOS",
+                  "gentoo", "netbsd", "mariner", "openbsd", "openeuler", "OpenCloudOS",
                   "openmandriva", "photon", "suse", "TencentOS", "ubuntu"] or is_rhel %}
    distro: {{ variant }}
 {% elif variant in ["dragonfly"] %}
@@ -254,7 +254,7 @@ system_info:
          security: http://ports.ubuntu.com/ubuntu-ports
    ssh_svcname: ssh
 {% elif variant in ["alpine", "amazon", "arch", "fedora",
-                    "gentoo", "openEuler", "OpenCloudOS", "openmandriva", "suse", "TencentOS"] 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 d71e3b8..783ae76 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", "OpenCloudOS", "openmandriva", "rhel", "rocky", "TencentOS", "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 1b1f9a8..c7a7c64 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",
-                  "miraclelinux", "openEuler", "OpenCloudOS", "openmandriva", "rhel", "rocky",
+                  "miraclelinux", "openeuler", "OpenCloudOS", "openmandriva", "rhel", "rocky",
                   "suse", "TencentOS", "virtuozzo"] %}
 
 After=network.service
diff --git a/tests/unittests/test_cli.py b/tests/unittests/test_cli.py
index e3fed41..2f031ee 100644
--- a/tests/unittests/test_cli.py
+++ b/tests/unittests/test_cli.py
@@ -246,7 +246,7 @@ class TestCLI:
                     "**Supported distros:** almalinux, alpine, centos, "
                     "cloudlinux, cos, debian, eurolinux, fedora, freebsd, "
                     "mariner, miraclelinux, "
-                    "openbsd, openEuler, OpenCloudOS, openmandriva, "
+                    "openbsd, openeuler, OpenCloudOS, openmandriva, "
                     "opensuse, opensuse-microos, opensuse-tumbleweed, "
                     "opensuse-leap, photon, rhel, rocky, sle_hpc, "
                     "sle-micro, sles, TencentOS, ubuntu, virtuozzo",
diff --git a/tools/render-cloudcfg b/tools/render-cloudcfg
index 6551875..b21fdee 100755
--- a/tools/render-cloudcfg
+++ b/tools/render-cloudcfg
@@ -25,7 +25,7 @@ def main():
         "miraclelinux",
         "netbsd",
         "openbsd",
-        "openEuler",
+        "openeuler",
         "OpenCloudOS",
         "openmandriva",
         "photon",
-- 
2.27.0

