예제 #1
0
 def test_lookupText(self):
     """
     See L{test_lookupAddress}
     """
     d = client.lookupText(self.hostname)
     d.addCallback(self.checkResult, dns.TXT)
     return d
예제 #2
0
 def test_lookupText(self):
     """
     See L{test_lookupAddress}
     """
     d = client.lookupText(self.hostname)
     d.addCallback(self.checkResult, dns.TXT)
     return d
예제 #3
0
파일: tap.py 프로젝트: warner/flancer
 def test_zone(self, zone_name):
     print("testing new zone %s" % zone_name)
     hostname = "_flancer_test.%s" % zone_name
     txtname = "_flancer_txtname"
     fullname = "%s.%s" % (txtname, hostname)
     test_data = "flancer_txt"
     self.add_txt(hostname, txtname, test_data)
     try:
         res = yield dns_client.lookupText(fullname)
     except DNSNameError as e:
         print("failure to test zone: is there an NS record pointing to us?")
         print(e)
         self.delete_txt(hostname, txtname)
         raise ValueError("failure to test zone: DNS error. Is there an NS record pointing to us?")
     #print("result", res)
     (answer, authority, additional) = res
     for r in answer:
         #print("R", r, dir(r))
         if r.type == dns.TXT:
             #print("TXT", r.payload.data[0])
             if r.payload.data[0] == test_data:
                 print("success")
                 self.delete_txt(hostname, txtname)
                 returnValue(True)
     print("failure to test zone: is there an NS record pointing to us?")
     self.delete_txt(hostname, txtname)
     raise ValueError("failure to test zone: is there an NS record pointing to us?")
예제 #4
0
파일: model.py 프로젝트: thimbl/Mammatus
def getConfiguration(uri):
    def gotFailure(failure):
        raise Exception("lookup for " + str(failure.value.message.queries[0].name) + " failed")
    def getZone(uri):
        domainlevels = uri.split(".")
        levelcount = len(domainlevels)
        # if the request is comming from an not fully qualied
        # domain name, i.e "localhost", use our own.
        if levelcount < 2:
            domainlevels = socket.getfqdn().split(".")
            levelcount = len(domainlevels)
        registeredDomain = domainlevels[levelcount-2:levelcount]
        subdomain = [domainlevels[:levelcount-2].pop(), "_mammatus"]
        mammatus_key = ".".join(subdomain) 
        root_zone = ".".join(registeredDomain)
        return (mammatus_key, root_zone)
    def getService(failure):
        service_fqdn = ".".join(("_mammatus._tcp", root_zone))
        d = client.lookupService(service_fqdn) 
        def gotSrvRecord(result):
            (answer, authority, additional) = result
            serviceUri = str(answer[0].payload.target)
            d = client.lookupText(".".join(getZone(serviceUri)))
            d.addCallbacks(getConfigFromText, gotFailure)
            return d
        d.addCallbacks(gotSrvRecord, gotFailure)
        return d
    def getConfigFromText(result):
        (answer, authority, additional) = result
        config = MammatusConfiguration()
        if answer:
            for a in answer:
                if hasattr(a.payload,'data'):
                    for d in a.payload.data:
                        config.parseText(d)
        return config
    (mammatus_key, root_zone) = getZone(uri)
    d = client.lookupText(".".join((mammatus_key, root_zone)))
    d.addCallbacks(getConfigFromText, getService)
    return d 
예제 #5
0
파일: model.py 프로젝트: thimbl/Mammatus
 def gotSrvRecord(result):
     (answer, authority, additional) = result
     serviceUri = str(answer[0].payload.target)
     d = client.lookupText(".".join(getZone(serviceUri)))
     d.addCallbacks(getConfigFromText, gotFailure)
     return d