Merge "Remove IPv6 addresses in dnsmasq leases file"
This commit is contained in:
commit
56dfd7291d
|
@ -638,21 +638,20 @@ class Dnsmasq(DhcpLocalProcess):
|
||||||
timestamp = 0
|
timestamp = 0
|
||||||
else:
|
else:
|
||||||
timestamp = int(time.time()) + self.conf.dhcp_lease_duration
|
timestamp = int(time.time()) + self.conf.dhcp_lease_duration
|
||||||
dhcp_enabled_subnet_ids = [s.id for s in
|
dhcpv4_enabled_subnet_ids = [
|
||||||
self._get_all_subnets(self.network)
|
s.id for s in self._get_all_subnets(self.network)
|
||||||
if s.enable_dhcp]
|
if s.enable_dhcp and s.ip_version == constants.IP_VERSION_4]
|
||||||
for host_tuple in self._iter_hosts():
|
for host_tuple in self._iter_hosts():
|
||||||
port, alloc, hostname, name, no_dhcp, no_opts = host_tuple
|
port, alloc, hostname, name, no_dhcp, no_opts = host_tuple
|
||||||
# don't write ip address which belongs to a dhcp disabled subnet
|
# don't write ip address which belongs to a dhcp disabled subnet
|
||||||
# or an IPv6 SLAAC/stateless subnet
|
# or an IPv6 subnet.
|
||||||
if no_dhcp or alloc.subnet_id not in dhcp_enabled_subnet_ids:
|
if no_dhcp or alloc.subnet_id not in dhcpv4_enabled_subnet_ids:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
ip_address = self._format_address_for_dnsmasq(alloc.ip_address)
|
|
||||||
# all that matters is the mac address and IP. the hostname and
|
# all that matters is the mac address and IP. the hostname and
|
||||||
# client ID will be overwritten on the next renewal.
|
# client ID will be overwritten on the next renewal.
|
||||||
buf.write('%s %s %s * *\n' %
|
buf.write('%s %s %s * *\n' %
|
||||||
(timestamp, port.mac_address, ip_address))
|
(timestamp, port.mac_address, alloc.ip_address))
|
||||||
contents = buf.getvalue()
|
contents = buf.getvalue()
|
||||||
file_utils.replace_file(filename, contents)
|
file_utils.replace_file(filename, contents)
|
||||||
LOG.debug('Done building initial lease file %s with contents:\n%s',
|
LOG.debug('Done building initial lease file %s with contents:\n%s',
|
||||||
|
|
|
@ -1465,9 +1465,7 @@ class TestDnsmasq(TestBase):
|
||||||
def _test_output_init_lease_file(self, timestamp):
|
def _test_output_init_lease_file(self, timestamp):
|
||||||
expected = [
|
expected = [
|
||||||
'00:00:80:aa:bb:cc 192.168.0.2 * *',
|
'00:00:80:aa:bb:cc 192.168.0.2 * *',
|
||||||
'00:00:f3:aa:bb:cc [fdca:3ba5:a17a:4ba3::2] * *',
|
|
||||||
'00:00:0f:aa:bb:cc 192.168.0.3 * *',
|
'00:00:0f:aa:bb:cc 192.168.0.3 * *',
|
||||||
'00:00:0f:aa:bb:cc [fdca:3ba5:a17a:4ba3::3] * *',
|
|
||||||
'00:00:0f:rr:rr:rr 192.168.0.1 * *\n']
|
'00:00:0f:rr:rr:rr 192.168.0.1 * *\n']
|
||||||
expected = "\n".join(['%s %s' % (timestamp, l) for l in expected])
|
expected = "\n".join(['%s %s' % (timestamp, l) for l in expected])
|
||||||
with mock.patch.object(dhcp.Dnsmasq, 'get_conf_file_name') as conf_fn:
|
with mock.patch.object(dhcp.Dnsmasq, 'get_conf_file_name') as conf_fn:
|
||||||
|
|
Loading…
Reference in New Issue