!25 openeuler-cloud-init

Merge pull request !25 from chenditang/master
This commit is contained in:
openeuler-ci-bot 2020-06-24 11:23:42 +08:00 committed by Gitee
commit cd156ec0ec
2 changed files with 101 additions and 17 deletions

View File

@ -1,6 +1,6 @@
Name: cloud-init
Version: 17.1
Release: 12
Release: 13
Summary: the defacto multi-distribution package that handles early initialization of a cloud instance.
License: ASL 2.0 or GPLv3
URL: http://launchpad.net/cloud-init
@ -8,22 +8,21 @@ Source0: https://launchpad.net/%{name}/trunk/%{version}/+download/%{name}-%{vers
Source1: cloud-init-tmpfiles.conf
Patch0: cloud-init-17.1-disable-lxd-tests.patch
Patch1: cloud-init-17.1-nm-controlled.patch
Patch2: cloud-init-17.1-no-override-default-network.patch
Patch6000: EC2-Limit-network-config-to-fallback-nic-fix-local-i.patch
Patch6001: ntp-fix-config-module-schema-to-allow-empty-ntp-conf.patch
Patch6002: resizefs-Fix-regression-when-system-booted-with-root.patch
Patch6003: hosts-Fix-openSUSE-and-SLES-setup-for-etc-hosts-and-.patch
Patch6004: EC2-Fix-bug-using-fallback_nic-and-metadata-when-res.patch
Patch6005: Fix-ssh-keys-validation-in-ssh_util.patch
Patch6006: stages-fix-tracebacks-if-a-module-stage-is-undefined.patch
Patch6007: stages-Fix-bug-causing-datasource-to-have-incorrect-.patch
Patch9000: bugfix-cloud-init-add-openEuler-os.patch
Patch9001: bugfix-sort-requirements.patch
Patch9002: add-variable-to-forbid-tmp-dir.patch
Patch0000: cloud-init-17.1-disable-lxd-tests.patch
Patch0001: cloud-init-17.1-nm-controlled.patch
Patch0002: cloud-init-17.1-no-override-default-network.patch
Patch0003: EC2-Limit-network-config-to-fallback-nic-fix-local-i.patch
Patch0004: ntp-fix-config-module-schema-to-allow-empty-ntp-conf.patch
Patch0005: resizefs-Fix-regression-when-system-booted-with-root.patch
Patch0006: hosts-Fix-openSUSE-and-SLES-setup-for-etc-hosts-and-.patch
Patch0007: EC2-Fix-bug-using-fallback_nic-and-metadata-when-res.patch
Patch0008: Fix-ssh-keys-validation-in-ssh_util.patch
Patch0009: stages-fix-tracebacks-if-a-module-stage-is-undefined.patch
Patch0010: stages-Fix-bug-causing-datasource-to-have-incorrect-.patch
Patch0011: bugfix-cloud-init-add-openEuler-os.patch
Patch0012: bugfix-sort-requirements.patch
Patch0013: add-variable-to-forbid-tmp-dir.patch
Patch0014: util-add-get_linux_distro-function-to-replace-platfo.patch
BuildRequires: pkgconfig(systemd) python3-devel python3-setuptools systemd
BuildRequires: iproute python3-configobj python3-httpretty >= 0.8.14-2
@ -128,6 +127,12 @@ fi
%exclude /usr/share/doc/*
%changelog
* Tue Jun 23 2020 chenditang <chenditang1@huawei.com> - 17.1-13
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:add get_linux_distro function to replace platfom.dist
* Sat Mar 14 2020 chengquan <chengquan3@huawei.com> - 17.1-12
- Type:bugfix
- ID:NA

View File

@ -0,0 +1,79 @@
From c4b342ded57aa1ad0ff01b8df8ae6bc900f0c213 Mon Sep 17 00:00:00 2001
From: openEuler BUildteam <buildteam@openeuler.org>
Date: Tue, 23 Jun 2020 16:45:57 +0800
Subject: [PATCH] util: add get_linux_distro function to replace platfom.dist
---
cloudinit/util.py | 39 ++++++++++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
diff --git a/cloudinit/util.py b/cloudinit/util.py
index ac9ae81..ff28b61 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -579,6 +579,39 @@ def get_cfg_option_int(yobj, key, default=0):
return int(get_cfg_option_str(yobj, key, default=default))
+def get_linux_distro():
+ distro_name = ''
+ distro_version = ''
+ if os.path.exists('/etc/os-release'):
+ os_release = load_file('/etc/os-release')
+ for line in os_release.splitlines():
+ if line.strip().startswith('ID='):
+ distro_name = line.split('=')[-1]
+ distro_name = distro_name.replace('"', '')
+ if line.strip().startswith('VERSION_ID='):
+ # Lets hope for the best that distros stay consistent ;)
+ distro_version = line.split('=')[-1]
+ distro_version = distro_version.replace('"', '')
+ else:
+ dist = ('', '', '')
+ try:
+ # Will be removed in 3.7
+ dist = platform.dist() # pylint: disable=W1505
+ except Exception:
+ pass
+ finally:
+ found = None
+ for entry in dist:
+ if entry:
+ found = 1
+ if not found:
+ LOG.warning('Unable to determine distribution, template '
+ 'expansion may have unexpected results')
+ return dist
+
+ return (distro_name, distro_version, platform.machine())
+
+
def system_info():
info = {
'platform': platform.platform(),
@@ -586,19 +619,19 @@ def system_info():
'release': platform.release(),
'python': platform.python_version(),
'uname': platform.uname(),
- 'dist': platform.dist(), # pylint: disable=W1505
+ 'dist': get_linux_distro()
}
system = info['system'].lower()
var = 'unknown'
if system == "linux":
linux_dist = info['dist'][0].lower()
- if linux_dist in ('centos', 'fedora', 'debian', 'openEuler'):
+ if linux_dist in ('centos', 'debian', 'fedora', 'rhel', 'suse', 'openEuler'):
var = linux_dist
elif linux_dist in ('ubuntu', 'linuxmint', 'mint'):
var = 'ubuntu'
elif linux_dist == 'redhat':
var = 'rhel'
- elif linux_dist == 'suse':
+ elif linux_dist in ('opensuse', 'sles'):
var = 'suse'
else:
var = 'linux'
--
1.8.3.1