From: Evan Broder Date: Tue, 13 Jan 2009 01:55:00 +0000 (-0500) Subject: DNS lookups first look in the nics table and then the machines table. X-Git-Tag: 0.0.8^0 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-dns.git/commitdiff_plain/bc2b9c977be0dfaffbe83dc226a710453733a2b3 DNS lookups first look in the nics table and then the machines table. This allows VMs with multiple IPs to have DNS names associated with both IPs. svn path=/trunk/packages/invirt-dns/; revision=1974 --- diff --git a/debian/changelog b/debian/changelog index 9a46bc5..5677ef4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +invirt-dns (0.0.8) unstable; urgency=low + + * Check the nics table first and then the machines table so that you can + do DNS lookups for machines with multiple IPs. + + -- Evan Broder Mon, 12 Jan 2009 20:51:28 -0500 + invirt-dns (0.0.7) unstable; urgency=low [ Yang Zhang ] diff --git a/invirt-dns b/invirt-dns index e49c279..4049257 100755 --- a/invirt-dns +++ b/invirt-dns @@ -92,11 +92,17 @@ class DatabaseAuthority(common.ResolverBase): results.append(dns.RRHeader(domain, dns.SOA, dns.IN, ttl, self.soa, auth=True)) else: # Request for a subdomain. - value = invirt.database.Machine.query().filter_by(name=host).first() - if value is None or not value.nics: - return defer.fail(failure.Failure(dns.AuthoritativeDomainError(name))) - ip = value.nics[0].ip - if ip is None: #Deactivated? + value = invirt.database.NIC.query.filter_by(hostname=host).first() + if value: + ip = value.ip + else: + value = invirt.database.Machine.query().filter_by(name=host).first() + if value: + ip = value.nics[0].ip + else: + return defer.fail(failure.Failure(dns.AuthoritativeDomainError(name))) + + if ip is None: return defer.fail(failure.Failure(dns.AuthoritativeDomainError(name))) if type in (dns.A, dns.ALL_RECORDS):