diff --git a/SOURCES/agent-RHEL-7-hostname-533.patch b/SOURCES/agent-RHEL-7-hostname-533.patch new file mode 100644 index 0000000..0dec5d3 --- /dev/null +++ b/SOURCES/agent-RHEL-7-hostname-533.patch @@ -0,0 +1,59 @@ +From 845e4647f72d27fc9aeaee5cd69d40a052d85f62 Mon Sep 17 00:00:00 2001 +From: Vitaly Kuznetsov +Date: Wed, 11 Jan 2017 16:40:59 +0100 +Subject: [PATCH 1/2] RHEL-7 hostname (#533) + +RH-Author: Vitaly Kuznetsov +Message-id: <20170111164100.436-2-vkuznets@redhat.com> +Patchwork-id: 73240 +O-Subject: [RHEL-7.4/7.3.z WALinuxAgent PATCH 1/2] RHEL-7 hostname (#533) +Bugzilla: 1413674 +RH-Acked-by: Cathy Avery + +From: Hans Krijger + +* use hostnamectl for redhat 7.x + +* create directory if it is missing + +(cherry picked from commit 8f91a15cd59b6ed81cdfa28e6014a226ce613c9e) +Signed-off-by: Miroslav Rezanina +--- + azurelinuxagent/common/osutil/redhat.py | 5 ++--- + azurelinuxagent/ga/exthandlers.py | 3 +++ + 2 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/azurelinuxagent/common/osutil/redhat.py b/azurelinuxagent/common/osutil/redhat.py +index 80370a2..f8372f0 100644 +--- a/azurelinuxagent/common/osutil/redhat.py ++++ b/azurelinuxagent/common/osutil/redhat.py +@@ -96,10 +96,9 @@ class RedhatOSUtil(Redhat6xOSUtil): + + def set_hostname(self, hostname): + """ +- Set /etc/hostname +- Unlike redhat 6.x, redhat 7.x will set hostname to /etc/hostname ++ Unlike redhat 6.x, redhat 7.x will set hostname via hostnamectl + """ +- DefaultOSUtil.set_hostname(self, hostname) ++ shellutil.run("hostnamectl {0}".format(hostname)) + + def publish_hostname(self, hostname): + """ +diff --git a/azurelinuxagent/ga/exthandlers.py b/azurelinuxagent/ga/exthandlers.py +index 192300e..5b35f45 100644 +--- a/azurelinuxagent/ga/exthandlers.py ++++ b/azurelinuxagent/ga/exthandlers.py +@@ -798,6 +798,9 @@ class ExtHandlerInstance(object): + def set_handler_state(self, handler_state): + state_dir = self.get_conf_dir() + try: ++ if not os.path.exists(state_dir): ++ fileutil.mkdir(state_dir, mode=0o700) ++ + state_file = os.path.join(state_dir, "HandlerState") + fileutil.write_file(state_file, handler_state) + except IOError as e: +-- +1.8.3.1 + diff --git a/SOURCES/agent-fix-for-hostnamectl-534.patch b/SOURCES/agent-fix-for-hostnamectl-534.patch new file mode 100644 index 0000000..9dd991c --- /dev/null +++ b/SOURCES/agent-fix-for-hostnamectl-534.patch @@ -0,0 +1,36 @@ +From f51337e5b8746ccb4402129c9bd3d86c578e49f0 Mon Sep 17 00:00:00 2001 +From: Vitaly Kuznetsov +Date: Wed, 11 Jan 2017 16:41:00 +0100 +Subject: [PATCH 2/2] fix for hostnamectl (#534) + +RH-Author: Vitaly Kuznetsov +Message-id: <20170111164100.436-3-vkuznets@redhat.com> +Patchwork-id: 73241 +O-Subject: [RHEL-7.4/7.3.z WALinuxAgent PATCH 2/2] fix for hostnamectl (#534) +Bugzilla: 1413674 +RH-Acked-by: Cathy Avery + +From: Hans Krijger + +(cherry picked from commit 5949843494a0c00d852f01e35a87d34674960f2b) +Signed-off-by: Miroslav Rezanina +--- + azurelinuxagent/common/osutil/redhat.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/azurelinuxagent/common/osutil/redhat.py b/azurelinuxagent/common/osutil/redhat.py +index f8372f0..8e86f6e 100644 +--- a/azurelinuxagent/common/osutil/redhat.py ++++ b/azurelinuxagent/common/osutil/redhat.py +@@ -98,7 +98,7 @@ class RedhatOSUtil(Redhat6xOSUtil): + """ + Unlike redhat 6.x, redhat 7.x will set hostname via hostnamectl + """ +- shellutil.run("hostnamectl {0}".format(hostname)) ++ shellutil.run("hostnamectl set-hostname {0}".format(hostname)) + + def publish_hostname(self, hostname): + """ +-- +1.8.3.1 + diff --git a/SPECS/WALinuxAgent.spec b/SPECS/WALinuxAgent.spec index bdb6215..c7ad869 100644 --- a/SPECS/WALinuxAgent.spec +++ b/SPECS/WALinuxAgent.spec @@ -1,7 +1,6 @@ %define name WALinuxAgent %define version 2.2.0 %define unmangled_version 2.2.0 -%define release 3 %if 0%{?rhel} < 7 %global initsys sysV @@ -12,10 +11,14 @@ Summary: UNKNOWN Name: %{name} Version: %{version} -Release: %{release}%{?dist} +Release: 4%{?dist} Source0: %{name}-%{unmangled_version}.tar.gz Patch0: agent-no-auto-update.patch Patch1: agent-no-auto-update-when-upgrading.patch +# For bz#1413674 - [WALA] Fail to send hostname to DHCP server during provisioning +Patch2: agent-RHEL-7-hostname-533.patch +# For bz#1413674 - [WALA] Fail to send hostname to DHCP server during provisioning +Patch3: agent-fix-for-hostnamectl-534.patch License: Apache License Version 2.0 Group: Development/Libraries BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot @@ -70,6 +73,8 @@ images that are built to run in the Azure environment. %setup -n %{name}-%{unmangled_version} -n %{name}-%{unmangled_version} %patch0 -p1 %patch1 -p1 +%patch2 -p1 +%patch3 -p1 %build python setup.py build @@ -118,6 +123,12 @@ fi %defattr(-,root,root) %changelog +* Mon Jan 16 2017 Miroslav Rezanina - 2.2.0-4.el7_3 +- agent-RHEL-7-hostname-533.patch [bz#1413674] +- agent-fix-for-hostnamectl-534.patch [bz#1413674] +- Resolves: bz#1413674 + ([WALA] Fail to send hostname to DHCP server during provisioning) + * Thu Nov 03 2016 Dave Anderson - 2.2.0-3 - Set implicit default of AutoUpdate.Enabled=n when upgrading Resolves: rhbz#1374115