# HG changeset patch # User Tero Marttila # Date 1424869975 -7200 # Node ID ac334a55eebcf20fbd72c66f611d92b1d206bc42 # Parent cd1f1b51f3a0ebe0b987def32661f1f79da572e2 pvl.hosts: fix location= and test forward records diff -r cd1f1b51f3a0 -r ac334a55eebc pvl/hosts/host.py --- a/pvl/hosts/host.py Wed Feb 25 15:09:51 2015 +0200 +++ b/pvl/hosts/host.py Wed Feb 25 15:12:55 2015 +0200 @@ -39,12 +39,12 @@ else: return () -def parse_location(value, domain): +def parse_location(location, domain): """ Parse location@domain. """ - if not value: + if not location: return None if '@' in location: @@ -148,7 +148,7 @@ ethernet - { index: ethernet } alias - [ str ]: generate CNAMEs for given relative names owner - str: LDAP uid - location - location (name, domain) or None + location - None or (name, domain) 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 diff -r cd1f1b51f3a0 -r ac334a55eebc pvl/hosts/tests.py --- a/pvl/hosts/tests.py Wed Feb 25 15:09:51 2015 +0200 +++ b/pvl/hosts/tests.py Wed Feb 25 15:12:55 2015 +0200 @@ -212,6 +212,19 @@ ('test', 'CNAME'): ['host'], }) + def testHostLocation(self): + h = host.Host.build('host', 'domain', + ip = '192.0.2.1', + location = 'test', + ) + + self.assertEquals(h.location, ('test', 'domain')) + + self.assertZoneEquals(zone.host_forward(h, 'domain'), { + ('host', 'A'): ['192.0.2.1'], + ('test', 'CNAME'): ['host'], + }) + class TestReverseZone(TestZoneMixin, unittest.TestCase): def setUp(self): self.options = Options() diff -r cd1f1b51f3a0 -r ac334a55eebc pvl/hosts/zone.py --- a/pvl/hosts/zone.py Wed Feb 25 15:09:51 2015 +0200 +++ b/pvl/hosts/zone.py Wed Feb 25 15:12:55 2015 +0200 @@ -74,9 +74,6 @@ if host.location: location_alias, location_domain = host.location - if not location_domain: - location_domain = host.domain - yield pvl.dns.ZoneRecord.CNAME(resolve(origin, location_domain, location_alias), label) for alias in host.alias: