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 openEuler os

reason: add openEuler into distros

Signed-off-by: chengquan <chengquan3@huawei.com>
---
 .../0001-cloud-init-Update-patch-information.patch | 68 ++++++++++++++++++++++
 cloud-init-19.4/cloudinit/config/cc_ntp.py         |  2 +-
 cloud-init-19.4/cloudinit/config/cc_resolv_conf.py |  2 +-
 cloud-init-19.4/cloudinit/config/cc_rh_subscription.py |  2 +-
 cloud-init-19.4/cloudinit/config/cc_spacewalk.py   |  2 +-
 .../cloudinit/config/cc_yum_add_repo.py            |  2 +-
 cloud-init-19.4/cloudinit/distros/__init__.py      |  2 +-
 cloud-init-19.4/cloudinit/distros/openEuler.py       | 12 ++++
 cloud-init-19.4/cloudinit/util.py                  |  2 +-
 cloud-init-19.4/config/cloud.cfg.tmpl              |  8 +--
 cloud-init-19.4/systemd/cloud-init.service.tmpl    |  2 +-
 cloud-init-19.4/tests/cloud_tests/util.py          |  2 +-
 cloud-init-19.4/tools/render-cloudcfg              |  2 +-
 14 files changed, 95 insertions(+), 15 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 d43d060..4f14c10 100644
--- a/cloudinit/config/cc_ntp.py
+++ b/cloudinit/config/cc_ntp.py
@@ -23,7 +23,7 @@ LOG = logging.getLogger(_name_)
 frequency = PER_INSTANCE
 NTP_CONF = '/etc/ntp.conf'
 NR_POOL_SERVERS = 4
