Ignore:
Timestamp:
May 7, 2008, 7:21:10 PM (17 years ago)
Author:
ecprice
Message:

Support xvm.mit.edu as well.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-dns/code/dnsserver.py

    r312 r505  
    1717    soa = None
    1818
    19     def __init__(self, domain, database=None):
     19    def __init__(self, domains, database=None):
    2020        common.ResolverBase.__init__(self)
    2121        if database is not None:
    2222            sipb_xen_database.connect(database)
    23         self.domain = domain
     23        self.domains = domains
    2424        self.soa = dns.Record_SOA(mname='sipb-xen-dev.mit.edu',
    2525                                  rname='sipb-xen.mit.edu',
     
    4141    def _lookup_unsafe(self, name, cls, type, timeout):
    4242        sipb_xen_database.clear_cache()
    43         if not (name.lower() == self.domain or
    44                 name.lower().endswith('.'+self.domain)):
    45             #Not us
    46             return defer.fail(failure.Failure(dns.DomainError(name)))
     43        if name.lower() in self.domains:
     44            domain = name.lower()
     45        else:
     46            found = False
     47            for domain in self.domains:
     48                if name.lower().endswith('.'+domain):
     49                    found = True
     50                    break
     51            if not found:
     52                #Not us
     53                return defer.fail(failure.Failure(dns.DomainError(name)))
    4754        results = []
    4855        if cls == dns.IN and type in (dns.A, dns.ALL_RECORDS):
    49             host = name[:-len(self.domain)-1]
     56            host = name[:-len(domain)-1]
    5057            value = sipb_xen_database.Machine.get_by(name=host)
    5158            if value is None or not value.nics:
     
    5966                                        ttl, record, auth=True))
    6067        authority = []
    61         authority.append(dns.RRHeader(self.domain, dns.SOA, dns.IN, 3600,
     68        authority.append(dns.RRHeader(domain, dns.SOA, dns.IN, 3600,
    6269                                      self.soa, auth=True))
    6370        return defer.succeed((results, authority, []))
     
    6673
    6774if '__main__' == __name__:
    68     resolver = DatabaseAuthority('servers.csail.mit.edu',
     75    resolver = DatabaseAuthority(['servers.csail.mit.edu',
     76                                  'xvm.mit.edu'],
    6977                                 'postgres://sipb-xen@sipb-xen-dev/sipb_xen')
    7078
Note: See TracChangeset for help on using the changeset viewer.