~andreserl/maas/lp1604962_lp1604987

« back to all changes in this revision

Viewing changes to src/maasserver/models/dnsresource.py

  • Committer: MAAS Lander
  • Author(s): LaMont Jones
  • Date: 2016-07-08 13:57:44 UTC
  • mfrom: (5157.1.3 bug-1599223)
  • Revision ID: maas_lander-20160708135744-aawne8ihh6ojn10m
[r=mpontillo][bug=1599223][author=lamont] Refactor get_hostname_ip_mapping() and stop generating multiple PTR RRs for node FQDNs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
    """
76
76
    if fqdn is None or fqdn == '' or fqdn == '@':
77
77
        return (fqdn, None)
78
 
    elif Domain.objects.filter(name=fqdn).exists():
79
 
        if domainname == fqdn or domainname is None:
 
78
    if domainname is not None:
 
79
        if domainname == fqdn:
80
80
            return ('@', fqdn)
81
81
        else:
82
82
            # strip off the passed in ".$domainname" from the fqdn.
83
83
            name = fqdn[:-len(domainname) - 1]
84
84
            return (name, domainname)
85
 
    elif rrtype == 'SRV':
 
85
    else:
 
86
        if Domain.objects.filter(name=fqdn).exists():
 
87
            return ('@', fqdn)
 
88
    if rrtype == 'SRV':
86
89
        spec = SRV_LHS
87
90
    else:
88
91
        spec = LABEL