def _iter_hosts(self):
        v6_nets = dict((subnet.id, subnet) for subnet in
                       self.network.subnets if subnet.ip_version == 6)

        for port in self.network.ports:
            fixed_ips = self._sort_fixed_ips_for_dnsmasq(port.fixed_ips,
                                                         v6_nets)
            # Confirm whether Neutron server supports dns_name attribute in the
            # ports API
            dns_assignment = getattr(port, 'dns_assignment', None)
            if dns_assignment:
                dns_ip_map = {d.ip_address: d for d in dns_assignment}
            for alloc in fixed_ips:
                no_dhcp = False
                no_opts = False
                if alloc.subnet_id in v6_nets:
                    addr_mode = v6_nets[alloc.subnet_id].ipv6_address_mode
                    no_dhcp = addr_mode in (n_const.IPV6_SLAAC,
                                            n_const.DHCPV6_STATELESS)
                    # we don't setup anything for SLAAC. It doesn't make sense
                    # to provide options for a client that won't use DHCP
                    no_opts = addr_mode == n_const.IPV6_SLAAC

                # If dns_name attribute is supported by ports API, return the
                # dns_assignment generated by the Neutron server. Otherwise,
                # generate hostname and fqdn locally (previous behaviour)
                if dns_assignment:
                    hostname = dns_ip_map[alloc.ip_address].hostname
                    fqdn = dns_ip_map[alloc.ip_address].fqdn
                else:
                    hostname = 'host-%s' % alloc.ip_address.replace(
                        '.', '-').replace(':', '-')
                    fqdn = hostname
                    if self.conf.dhcp_domain:
                        fqdn = '%s.%s' % (fqdn, self.conf.dhcp_domain)
                yield (port, alloc, hostname, fqdn, no_dhcp, no_opts)
Iterate over hosts.
dataset/ETHPy150Open openstack/neutron/neutron/agent/linux/dhcp.py/Dnsmasq._iter_hosts