Blame SOURCES/wla-redhat-Use-NetworkManager-to-set-DHCP-hostnames-on-r.patch

46ba25
From f45dc73365999334e680d64c90d36f710a0c7831 Mon Sep 17 00:00:00 2001
5d5c10
From: Mohammed Gamal <mgamal@redhat.com>
5d5c10
Date: Fri, 29 Jul 2022 13:07:13 +0200
46ba25
Subject: [PATCH 1/2] redhat: Use NetworkManager to set DHCP hostnames on
46ba25
 recent RHEL distros
5d5c10
5d5c10
RH-Author: Mohamed Gamal Morsy <mmorsy@redhat.com>
46ba25
RH-MergeRequest: 8: redhat: Use NetworkManager to set DHCP hostnames on recent RHEL distros
46ba25
RH-Commit: [1/1] b83612e9d88bac7117541d7f7832f65ef268bbe3
46ba25
RH-Bugzilla: 2092002
46ba25
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
5d5c10
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
5d5c10
46ba25
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2092002
5d5c10
5d5c10
Recent versions of RHEL 8 and RHEL 9 started using NetworkManager to configure
5d5c10
network intefaces instead of sysconfig files. Configurations are no longer
5d5c10
stored in /etc/sysconfig/ifcfg-{interface}.
5d5c10
5d5c10
Fix this for setting DHCP hostnames in those RHEL versions.
5d5c10
5d5c10
Signed-off-by: Mohammed Gamal <mgamal@redhat.com>
5d5c10
---
5d5c10
 azurelinuxagent/common/osutil/redhat.py | 12 ++++++++++++
5d5c10
 1 file changed, 12 insertions(+)
5d5c10
5d5c10
diff --git a/azurelinuxagent/common/osutil/redhat.py b/azurelinuxagent/common/osutil/redhat.py
5d5c10
index 5c397ae8..7dd36add 100644
5d5c10
--- a/azurelinuxagent/common/osutil/redhat.py
5d5c10
+++ b/azurelinuxagent/common/osutil/redhat.py
5d5c10
@@ -158,3 +158,15 @@ class RedhatOSUtil(Redhat6xOSUtil):
5d5c10
                 time.sleep(wait)
5d5c10
             else:
5d5c10
                 logger.warn("exceeded restart retries")
5d5c10
+
5d5c10
+    def set_dhcp_hostname(self, hostname):
5d5c10
+        """
5d5c10
+        Recent RHEL distributions use network manager instead of sysconfig files
5d5c10
+        to configure network interfaces
5d5c10
+        """
5d5c10
+        ifname = self.get_if_name()
5d5c10
+
5d5c10
+        return_code = shellutil.run("nmcli device modify {0} ipv4.dhcp-hostname {1} ipv6.dhcp-hostname {1}".format(ifname, hostname))
5d5c10
+
5d5c10
+        if return_code != 0:
5d5c10
+            logger.error("failed to set DHCP hostname for interface {0}: return code {1}".format(ifname, return_code))
5d5c10
-- 
46ba25
2.31.1
5d5c10