cloud-init/bugfix-cloud-init-add-openEuler-os.patch
2019-12-25 15:43:33 +08:00

228 lines
8.8 KiB
Diff

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-17.1/cloudinit/config/cc_ntp.py | 2 +-
cloud-init-17.1/cloudinit/config/cc_resolv_conf.py | 2 +-
.../cloudinit/config/cc_rh_subscription.py | 2 +-
cloud-init-17.1/cloudinit/config/cc_spacewalk.py | 2 +-
.../cloudinit/config/cc_yum_add_repo.py | 2 +-
cloud-init-17.1/cloudinit/distros/__init__.py | 2 +-
cloud-init-17.1/cloudinit/distros/openEuler.py | 12 ++++
cloud-init-17.1/cloudinit/util.py | 2 +-
cloud-init-17.1/config/cloud.cfg.tmpl | 8 +--
cloud-init-17.1/systemd/cloud-init.service.tmpl | 2 +-
cloud-init-17.1/tests/cloud_tests/util.py | 2 +-
.../unittests/test_handler/test_handler_ntp.py | 2 +-
cloud-init-17.1/tools/render-cloudcfg | 2 +-
14 files changed, 95 insertions(+), 15 deletions(-)
create mode 100644 cloud-init-17.1/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 @@ frequency = PER_INSTANCE
NTP_CONF = '/etc/ntp.conf'
TIMESYNCD_CONF = '/etc/systemd/timesyncd.conf.d/cloud-init.conf'
NR_POOL_SERVERS = 4
-distros = ['centos', 'debian', 'fedora', 'opensuse', 'ubuntu']
+distros = ['centos', 'debian', 'fedora', 'opensuse', 'ubuntu', 'openEuler']
# The schema definition for each cloud-config module is a strict contract for
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
@@ -40,7 +40,7 @@ Subscription`` example config.
from cloudinit import util
-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': ['centos', 'fedora', 'rhel'],
+ 'redhat': ['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
@@ -592,7 +592,7 @@ def system_info():
var = 'unknown'
if system == "linux":
linux_dist = info['dist'][0].lower()
- if linux_dist in ('centos', 'fedora', 'debian'):
+ if linux_dist in ('centos', 'fedora', 'debian', '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
@@ -19,7 +19,7 @@ disable_root: false
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_deletekeys: 0
@@ -75,7 +75,7 @@ cloud_config_modules:
- ssh-import-id
- locale
- set-passwords
-{% if variant in ["rhel", "fedora"] %}
+{% if variant in ["rhel", "fedora", "openEuler"] %}
- spacewalk
- yum-add-repo
{% endif %}
@@ -127,7 +127,7 @@ cloud_final_modules:
# (not accessible to handlers/transforms)
system_info:
# This will affect which distro class gets used
-{% if variant in ["centos", "debian", "fedora", "rhel", "suse", "ubuntu", "freebsd"] %}
+{% if variant in ["centos", "debian", "fedora", "rhel", "suse", "ubuntu", "freebsd", "openEuler"] %}
distro: {{ variant }}
{% else %}
# Unknown/fallback distro.
@@ -163,7 +163,7 @@ system_info:
primary: http://ports.ubuntu.com/ubuntu-ports
security: http://ports.ubuntu.com/ubuntu-ports
ssh_svcname: ssh
-{% elif variant in ["centos", "rhel", "fedora", "suse"] %}
+{% elif variant in ["centos", "rhel", "fedora", "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
{% endif %}
{% if variant in ["suse"] %}
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/tests/unittests/test_handler/test_handler_ntp.py b/tests/unittests/test_handler/test_handler_ntp.py
index 3abe578..78548cc 100644
--- a/tests/unittests/test_handler/test_handler_ntp.py
+++ b/tests/unittests/test_handler/test_handler_ntp.py
@@ -258,7 +258,7 @@ class TestNtp(FilesystemMockingTestCase):
}
}
ntp_conf = self.tmp_path('ntp.conf', self.new_root) # Doesn't exist
- for distro in ('debian', 'ubuntu', 'fedora', 'rhel', 'sles'):
+ for distro in ('debian', 'ubuntu', 'fedora', 'rhel', 'sles', 'openEuler'):
mycloud = self._get_cloud(distro)
root_dir = dirname(dirname(os.path.realpath(util.__file__)))
tmpl_file = os.path.join(
diff --git a/tools/render-cloudcfg b/tools/render-cloudcfg
index 91d074b..7a8a2c4 100755
--- a/tools/render-cloudcfg
+++ b/tools/render-cloudcfg
@@ -4,7 +4,7 @@ import argparse
import os
import sys
-VARIANTS = ["bsd", "centos", "fedora", "rhel", "suse", "ubuntu", "unknown"]
+VARIANTS = ["bsd", "centos", "fedora", "rhel", "suse", "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