Skip to content
Closed
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
13 changes: 13 additions & 0 deletions azurelinuxagent/common/osutil/redhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,19 @@ def check_and_recover_nic_state(self, ifname):
# TODO: Implement and test a way to recover the network interface for RedhatOSModernUtil
pass


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))

def publish_hostname(self, hostname, recover_nic=False):
# RedhatOSUtil was updated to conditionally run NetworkManager restart in response to a race condition between
# NetworkManager restart and the agent restarting the network interface during publish_hostname. Keeping the
Expand Down