X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-dns.git/blobdiff_plain/66f0546472e36a789a40be2b189c645a269efee4..refs/heads/geofft:/invirt-dns diff --git a/invirt-dns b/invirt-dns index 5b24d31..60787a0 100755 --- a/invirt-dns +++ b/invirt-dns @@ -127,7 +127,7 @@ class DatabaseAuthority(common.ResolverBase): if value: ip = value.ip else: - value = invirt.database.Machine.query().filter_by(name=host).first() + value = invirt.database.Machine.query.filter_by(name=host).first() if value: ip = value.nics[0].ip else: @@ -195,29 +195,20 @@ class DelegatingQuotingBindAuthority(authority.BindAuthority): return filter(None, L) def _lookup(self, name, cls, type, timeout = None): - maybeDelegate = False deferredResult = authority.BindAuthority._lookup(self, name, cls, type, timeout) # If we didn't find an exact match for the name we were seeking, # check if it's within a subdomain we're supposed to delegate to # some other DNS server. - while (isinstance(deferredResult.result, failure.Failure) - and '.' in name): - maybeDelegate = True + deferredResult.addErrback(self._delegation_errback, name, cls, timeout) + return deferredResult + + def _delegation_errback(self, deferredResult, name, cls, timeout): + if '.' in name: name = name[name.find('.') + 1 :] deferredResult = authority.BindAuthority._lookup(self, name, cls, dns.NS, timeout) - # If we found somewhere to delegate the query to, our _lookup() - # for the NS record resulted in it being in the 'results' section. - # We need to instead return that information in the 'authority' - # section to delegate, and return an empty 'results' section - # (because we didn't find the name we were asked about). We - # leave the 'additional' section as we received it because it - # may contain A records for the DNS server we're delegating to. - if maybeDelegate and not isinstance(deferredResult.result, - failure.Failure): - (nsResults, nsAuthority, nsAdditional) = deferredResult.result - deferredResult = defer.succeed(([], nsResults, nsAdditional)) + deferredResult.addErrback(self._delegation_errback, name, cls, timeout) return deferredResult if '__main__' == __name__: