mirror of
https://github.com/clearlinux/WALinuxAgent.git
synced 2026-09-03 20:31:31 +00:00
Fix hostname publishing for centos 6.x
This commit is contained in:
@@ -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,18 @@ 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 register_agent_service(self):
|
||||
return shellutil.run("systemctl enable waagent", chk_err=False)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user