sailesh1993 / rpms / cloud-init

Forked from rpms/cloud-init a year ago
Clone
16d12a
From 9a09efb49c2d7cade1f0ac309293166c3c2d8d7b Mon Sep 17 00:00:00 2001
c1c26e
From: Vitaly Kuznetsov <vkuznets@redhat.com>
c1c26e
Date: Tue, 17 Apr 2018 13:07:54 +0200
c1c26e
Subject: DataSourceAzure.py: use hostnamectl to set hostname
c1c26e
c1c26e
RH-Author: Vitaly Kuznetsov <vkuznets@redhat.com>
c1c26e
Message-id: <20180417130754.12918-3-vkuznets@redhat.com>
c1c26e
Patchwork-id: 79659
c1c26e
O-Subject: [RHEL7.6/7.5.z cloud-init PATCH 2/2] DataSourceAzure.py: use hostnamectl to set hostname
c1c26e
Bugzilla: 1568717
c1c26e
RH-Acked-by: Eduardo Otubo <otubo@redhat.com>
c1c26e
RH-Acked-by: Mohammed Gamal <mgamal@redhat.com>
c1c26e
RH-Acked-by: Cathy Avery <cavery@redhat.com>
c1c26e
c1c26e
The right way to set hostname in RHEL7 is:
c1c26e
c1c26e
 $ hostnamectl set-hostname HOSTNAME
c1c26e
c1c26e
DataSourceAzure, however, uses:
c1c26e
 $ hostname HOSTSNAME
c1c26e
c1c26e
instead and this causes problems. We can't simply change
c1c26e
'BUILTIN_DS_CONFIG' in DataSourceAzure.py as 'hostname' is being used
c1c26e
for both getting and setting the hostname.
c1c26e
c1c26e
Long term, this should be fixed in a different way. Cloud-init
c1c26e
has distro-specific hostname setting/getting (see
c1c26e
cloudinit/distros/rhel.py) and DataSourceAzure.py needs to be switched
c1c26e
to use these.
c1c26e
c1c26e
Resolves: rhbz#1434109
c1c26e
c1c26e
X-downstream-only: yes
c1c26e
c1c26e
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
c1c26e
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
c1c26e
---
c1c26e
 cloudinit/sources/DataSourceAzure.py | 2 +-
c1c26e
 1 file changed, 1 insertion(+), 1 deletion(-)
c1c26e
c1c26e
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
16d12a
index 24f448c..6fb889c 100755
c1c26e
--- a/cloudinit/sources/DataSourceAzure.py
c1c26e
+++ b/cloudinit/sources/DataSourceAzure.py
16d12a
@@ -256,7 +256,7 @@ def get_hostname(hostname_command='hostname'):
c1c26e
 
c1c26e
 
c1c26e
 def set_hostname(hostname, hostname_command='hostname'):
c1c26e
-    util.subp([hostname_command, hostname])
c1c26e
+    util.subp(['hostnamectl', 'set-hostname', str(hostname)])
c1c26e
 
c1c26e
 
16d12a
 @azure_ds_telemetry_reporter
c1c26e
-- 
16d12a
1.8.3.1
c1c26e