sailesh1993 / rpms / cloud-init

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