Commit c6d8dc3c authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Allow fully qualified hostname aliases

parent 27479691
......@@ -31,7 +31,7 @@ def generate(tree, options):
pass
#
# C. Create reverse mapping for localhost
# C. Create reverse mapping for host
#
result = []
......@@ -141,7 +141,7 @@ class DomainDict:
def add_host(self, name, kind, value):
if not re.match('^[0-9a-zA-Z.-]+$', name):
raise Exception('Invalid nameserver name "%s"' % name)
raise Exception('Invalid host name "%s"' % name)
if not name in self.host:
self.host[name] = set()
pass
......@@ -203,17 +203,28 @@ def generate_forward(tree, hosts):
result[c.domain[1]].add_host(c.alias[0], 'CNAME', c.name[0])
pass
# Add numbered hosts
def add_host(domain, name, address):
if address.version == 4:
result[domain].add_host(name, 'A', str(address.exploded))
pass
elif address.version == 6:
result[domain].add_host(name, 'AAAA', str(address.exploded))
pass
for domain,net in [ (s.domain[0],util.network(s))
for s in tree._subnet_
if s.domain[0] and util.network(s)]:
for name,address in hosts:
try:
if name.endswith('.'):
d = '.'.join(name.split('.')[1:-1])
n = name.split('.')[0]
add_host(d, n, address)
continue
except Exception,e:
pass
if address in net:
if address.version == 4:
result[domain].add_host(name, 'A', str(address.exploded))
pass
elif address.version == 6:
result[domain].add_host(name, 'AAAA', str(address.exploded))
pass
add_host(domain, name,address)
pass
pass
pass
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment