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>
---
 .../0001-cloud-init-Update-patch-information.patch | 68 ++++++++++++++++++++++
 cloud-init-20.3/cloudinit/config/cc_ntp.py         |  2 +-
 cloud-init-20.3/cloudinit/config/cc_resolv_conf.py |  2 +-
 cloud-init-20.3/cloudinit/config/cc_rh_subscription.py |  2 +-
 cloud-init-20.3/cloudinit/config/cc_spacewalk.py   |  2 +-
 .../cloudinit/config/cc_yum_add_repo.py            |  2 +-
 cloud-init-20.3/cloudinit/distros/__init__.py      |  2 +-
 cloud-init-20.3/cloudinit/distros/openeuler.py       | 12 ++++
 cloud-init-20.3/cloudinit/util.py                  |  2 +-
 cloud-init-20.3/config/cloud.cfg.tmpl              |  8 +--
 cloud-init-20.3/systemd/cloud-init.service.tmpl    |  2 +-
 cloud-init-20.3/tests/cloud_tests/util.py          |  2 +-
 cloud-init-20.3/tools/render-cloudcfg              |  2 +-
 cloud-init-20.3/systemd/cloud-init-generator.tmpl  |  2 +-
 15 files changed, 96 insertions(+), 16 deletions(-)
 create mode 100644 cloud-init-19.4/cloudinit/distros/openeuler.py

