Changeset 851 for trunk/packages/sipb-xen-dns/code
- Timestamp:
- Aug 3, 2008, 9:35:24 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-dns/code/dnsserver.py
r849 r851 7 7 from twisted.python import failure 8 8 9 import sipb_xen_database 9 from invirt.config import structs as config 10 import invirt.database 10 11 import psycopg2 11 12 import sqlalchemy … … 17 18 soa = None 18 19 19 def __init__(self, domains , database=None):20 def __init__(self, domains=None, database=None): 20 21 common.ResolverBase.__init__(self) 21 22 if database is not None: 22 sipb_xen_database.connect(database) 23 self.domains = domains 24 self.soa = dns.Record_SOA(mname='ns1.xvm.mit.edu', 25 rname='xvm.mit.edu', 23 invirt.database.connect(database) 24 else: 25 invirt.database.connect() 26 if domains is not None: 27 self.domains = domains 28 else: 29 self.domains = config.dns.domains 30 ns = config.dns.nameservers[0] 31 self.soa = dns.Record_SOA(mname=ns.hostname, 32 rname=config.dns.contact.replace('@','.',1), 26 33 serial=1, refresh=3600, retry=900, 27 34 expire=3600000, minimum=21600, ttl=3600) 28 self.ns = dns.Record_NS(name= 'ns1.xvm.mit.edu', ttl=3600)29 record = dns.Record_A(address= '18.181.0.62', ttl=3600)30 self.ns1 = dns.RRHeader( 'ns1.xvm.mit.edu', dns.A, dns.IN,35 self.ns = dns.Record_NS(name=ns.hostname, ttl=3600) 36 record = dns.Record_A(address=ns.ip, ttl=3600) 37 self.ns1 = dns.RRHeader(ns.hostname, dns.A, dns.IN, 31 38 3600, record, auth=True) 32 39 … … 46 53 47 54 def _lookup_unsafe(self, name, cls, type, timeout): 48 sipb_xen_database.clear_cache()55 invirt.database.clear_cache() 49 56 50 57 ttl = 900 … … 68 75 if not host: 69 76 if type in (dns.A, dns.ALL_RECORDS): 70 record = dns.Record_A( '18.181.0.62', ttl)77 record = dns.Record_A(config.dns.nameservers[0].ip, ttl) 71 78 results.append(dns.RRHeader(name, dns.A, dns.IN, 72 79 ttl, record, auth=True)) … … 80 87 else: 81 88 if host: 82 value = sipb_xen_database.Machine.get_by(name=host)89 value = invirt.database.Machine.get_by(name=host) 83 90 if value is None or not value.nics: 84 91 return defer.fail(failure.Failure(dns.AuthoritativeDomainError(name))) … … 102 109 103 110 if '__main__' == __name__: 104 resolver = DatabaseAuthority(['servers.csail.mit.edu', 105 'xvm.mit.edu'], 106 'postgres://sipb-xen@sipb-xen-dev/sipb_xen') 111 resolver = DatabaseAuthority() 107 112 108 113 verbosity = 0
Note: See TracChangeset
for help on using the changeset viewer.