From ef7ff0197fbbf6b3b670efda7a0d65c970cdd338e8550a740722bea1d3e3a0a0 Mon Sep 17 00:00:00 2001 From: Robert Schweikert Date: Fri, 9 Dec 2016 12:50:46 +0000 Subject: [PATCH] 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 --- cloud-init-python26.patch | 23 +++++++++++++++++++++++ cloud-init.changes | 9 +++++++++ cloud-init.spec | 6 ++++++ suseIntegratedHandler.patch | 21 ++++++++++++++++----- 4 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 cloud-init-python26.patch diff --git a/cloud-init-python26.patch b/cloud-init-python26.patch new file mode 100644 index 0000000..d540409 --- /dev/null +++ b/cloud-init-python26.patch @@ -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) diff --git a/cloud-init.changes b/cloud-init.changes index e71f894..6aee8a0 100644 --- a/cloud-init.changes +++ b/cloud-init.changes @@ -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 diff --git a/cloud-init.spec b/cloud-init.spec index a8d5c61..927a808 100644 --- a/cloud-init.spec +++ b/cloud-init.spec @@ -112,6 +112,7 @@ Requires: dmidecode %endif %if 0%{?suse_version} && 0%{?suse_version} <= 1210 %define initsys sysvinit_suse +Patch40: cloud-init-python26.patch %else %define initsys systemd BuildRequires: systemd @@ -139,7 +140,9 @@ according to the fetched configuration data from the admin node. %package config-suse Summary: Configuration file for Cloud node initialization tool +Requires: cloud-init = %{version} Provides: cloud-init-config = %{version} +Group: System/Management Conflicts: otherproviders(cloud-init-config) %description config-suse @@ -191,6 +194,9 @@ Unit tests for the cloud-init tools %patch27 %patch28 -p0 %patch29 -p0 +%if 0%{?suse_version} && 0%{?suse_version} <= 1210 +%patch40 -p1 +%endif %if 0%{?suse_version} <= 1130 # disable ecdsa for SLE 11 (not available) diff --git a/suseIntegratedHandler.patch b/suseIntegratedHandler.patch index c411035..e48d281 100644 --- a/suseIntegratedHandler.patch +++ b/suseIntegratedHandler.patch @@ -1,6 +1,8 @@ +Index: cloudinit/distros/opensuse.py +=================================================================== --- /dev/null +++ cloudinit/distros/opensuse.py -@@ -0,0 +1,226 @@ +@@ -0,0 +1,233 @@ +# vi: ts=4 expandtab +# +# Copyright (C) 2016 SUSE LLC @@ -134,9 +136,14 @@ + + + def _read_hostname(self, filename, default=None): -+ (out, _err) = util.subp(['hostname']) -+ if len(out): -+ return out ++ if self.systemdDist and filename.endswith('/previous-hostname'): ++ return util.load_file(filename).strip() ++ elif self.systemdDist: ++ (out, _err) = util.subp(['hostname']) ++ if len(out): ++ return out ++ else: ++ return default + else: + try: + conf = self._read_hostname_conf(filename) @@ -160,7 +167,9 @@ + return (host_fn, self._read_hostname(host_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)]) + else: + conf = None @@ -227,6 +236,8 @@ +# ns = parse_net_config_data(netconfig) +# self._net_renderer.render_network_state("/", ns) +# return [] +Index: cloudinit/distros/sles.py +=================================================================== --- cloudinit/distros/sles.py.orig +++ cloudinit/distros/sles.py @@ -1,10 +1,9 @@