--- a/pvl/hosts/host.py Wed Feb 25 14:56:59 2015 +0200
+++ b/pvl/hosts/host.py Wed Feb 25 14:59:48 2015 +0200
@@ -152,7 +152,7 @@
alias4 - list (CNAME -> A)
alias6 - list (CNAME -> AAAA)
forward - None: generate forward zone A/AAAA records per ip/ip6
- False: omit A/AAAA records
+ False: omit A/AAAA records (and any alias= CNAMEs)
str: generate forward zone CNAME to given fqdn
reverse - None: generate reverse zone PTR records per ip/ip6
False: omit PTR records for ip/ip6
--- a/pvl/hosts/tests.py Wed Feb 25 14:56:59 2015 +0200
+++ b/pvl/hosts/tests.py Wed Feb 25 14:59:48 2015 +0200
@@ -155,7 +155,16 @@
('*.test', 'CNAME'): ['host'],
})
- # TODO: forward=... with alias=
+ def testHostForwardAlias(self):
+ h = host.Host.build('host', 'domain',
+ forward = 'host.example.net',
+ alias = 'test',
+ )
+
+ self.assertZoneEquals(zone.host_forward(h, 'domain'), {
+ ('host', 'CNAME'): ['host.example.net.'],
+ ('test', 'CNAME'): ['host'],
+ })
def testHostDelegateForward(self):
h = host.Host.build('host', 'example.com',
--- a/pvl/hosts/zone.py Wed Feb 25 14:56:59 2015 +0200
+++ b/pvl/hosts/zone.py Wed Feb 25 14:59:48 2015 +0200
@@ -54,18 +54,22 @@
log.info("%s: forward: %s", host, forward)
yield pvl.dns.ZoneRecord.CNAME(label, forward)
- return
+
+ elif host.forward is None:
+ # forward
+ if host.ip :
+ log.info("%s: forward %s[%s]: A %s", host, origin, label, host.ip)
- elif host.forward is not None:
+ yield pvl.dns.ZoneRecord.A(label, host.ip)
+
+ if host.ip6 :
+ log.info("%s: forward %s[%s]: AAAA %s", host, origin, label, host.ip6)
+
+ yield pvl.dns.ZoneRecord.AAAA(label, host.ip6)
+
+ else:
log.info("%s: skip forward", host)
return
-
- # forward
- if host.ip :
- yield pvl.dns.ZoneRecord.A(label, host.ip)
-
- if host.ip6 :
- yield pvl.dns.ZoneRecord.AAAA(label, host.ip6)
if host.location:
location_alias, location_domain = host.location