--- a/pvl/hosts/tests.py Wed Feb 25 15:12:55 2015 +0200
+++ b/pvl/hosts/tests.py Wed Feb 25 15:24:49 2015 +0200
@@ -224,6 +224,37 @@
('host', 'A'): ['192.0.2.1'],
('test', 'CNAME'): ['host'],
})
+
+ def testHostLocationDomain(self):
+ h = host.Host.build('host', 'foo.domain',
+ ip = '192.0.2.1',
+ location = 'test@bar.domain',
+ )
+
+ self.assertEquals(h.location, ('test', 'bar.domain'))
+
+ self.assertZoneEquals(zone.host_forward(h, 'domain'), {
+ ('host.foo', 'A'): ['192.0.2.1'],
+ ('test.bar', 'CNAME'): ['host.foo'],
+ })
+
+ def testHostLocationDomainOutOfOrigin(self):
+ h = host.Host.build('host', 'foo.domain',
+ ip = '192.0.2.1',
+ location = 'test@bar.domain',
+ )
+
+ self.assertEquals(h.location, ('test', 'bar.domain'))
+
+ with self.assertRaises(zone.HostZoneError):
+ self.assertZoneEquals(zone.host_forward(h, 'foo.domain'), {
+ ('host', 'A'): ['192.0.2.1'],
+ })
+
+ # TODO
+ #self.assertZoneEquals(zone.host_forward(h, 'bar.domain'), {
+ # ('test', 'CNAME'): ['host.foo'],
+ #})
class TestReverseZone(TestZoneMixin, unittest.TestCase):
def setUp(self):
--- a/pvl/hosts/zone.py Wed Feb 25 15:12:55 2015 +0200
+++ b/pvl/hosts/zone.py Wed Feb 25 15:24:49 2015 +0200
@@ -37,6 +37,7 @@
else:
raise HostZoneError("{name}: fqdn {fqdn} out of zone {origin}".format(name=name, fqdn=fqdn, origin=origin))
+# TODO: generate location alias CNAMEs even if host itself is outside origin?
def host_forward (host, origin) :
"""
Yield ZoneRecords for hosts within the given zone origin
@@ -73,7 +74,7 @@
if host.location:
location_alias, location_domain = host.location
-
+
yield pvl.dns.ZoneRecord.CNAME(resolve(origin, location_domain, location_alias), label)
for alias in host.alias: