Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions azurelinuxagent/common/osutil/redhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,15 @@ def restart_if(self, ifname, retries=3, wait=5):
time.sleep(wait)
else:
logger.warn("exceeded restart retries")

def set_dhcp_hostname(self, hostname):
"""
Recent RHEL distributions use network manager instead of sysconfig files
to configure network interfaces
"""
ifname = self.get_if_name()

return_code = shellutil.run("nmcli device modify {0} ipv4.dhcp-hostname {1} ipv6.dhcp-hostname {1}".format(ifname, hostname))

if return_code != 0:
logger.error("failed to set DHCP hostname for interface {0}: return code {1}".format(ifname, return_code))