From 83be006e288c58a46f5b76c29b6886c1f417d88c Mon Sep 17 00:00:00 2001 From: Ɓukasz 'sil2100' Zemczak Date: Wed, 15 Mar 2017 10:19:34 +0100 Subject: Import patches-unapplied version 2.2.6-0ubuntu1 to ubuntu/zesty-proposed Imported using git-ubuntu import. Changelog parent: d064ab0bffd429382ea4fafeb144784d403848bd New changelog entries: * New upstream release (LP: #1661750). * debian/control: - Change the maintainer to Ubuntu Developers (LP: #1657528). - Add the dependency of isc-dhcp-client as our maintainer scripts assume it's installed. - Add trailing commas to dependencies, add whitespaces. * Rename ephemeral-disk-warning.sh to ephemeral-disk-warning (lintian error). * debian/docs: - Remove LICENSE.txt as it's redundant. * debian/postinst: - Stop checking for update-initramfs existence using the absolute path, use the 'command' command instead to make lintian happy. * Remove debian/patches/disable-auto-update.patch: - We now ship with auto-updates enabled (LP: #1650522). * debian/maintscript: - Add a maintscript to rename the old logrotate file on upgrade from an ancient version of walinuxagent (LP: #1673152). --- azurelinuxagent/common/osutil/redhat.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'azurelinuxagent/common/osutil/redhat.py') diff --git a/azurelinuxagent/common/osutil/redhat.py b/azurelinuxagent/common/osutil/redhat.py index 80370a2..5254ea5 100644 --- a/azurelinuxagent/common/osutil/redhat.py +++ b/azurelinuxagent/common/osutil/redhat.py @@ -36,6 +36,7 @@ import azurelinuxagent.common.utils.textutil as textutil from azurelinuxagent.common.utils.cryptutil import CryptUtil from azurelinuxagent.common.osutil.default import DefaultOSUtil + class Redhat6xOSUtil(DefaultOSUtil): def __init__(self): super(Redhat6xOSUtil, self).__init__() @@ -57,7 +58,7 @@ class Redhat6xOSUtil(DefaultOSUtil): def unregister_agent_service(self): return shellutil.run("chkconfig --del waagent", chk_err=False) - + def openssl_to_openssh(self, input_file, output_file): pubkey = fileutil.read_file(input_file) try: @@ -67,7 +68,7 @@ class Redhat6xOSUtil(DefaultOSUtil): raise OSUtilError(ustr(e)) fileutil.write_file(output_file, ssh_rsa_pubkey) - #Override + # Override def get_dhcp_pid(self): ret = shellutil.run_get_output("pidof dhclient", chk_err=False) return ret[1] if ret[0] == 0 else None @@ -84,22 +85,28 @@ class Redhat6xOSUtil(DefaultOSUtil): def set_dhcp_hostname(self, hostname): ifname = self.get_if_name() filepath = "/etc/sysconfig/network-scripts/ifcfg-{0}".format(ifname) - fileutil.update_conf_file(filepath, 'DHCP_HOSTNAME', + fileutil.update_conf_file(filepath, + 'DHCP_HOSTNAME', 'DHCP_HOSTNAME={0}'.format(hostname)) def get_dhcp_lease_endpoint(self): return self.get_endpoint_from_leases_path('/var/lib/dhclient/dhclient-*.leases') + 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 + Unlike redhat 6.x, redhat 7.x will set hostname via hostnamectl + Due to a bug in systemd in Centos-7.0, if this call fails, fallback + to hostname. """ - DefaultOSUtil.set_hostname(self, hostname) + hostnamectl_cmd = "hostnamectl set-hostname {0}".format(hostname) + if shellutil.run(hostnamectl_cmd, chk_err=False) != 0: + logger.warn("[{0}] failed, attempting fallback".format(hostnamectl_cmd)) + DefaultOSUtil.set_hostname(self, hostname) def publish_hostname(self, hostname): """ @@ -118,5 +125,11 @@ class RedhatOSUtil(Redhat6xOSUtil): DefaultOSUtil.openssl_to_openssh(self, input_file, output_file) def get_dhcp_lease_endpoint(self): - # centos7 has this weird naming with double hyphen like /var/lib/dhclient/dhclient--eth0.lease - return self.get_endpoint_from_leases_path('/var/lib/dhclient/dhclient-*.lease') + # dhclient + endpoint = self.get_endpoint_from_leases_path('/var/lib/dhclient/dhclient-*.lease') + + if endpoint is None: + # NetworkManager + endpoint = self.get_endpoint_from_leases_path('/var/lib/NetworkManager/dhclient-*.lease') + + return endpoint -- cgit v1.2.3