--- a/pvl/hosts/host.py Wed Feb 25 14:59:48 2015 +0200
+++ b/pvl/hosts/host.py Wed Feb 25 15:06:28 2015 +0200
@@ -146,11 +146,11 @@
ip - ipaddr.IPv4Address
ip6 - ipaddr.IPv6Address
ethernet - { index: ethernet }
- alias - list
+ alias - [ str ]: generate CNAMEs for given relative names
owner - str: LDAP uid
location - location (name, domain) or None
- alias4 - list (CNAME -> A)
- alias6 - list (CNAME -> AAAA)
+ alias4 - [ str ]: generate additional A records for given relative names
+ alias6 - [ str ]: generate additional AAAA records for given relative names
forward - None: generate forward zone A/AAAA records per ip/ip6
False: omit A/AAAA records (and any alias= CNAMEs)
str: generate forward zone CNAME to given fqdn
--- a/pvl/hosts/tests.py Wed Feb 25 14:59:48 2015 +0200
+++ b/pvl/hosts/tests.py Wed Feb 25 15:06:28 2015 +0200
@@ -155,6 +155,41 @@
('*.test', 'CNAME'): ['host'],
})
+ def testHostAlias46(self):
+ h = host.Host.build('host', 'domain',
+ ip = '192.0.2.1',
+ ip6 = '2001:db8::192.0.2.1',
+ alias4 = 'test4',
+ alias6 = 'test6',
+ )
+
+ self.assertZoneEquals(zone.host_forward(h, 'domain'), {
+ ('host', 'A'): ['192.0.2.1'],
+ ('host', 'AAAA'): ['2001:db8::c000:201'],
+ ('test4', 'A'): ['192.0.2.1'],
+ ('test6', 'AAAA'): ['2001:db8::c000:201'],
+ })
+
+ def testHostAlias4Missing(self):
+ h = host.Host.build('host', 'domain',
+ ip6 = '2001:db8::192.0.2.1',
+ alias4 = 'test4',
+ alias6 = 'test6',
+ )
+
+ with self.assertRaises(zone.HostZoneError):
+ self.assertZoneEquals(zone.host_forward(h, 'domain'), { })
+
+ def testHostAlias6Missing(self):
+ h = host.Host.build('host', 'domain',
+ ip = '192.0.2.1',
+ alias4 = 'test4',
+ alias6 = 'test6',
+ )
+
+ with self.assertRaises(zone.HostZoneError):
+ self.assertZoneEquals(zone.host_forward(h, 'domain'), { })
+
def testHostForwardAlias(self):
h = host.Host.build('host', 'domain',
forward = 'host.example.net',
--- a/pvl/hosts/zone.py Wed Feb 25 14:59:48 2015 +0200
+++ b/pvl/hosts/zone.py Wed Feb 25 15:06:28 2015 +0200
@@ -83,10 +83,16 @@
yield pvl.dns.ZoneRecord.CNAME(resolve(origin, host.domain, alias), label)
for alias in host.alias4:
+ if not host.ip:
+ raise HostZoneError(host, "alias4={host.alias4} without ip=".format(host=host))
+
yield pvl.dns.ZoneRecord.A(resolve(origin, host.domain, alias), host.ip)
for alias in host.alias6:
- yield pvl.dns.ZoneRecord.AAAA(resolve(origin, host.domain, alias), host.ip6)
+ if not host.ip6:
+ raise HostZoneError(host, "alias6={host.alias6} without ip6=".format(host=host))
+
+ yield pvl.dns.ZoneRecord.AAAA(resolve(origin, host.domain, alias), host.ip6)
def host_reverse (host, prefix) :
"""