From 83432149e212155469b1e9f06eb0095121377356 Mon Sep 17 00:00:00 2001 From: Ben Howard Date: Mon, 7 Dec 2015 16:48:51 -0700 Subject: Import patches-unapplied version 2.1.2-0ubuntu1 to ubuntu/xenial-proposed Imported using git-ubuntu import. Changelog parent: 04946cba49f19c0b6b876bccdbb36d47334af002 New changelog entries: * New upstream release (LP: #1523715): - Bug fixes for Ubuntu 15.10 on Azure - Enablement for Azure Stack - Dropped patch for systemd job as upstream now includes it. --- azurelinuxagent/distro/redhat/osutil.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'azurelinuxagent/distro/redhat/osutil.py') diff --git a/azurelinuxagent/distro/redhat/osutil.py b/azurelinuxagent/distro/redhat/osutil.py index c6c3016..7478867 100644 --- a/azurelinuxagent/distro/redhat/osutil.py +++ b/azurelinuxagent/distro/redhat/osutil.py @@ -122,15 +122,14 @@ class Redhat6xOSUtil(DefaultOSUtil): ret= shellutil.run_get_output("pidof dhclient") return ret[1] if ret[0] == 0 else None -class RedhatOSUtil(Redhat6xOSUtil): - def __init__(self): - super(RedhatOSUtil, self).__init__() - def set_hostname(self, hostname): - super(RedhatOSUtil, self).set_hostname(hostname) + """ + Set /etc/sysconfig/network + """ fileutil.update_conf_file('/etc/sysconfig/network', 'HOSTNAME', 'HOSTNAME={0}'.format(hostname)) + shellutil.run("hostname {0}".format(hostname), chk_err=False) def set_dhcp_hostname(self, hostname): ifname = self.get_if_name() @@ -139,6 +138,24 @@ class RedhatOSUtil(Redhat6xOSUtil): 'DHCP_HOSTNAME', 'DHCP_HOSTNAME={0}'.format(hostname)) +class RedhatOSUtil(Redhat6xOSUtil): + def __init__(self): + super(RedhatOSUtil, self).__init__() + + def set_hostname(self, hostname): + """ + Set /etc/hostname + Unlike redhat 6.x, redhat 7.x will set hostname to /etc/hostname + """ + DefaultOSUtil.set_hostname(self, hostname) + + def publish_hostname(self, hostname): + """ + Restart NetworkManager first before publishing hostname + """ + shellutil.run("service NetworkManager restart") + super(RedhatOSUtil, self).publish_hostname(hostname) + def register_agent_service(self): return shellutil.run("systemctl enable waagent", chk_err=False) -- cgit v1.2.3