Merge "Log dnsmasq host file generation"
This commit is contained in:
commit
04464f2458
@ -403,6 +403,9 @@ class Dnsmasq(DhcpLocalProcess):
|
|||||||
"""Writes a dnsmasq compatible hosts file."""
|
"""Writes a dnsmasq compatible hosts file."""
|
||||||
r = re.compile('[:.]')
|
r = re.compile('[:.]')
|
||||||
buf = six.StringIO()
|
buf = six.StringIO()
|
||||||
|
filename = self.get_conf_file_name('host')
|
||||||
|
|
||||||
|
LOG.debug(_('Building host file: %s'), filename)
|
||||||
|
|
||||||
for port in self.network.ports:
|
for port in self.network.ports:
|
||||||
for alloc in port.fixed_ips:
|
for alloc in port.fixed_ips:
|
||||||
@ -415,6 +418,11 @@ class Dnsmasq(DhcpLocalProcess):
|
|||||||
ip_address = alloc.ip_address
|
ip_address = alloc.ip_address
|
||||||
if netaddr.valid_ipv6(ip_address):
|
if netaddr.valid_ipv6(ip_address):
|
||||||
ip_address = '[%s]' % ip_address
|
ip_address = '[%s]' % ip_address
|
||||||
|
|
||||||
|
LOG.debug(_('Adding %(mac)s : %(name)s : %(ip)s'),
|
||||||
|
{"mac": port.mac_address, "name": name,
|
||||||
|
"ip": ip_address})
|
||||||
|
|
||||||
if getattr(port, 'extra_dhcp_opts', False):
|
if getattr(port, 'extra_dhcp_opts', False):
|
||||||
if self.version >= self.MINIMUM_VERSION:
|
if self.version >= self.MINIMUM_VERSION:
|
||||||
set_tag = 'set:'
|
set_tag = 'set:'
|
||||||
@ -426,9 +434,9 @@ class Dnsmasq(DhcpLocalProcess):
|
|||||||
buf.write('%s,%s,%s\n' %
|
buf.write('%s,%s,%s\n' %
|
||||||
(port.mac_address, name, ip_address))
|
(port.mac_address, name, ip_address))
|
||||||
|
|
||||||
name = self.get_conf_file_name('host')
|
utils.replace_file(filename, buf.getvalue())
|
||||||
utils.replace_file(name, buf.getvalue())
|
LOG.debug(_('Done building host file %s'), filename)
|
||||||
return name
|
return filename
|
||||||
|
|
||||||
def _read_hosts_file_leases(self, filename):
|
def _read_hosts_file_leases(self, filename):
|
||||||
leases = set()
|
leases = set()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user