+ host = name[:-len(domain)-1]
+ other = False
+ if host.endswith(".other"):
+ host = host[:-len(".other")]
+ other = True
+ value = invirt.database.NIC.query.filter_by(hostname=host).first()
+ if value:
+ if other:
+ ip = value.other_ip
+ action = value.other_action
+ else:
+ ip = value.ip
+ else:
+ value = invirt.database.Machine.query.filter_by(name=host).first()
+ if value:
+ if other:
+ ip = value.nics[0].other_ip
+ action = value.nics[0].other_action
+ else:
+ 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):
+ record = dns.Record_A(ip, ttl)
+ results.append(dns.RRHeader(name, dns.A, dns.IN,
+ ttl, record, auth=True))
+ elif type == dns.SOA:
+ results.append(dns.RRHeader(domain, dns.SOA, dns.IN,
+ ttl, self.soa, auth=True))
+ elif other and type == dns.TXT:
+ record = dns.Record_TXT(action if action else '', ttl=ttl)
+ results.append(dns.RRHeader(name, dns.TXT, dns.IN,
+ ttl, record, auth=True))
+
+ if len(results) == 0:
+ authority = []
+ additional = []
+ return defer.succeed((results, authority, additional))