Accepting request 445052 from home:jgleissner:branches:Cloud:Tools

fix handling of user maintained hostname

OBS-URL: https://build.opensuse.org/request/show/445052
OBS-URL: https://build.opensuse.org/package/show/Cloud:Tools/cloud-init?expand=0&rev=70
This commit is contained in:
Robert Schweikert 2016-12-09 12:50:46 +00:00 committed by Git OBS Bridge
parent 0548ac26cd
commit ef7ff0197f
4 changed files with 54 additions and 5 deletions

23
cloud-init-python26.patch Normal file
View File

@ -0,0 +1,23 @@
Index: cloud-init-0.7.8/cloudinit/util.py
===================================================================
--- cloud-init-0.7.8.orig/cloudinit/util.py
+++ cloud-init-0.7.8/cloudinit/util.py
@@ -283,9 +283,6 @@ class ProcessExecutionError(IOError):
'reason': self.reason,
}
IOError.__init__(self, message)
- # For backward compatibility with Python 2.
- if not hasattr(self, 'message'):
- self.message = message
class SeLinuxGuard(object):
@@ -1816,7 +1813,7 @@ def subp(args, data=None, rcs=None, env=
def ldecode(data, m='utf-8'):
if not isinstance(data, bytes):
return data
- return data.decode(m, errors=decode)
+ return data.decode(m, decode)
out = ldecode(out)
err = ldecode(err)

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Fri Dec 9 09:50:50 UTC 2016 - jgleissner@suse.com
- Modify suseIntegratedHandler.patch (bsc#998103)
+ Store previous hostname so update_hostname module does not
overwrite manually set hostnames
- cloud-init-python26.patch
+ Compatibility fixes with Python 2.6
------------------------------------------------------------------- -------------------------------------------------------------------
Thu Dec 8 12:35:51 UTC 2016 - dmueller@suse.com Thu Dec 8 12:35:51 UTC 2016 - dmueller@suse.com

View File

@ -112,6 +112,7 @@ Requires: dmidecode
%endif %endif
%if 0%{?suse_version} && 0%{?suse_version} <= 1210 %if 0%{?suse_version} && 0%{?suse_version} <= 1210
%define initsys sysvinit_suse %define initsys sysvinit_suse
Patch40: cloud-init-python26.patch
%else %else
%define initsys systemd %define initsys systemd
BuildRequires: systemd BuildRequires: systemd
@ -139,7 +140,9 @@ according to the fetched configuration data from the admin node.
%package config-suse %package config-suse
Summary: Configuration file for Cloud node initialization tool Summary: Configuration file for Cloud node initialization tool
Requires: cloud-init = %{version}
Provides: cloud-init-config = %{version} Provides: cloud-init-config = %{version}
Group: System/Management
Conflicts: otherproviders(cloud-init-config) Conflicts: otherproviders(cloud-init-config)
%description config-suse %description config-suse
@ -191,6 +194,9 @@ Unit tests for the cloud-init tools
%patch27 %patch27
%patch28 -p0 %patch28 -p0
%patch29 -p0 %patch29 -p0
%if 0%{?suse_version} && 0%{?suse_version} <= 1210
%patch40 -p1
%endif
%if 0%{?suse_version} <= 1130 %if 0%{?suse_version} <= 1130
# disable ecdsa for SLE 11 (not available) # disable ecdsa for SLE 11 (not available)

View File

@ -1,6 +1,8 @@
Index: cloudinit/distros/opensuse.py
===================================================================
--- /dev/null --- /dev/null
+++ cloudinit/distros/opensuse.py +++ cloudinit/distros/opensuse.py
@@ -0,0 +1,226 @@ @@ -0,0 +1,233 @@
+# vi: ts=4 expandtab +# vi: ts=4 expandtab
+# +#
+# Copyright (C) 2016 SUSE LLC +# Copyright (C) 2016 SUSE LLC
@ -134,10 +136,15 @@
+ +
+ +
+ def _read_hostname(self, filename, default=None): + def _read_hostname(self, filename, default=None):
+ if self.systemdDist and filename.endswith('/previous-hostname'):
+ return util.load_file(filename).strip()
+ elif self.systemdDist:
+ (out, _err) = util.subp(['hostname']) + (out, _err) = util.subp(['hostname'])
+ if len(out): + if len(out):
+ return out + return out
+ else: + else:
+ return default
+ else:
+ try: + try:
+ conf = self._read_hostname_conf(filename) + conf = self._read_hostname_conf(filename)
+ hostname = conf.hostname + hostname = conf.hostname
@ -160,7 +167,9 @@
+ return (host_fn, self._read_hostname(host_fn)) + return (host_fn, self._read_hostname(host_fn))
+ +
+ def _write_hostname(self, hostname, out_fn): + def _write_hostname(self, hostname, out_fn):
+ if self.systemdDist: + if self.systemdDist and out_fn.endswith('/previous-hostname'):
+ util.write_file(out_fn, hostname)
+ elif self.systemdDist:
+ util.subp(['hostnamectl', 'set-hostname', str(hostname)]) + util.subp(['hostnamectl', 'set-hostname', str(hostname)])
+ else: + else:
+ conf = None + conf = None
@ -227,6 +236,8 @@
+# ns = parse_net_config_data(netconfig) +# ns = parse_net_config_data(netconfig)
+# self._net_renderer.render_network_state("/", ns) +# self._net_renderer.render_network_state("/", ns)
+# return [] +# return []
Index: cloudinit/distros/sles.py
===================================================================
--- cloudinit/distros/sles.py.orig --- cloudinit/distros/sles.py.orig
+++ cloudinit/distros/sles.py +++ cloudinit/distros/sles.py
@@ -1,10 +1,9 @@ @@ -1,10 +1,9 @@