~lamont/maas/bug-1599223-2.0

« back to all changes in this revision

Viewing changes to src/maasserver/dns/zonegenerator.py

  • Committer: LaMont Jones
  • Date: 2016-07-07 18:31:23 UTC
  • Revision ID: lamont@canonical.com-20160707183123-46vktl6e7ri8xtc5
Add forward mapping for interface-name IPs.  Drop interface-named PTR RR for
boot-interfaces.

Show diffs side-by-side

added added

removed removed

Lines of Context:
187
187
        # 2. Dnsresource non-address records in this domain.
188
188
        # 3. For the default domain all forward look ups for the managed and
189
189
        #    unmanaged dynamic ranges.
 
190
        # 4. Add all of the (non-boot) interface named records.
190
191
        for domain in domains:
191
192
            # 1. node: ip mapping(domain)
192
193
            # Map all of the nodes in this domain, including the user-reserved
216
217
                        if ip_range.type == IPRANGE_TYPE.DYNAMIC:
217
218
                            dynamic_ranges.append(ip_range.get_MAASIPRange())
218
219
 
 
220
            # 4. Add all of the (non-boot) interface named records.
 
221
            # This will also include any discovered addresses on such
 
222
            # interfaces.
 
223
            nodes = Node.objects.filter(
 
224
                domain_id=domain.id,
 
225
                interface__ip_addresses__ip__isnull=False).prefetch_related(
 
226
                "interface_set__ip_addresses")
 
227
            for node in nodes:
 
228
                if node.address_ttl is not None:
 
229
                    ttl = node.address_ttl
 
230
                elif node.domain.ttl is not None:
 
231
                    ttl = node.domain.ttl
 
232
                else:
 
233
                    ttl = default_ttl
 
234
                boot_iface = node.get_boot_interface()
 
235
                # If we want boot interfaces also have a name, change the
 
236
                # exclude() to all().  See LP:#1599223.
 
237
                for iface in node.interface_set.exclude(id=boot_iface.id):
 
238
                    ips = {
 
239
                        ip.ip
 
240
                        for ip in iface.ip_addresses.all()
 
241
                        if (ip.ip is not None)}
 
242
                    if len(ips) > 0:
 
243
                        iface_map = HostnameIPMapping(
 
244
                            node.system_id, ttl, ips, node.node_type)
 
245
                        mapping.update({
 
246
                            "%s.%s" % (iface.name, iface.node.fqdn): iface_map
 
247
                        })
 
248
 
219
249
            yield DNSForwardZoneConfig(
220
250
                domain.name, serial=serial, dns_ip=dns_ip,
221
251
                default_ttl=default_ttl,
288
318
            mapping = mappings[subnet]
289
319
 
290
320
            # 3. Add all of the interface named records.
291
 
            # 2015-12-18 lamont N.B., these are not found in the forward zone,
292
 
            # on purpose.  If someone eventually calls this a bug, we can
293
 
            # revisit the size increase this would create in the forward zone.
294
321
            # This will also include any discovered addresses on such
295
322
            # interfaces.
296
323
            nodes = Node.objects.filter(
304
331
                    ttl = node.domain.ttl
305
332
                else:
306
333
                    ttl = default_ttl
307
 
                for iface in node.interface_set.all():
 
334
                boot_iface = node.get_boot_interface()
 
335
                # If we want boot interfaces also have a name, change the
 
336
                # exclude() to all().  See LP:#1599223.
 
337
                for iface in node.interface_set.exclude(id=boot_iface.id):
308
338
                    ips_in_subnet = {
309
339
                        ip.ip
310
340
                        for ip in iface.ip_addresses.all()