sailesh1993 / rpms / cloud-init

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