diff --git a/cloudinit/config/cc_ntp.py b/cloudinit/config/cc_ntp.py
index c3aee79..b107359 100644
--- a/cloudinit/config/cc_ntp.py
+++ b/cloudinit/config/cc_ntp.py
@@ -25,7 +25,7 @@ frequency = PER_INSTANCE
 NTP_CONF = '/etc/ntp.conf'
 NR_POOL_SERVERS = 4
 distros = ['almalinux', 'alpine', 'centos', 'cloudlinux', 'debian',
-           'eurolinux', 'fedora', 'openEuler', 'opensuse', 'photon',
+           'eurolinux', 'fedora', 'openeuler', 'opensuse', 'photon',
            'rhel', 'rocky', 'sles', 'ubuntu', 'virtuozzo']
 
 NTP_CLIENT_CONFIG = {
diff --git a/cloudinit/config/cc_resolv_conf.py b/cloudinit/config/cc_resolv_conf.py
index 648935e..8a4efa5 100644
--- a/cloudinit/config/cc_resolv_conf.py
+++ b/cloudinit/config/cc_resolv_conf.py
@@ -55,7 +55,7 @@ LOG = logging.getLogger(__name__)
 
 frequency = PER_INSTANCE
 
-distros = ['alpine', 'fedora', 'opensuse', 'photon', 'rhel', 'sles']
+distros = ['alpine', 'fedora', 'opensuse', 'photon', 'rhel', 'sles', 'openeuler']
 
 RESOLVE_CONFIG_TEMPLATE_MAP = {
     '/etc/resolv.conf': 'resolv.conf',
diff --git a/cloudinit/config/cc_rh_subscription.py b/cloudinit/config/cc_rh_subscription.py
index 693317c..6c1c6b7 100644
--- a/cloudinit/config/cc_rh_subscription.py
+++ b/cloudinit/config/cc_rh_subscription.py
@@ -44,7 +44,7 @@ from cloudinit import util
 
 LOG = logging.getLogger(__name__)
 
-distros = ['fedora', 'rhel']
+distros = ['fedora', 'rhel', 'openeuler']
 
 
 def handle(name, cfg, _cloud, log, _args):
diff --git a/cloudinit/config/cc_spacewalk.py b/cloudinit/config/cc_spacewalk.py
index 9508360..6732979 100644
--- a/cloudinit/config/cc_spacewalk.py
+++ b/cloudinit/config/cc_spacewalk.py
@@ -30,7 +30,7 @@ For more information about spacewalk see: https://fedorahosted.org/spacewalk/
 from cloudinit import subp
 
 
-distros = ['redhat', 'fedora']
+distros = ['redhat', 'fedora', 'openeuler']
 required_packages = ['rhn-setup']
 def_ca_cert_path = "/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT"
 
diff --git a/cloudinit/config/cc_yum_add_repo.py b/cloudinit/config/cc_yum_add_repo.py
index d66d3ae..f4ac969 100644
--- a/cloudinit/config/cc_yum_add_repo.py
+++ b/cloudinit/config/cc_yum_add_repo.py
@@ -38,7 +38,7 @@ from configparser import ConfigParser
 from cloudinit import util
 
 distros = ['almalinux', 'centos', 'cloudlinux', 'eurolinux', 'fedora',
-           'openEuler', '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 cf6aad1..d91aab2 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', 'openEuler', '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 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/cloudinit/util.py b/cloudinit/util.py
index 575a1fe..68c12f9 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -549,7 +549,7 @@ def system_info():
         linux_dist = info['dist'][0].lower()
         if linux_dist in (
                 'almalinux', 'alpine', 'arch', 'centos', 'cloudlinux',
-                'debian', 'eurolinux', 'fedora', 'openEuler', 'photon',
+                'debian', 'eurolinux', 'fedora', 'openeuler', 'photon',
                 'rhel', 'rocky', 'suse', 'virtuozzo'):
             var = linux_dist
         elif linux_dist in ('ubuntu', 'linuxmint', 'mint'):
diff --git a/config/cloud.cfg.tmpl b/config/cloud.cfg.tmpl
index b66bbe6..995ba66 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", "openeuler", "rhel", "rocky", "virtuozzo"] %}
 mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2']
 {% if variant == "amazon" %}
 resize_rootfs: noblock
@@ -110,7 +110,7 @@ cloud_config_modules:
  - locale
 {% endif %}
  - set-passwords
-{% if variant in ["rhel", "fedora", "photon"] %}
+{% if variant in ["rhel", "fedora", "photon", "openeuler"] %}
 {% if variant not in ["photon"] %}
  - spacewalk
 {% endif %}
@@ -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", "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", "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 7d1e725..685c012 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"] %}
+                  "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 de3f3d9..25830e0 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"] %}
+                  "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 1459fd9..b888e87 100644
--- a/tests/unittests/test_cli.py
+++ b/tests/unittests/test_cli.py
@@ -225,7 +225,7 @@ class TestCLI(test_helpers.FilesystemMockingTestCase):
         expected_doc_sections = [
             '**Supported distros:** all',
             ('**Supported distros:** almalinux, alpine, centos, cloudlinux, '
-             'debian, eurolinux, fedora, openEuler, opensuse, photon, rhel, '
+             'debian, eurolinux, fedora, openeuler, opensuse, photon, rhel, '
              'rocky, sles, ubuntu, virtuozzo'),
             '**Config schema**:\n    **resize_rootfs:** (true/false/noblock)',
             '**Examples**::\n\n    runcmd:\n        - [ ls, -l, / ]\n'
diff --git a/tests/unittests/test_render_cloudcfg.py b/tests/unittests/test_render_cloudcfg.py
index 00d50e6..e8680b8 100644
--- a/tests/unittests/test_render_cloudcfg.py
+++ b/tests/unittests/test_render_cloudcfg.py
@@ -10,7 +10,7 @@ from cloudinit import util
 
 # TODO(Look to align with tools.render-cloudcfg or cloudinit.distos.OSFAMILIES)
 DISTRO_VARIANTS = ["amazon", "arch", "centos", "debian", "eurolinux", "fedora",
-                   "freebsd", "netbsd", "openbsd", "photon", "rhel", "suse",
+                   "freebsd", "netbsd", "openbsd", "openeuler", "photon", "rhel", "suse",
                    "ubuntu", "unknown"]
 
 
diff --git a/tools/render-cloudcfg b/tools/render-cloudcfg
index 560f591..7751cb6 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", "netbsd", "openbsd", "openeuler", "photon",
             "rhel", "suse","rocky", "ubuntu", "unknown", "virtuozzo"]
 
 
-- 
1.8.3.1

