Skip to content

Commit

Permalink
Fix the issue caused by the non-existence of the hostname file
Browse files Browse the repository at this point in the history
  • Loading branch information
zhihuiyuze committed May 29, 2024
1 parent 084699f commit 3a169c7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions python/vyos/ifconfig/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1358,10 +1358,11 @@ def set_dhcp(self, enable):
# read configured system hostname.
# maybe change to vyos hostd client ???
hostname = 'vyos'
with open('/etc/hostname', 'r') as f:
hostname = f.read().rstrip('\n')
tmp = {'dhcp_options' : { 'host_name' : hostname}}
self.config = dict_merge(tmp, self.config)
if os.path.isfile('/etc/hostname'):
with open('/etc/hostname', 'r') as f:
hostname = f.read().rstrip('\n')
tmp = {'dhcp_options' : { 'host_name' : hostname}}
self.config = dict_merge(tmp, self.config)

render(systemd_override_file, 'dhcp-client/override.conf.j2', self.config)
render(dhclient_config_file, 'dhcp-client/ipv4.j2', self.config)
Expand Down

0 comments on commit 3a169c7

Please sign in to comment.