-distros = ['centos', 'debian', 'fedora', 'opensuse', 'rhel', 'sles', 'ubuntu']
+distros = ['centos', 'debian', 'fedora', 'opensuse', 'rhel', 'sles', 'ubuntu', 'openEuler']

 NTP_CLIENT_CONFIG = {
     'chrony': {
diff --git a/cloudinit/config/cc_resolv_conf.py b/cloudinit/config/cc_resolv_conf.py
index 9812562..973fe2e 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 = ['fedora', 'opensuse', 'rhel', 'sles']
+distros = ['fedora', 'opensuse', 'rhel', 'sles', 'openEuler']


 def generate_resolv_conf(template_fn, params, target_fname="/etc/resolv.conf"):
diff --git a/cloudinit/config/cc_rh_subscription.py b/cloudinit/config/cc_rh_subscription.py
index 7f36cf8..23f3a5a 100644
--- a/cloudinit/config/cc_rh_subscription.py
+++ b/cloudinit/config/cc_rh_subscription.py
@@ -43,7 +43,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 1020e94..63e9d3b 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 util


-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 6a42f49..9b2d1bd 100644
--- a/cloudinit/config/cc_yum_add_repo.py
+++ b/cloudinit/config/cc_yum_add_repo.py
@@ -40,7 +40,7 @@ import six

 from cloudinit import util

-distros = ['fedora', 'rhel']
+distros = ['fedora', 'rhel', 'openEuler']


 def _canonicalize_id(repo_id):
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index d5becd1..f6eb899 100755
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -36,7 +36,7 @@ ALL_DISTROS = 'all'

 OSFAMILIES = {
     'debian': ['debian', 'ubuntu'],
-    'redhat': ['amazon', 'centos', 'fedora', 'rhel'],
+    'redhat': ['amazon', 'centos', 'fedora', 'rhel', 'openEuler'],
     'gentoo': ['gentoo'],
     'freebsd': ['freebsd'],
     'suse': ['opensuse', 'sles'],
diff --git a/cloudinit/util.py b/cloudinit/util.py
index e1290aa..d85daf0 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -593,7 +593,7 @@ def system_info():
     if system == "linux":
         linux_dist = info['dist'][0].lower()
         if linux_dist in (
-                'arch', 'centos', 'debian', 'fedora', 'rhel', 'suse'):
+                'arch', 'centos', 'debian', 'fedora', 'rhel', 'suse', 'openEuler'):
             var = linux_dist
         elif linux_dist in ('ubuntu', 'linuxmint', 'mint'):
             var = 'ubuntu'
diff --git a/config/cloud.cfg.tmpl b/config/cloud.cfg.tmpl
index 50e3bd8..e3816f2 100644
--- a/config/cloud.cfg.tmpl
+++ b/config/cloud.cfg.tmpl
@@ -21,7 +21,7 @@
 disable_root: true
 {% endif %}

-{% if variant in ["centos", "fedora", "rhel"] %}
+{% if variant in ["centos", "fedora", "rhel", "openEuler"] %}
 mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2']
 resize_rootfs_tmp: /dev
 ssh_pwauth:   0
@@ -76,7 +76,7 @@
  - ssh-import-id
  - locale
  - set-passwords
-{% if variant in ["rhel", "fedora"] %}
+{% if variant in ["rhel", "fedora", "openEuler"] %}
  - spacewalk
  - yum-add-repo
 {% endif %}
@@ -137,7 +137,7 @@
 # (not accessible to handlers/transforms)
 system_info:
    # This will affect which distro class gets used
-{% if variant in ["arch", "centos", "debian", "fedora", "freebsd", "rhel", "suse", "ubuntu"] %}
+{% if variant in ["arch", "centos", "debian", "fedora", "freebsd", "rhel", "suse", "ubuntu", "openEuler"] %}
    distro: {{ variant }}
 {% else %}
    # Unknown/fallback distro.
@@ -185,7 +185,7 @@
          primary: http://ports.ubuntu.com/ubuntu-ports
          security: http://ports.ubuntu.com/ubuntu-ports
    ssh_svcname: ssh
-{% elif variant in ["arch", "centos", "fedora", "rhel", "suse"] %}
+{% elif variant in ["arch", "centos", "fedora", "rhel", "suse", "openEuler"] %}
    # Default user name + that default users groups (if added/used)
    default_user:
      name: {{ variant }}
diff --git a/systemd/cloud-init.service.tmpl b/systemd/cloud-init.service.tmpl
index b92e8ab..f59d4fd 100644
--- a/systemd/cloud-init.service.tmpl
+++ b/systemd/cloud-init.service.tmpl
@@ -10,7 +10,7 @@ After=systemd-networkd-wait-online.service
 {% if variant in ["ubuntu", "unknown", "debian"] %}
 After=networking.service
 {% endif %}
-{% if variant in ["centos", "fedora", "redhat"] %}
+{% if variant in ["centos", "fedora", "redhat", "openEuler"] %}
 After=network.service
 After=NetworkManager.service
 {% endif %}
diff --git a/tests/cloud_tests/util.py b/tests/cloud_tests/util.py
index 4357fbb..7d3034d 100644
--- a/tests/cloud_tests/util.py
+++ b/tests/cloud_tests/util.py
@@ -18,7 +18,7 @@ from tests.cloud_tests import LOG

 OS_FAMILY_MAPPING = {
     'debian': ['debian', 'ubuntu'],
-    'redhat': ['centos', 'rhel', 'fedora'],
+    'redhat': ['centos', 'rhel', 'fedora', 'openEuler'],
     'gentoo': ['gentoo'],
     'freebsd': ['freebsd'],
     'suse': ['sles'],
diff --git a/tools/render-cloudcfg b/tools/render-cloudcfg
index 91d074b..7a8a2c4 100755
--- a/tools/render-cloudcfg
+++ b/tools/render-cloudcfg
@@ -5,7 +5,7 @@ import argparse
 import sys

 VARIANTS = ["arch", "centos", "debian", "fedora", "freebsd", "rhel", "suse",
-            "ubuntu", "unknown"]
+            "ubuntu", "unknown", "openEuler"]

 if "avoid-pep8-E402-import-not-top-of-file":
     _tdir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
diff --git a/cloudinit/distros/openEuler.py b/cloudinit/distros/openEuler.py
new file mode 100644
index 0000000..5ac4700
--- /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
