# an IPv6 address because of stateless DHCPv6 network.
host_name, # Host name.
name, # Canonical hostname in the format 'hostname[.domain]'.
+ no_dhcp, # A flag indicating that the address doesn't need DHCP.
)
"""
v6_nets = dict((subnet.id, subnet) for subnet in
if dns_assignment:
dns_ip_map = {d.ip_address: d for d in dns_assignment}
for alloc in fixed_ips:
- # Note(scollins) Only create entries that are
- # associated with the subnet being managed by this
- # dhcp agent
+ no_dhcp = False
if alloc.subnet_id in v6_nets:
addr_mode = v6_nets[alloc.subnet_id].ipv6_address_mode
- if addr_mode == constants.IPV6_SLAAC:
- continue
- elif addr_mode == constants.DHCPV6_STATELESS:
- alloc = hostname = fqdn = None
- yield (port, alloc, hostname, fqdn)
- continue
+ no_dhcp = addr_mode in (constants.IPV6_SLAAC,
+ constants.DHCPV6_STATELESS)
# If dns_name attribute is supported by ports API, return the
# dns_assignment generated by the Neutron server. Otherwise,
fqdn = hostname
if self.conf.dhcp_domain:
fqdn = '%s.%s' % (fqdn, self.conf.dhcp_domain)
- yield (port, alloc, hostname, fqdn)
+ yield (port, alloc, hostname, fqdn, no_dhcp)
def _get_port_extra_dhcp_opts(self, port):
return getattr(port, edo_ext.EXTRADHCPOPTS, False)
timestamp = int(time.time()) + self.conf.dhcp_lease_duration
dhcp_enabled_subnet_ids = [s.id for s in self.network.subnets
if s.enable_dhcp]
- for (port, alloc, hostname, name) in self._iter_hosts():
- # don't write ip address which belongs to a dhcp disabled subnet.
- if not alloc or alloc.subnet_id not in dhcp_enabled_subnet_ids:
+ for (port, alloc, hostname, name, no_dhcp) in self._iter_hosts():
+ # don't write ip address which belongs to a dhcp disabled subnet
+ # or an IPv6 SLAAC/stateless subnet
+ if no_dhcp or alloc.subnet_id not in dhcp_enabled_subnet_ids:
continue
ip_address = self._format_address_for_dnsmasq(alloc.ip_address)
if s.enable_dhcp]
# NOTE(ihrachyshka): the loop should not log anything inside it, to
# avoid potential performance drop when lots of hosts are dumped
- for (port, alloc, hostname, name) in self._iter_hosts():
- if not alloc:
+ for (port, alloc, hostname, name, no_dhcp) in self._iter_hosts():
+ if no_dhcp:
if self._get_port_extra_dhcp_opts(port):
buf.write('%s,%s%s\n' %
(port.mac_address, 'set:', port.id))
file.
"""
buf = six.StringIO()
- for (port, alloc, hostname, fqdn) in self._iter_hosts():
+ for (port, alloc, hostname, fqdn, no_dhcp) in self._iter_hosts():
# It is compulsory to write the `fqdn` before the `hostname` in
# order to obtain it in PTR responses.
if alloc:
'dddddddd-dddd-dddd-dddd-dddddddddddd'),
FakeIPAllocation('ffda:3ba5:a17a:4ba3:0216:3eff:fec2:771d',
'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee')]
- dns_assignment = [FakeDNSAssignment('192.168.0.4')]
+ dns_assignment = [
+ FakeDNSAssignment('192.168.0.4'),
+ FakeDNSAssignment('ffda:3ba5:a17a:4ba3:0216:3eff:fec2:771d')]
mac_address = '00:16:3E:C2:77:1D'
device_id = 'fake_port4'
device_owner = 'foo3'
fixed_ips = [FakeIPAllocation('ffea:3ba5:a17a:4ba3:0216:3eff:fec2:771d',
'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee')]
- dns_assignment = []
+ dns_assignment = [
+ FakeDNSAssignment('ffea:3ba5:a17a:4ba3:0216:3eff:fec2:771d')]
mac_address = '00:16:3e:c2:77:1d'
device_id = 'fake_port6'
'dddddddd-dddd-dddd-dddd-dddddddddddd'),
FakeIPAllocation('ffea:3ba5:a17a:4ba3:0216:3eff:fec2:771d',
'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee')]
- dns_assignment = [FakeDNSAssignment('192.168.0.3')]
+ dns_assignment = [
+ FakeDNSAssignment('192.168.0.3'),
+ FakeDNSAssignment('ffea:3ba5:a17a:4ba3:0216:3eff:fec2:771d')]
mac_address = '00:16:3e:c2:77:1d'
device_id = 'fake_port6'