Commit 3ddba1e9 authored by Morten Knutsen's avatar Morten Knutsen

Find reverse IPv4 zone in a more general fashion, allowing updates in more than one zone.

parent 0da8662c
......@@ -169,13 +169,14 @@ class PowerRESTClient(object):
ptr_record['content'] = generate_ptr(ipaddress)
self.update_record(ptr_record)
def get_reverse_domain_id(self, v6):
def get_reverse_domain_id(self, v6, record):
if v6:
domain_id = self.get_domain_id("4.5.4.0.0.0.0.0.0.7.0.1.0.0.2.ip6.arpa")
if domain_id:
return domain_id
else:
domain_id = self.get_domain_id("213.38.158.in-addr.arpa")
zone = '.'.join(record.split('.')[1:])
domain_id = self.get_domain_id("{}".format(zone))
if domain_id:
return domain_id
......@@ -186,11 +187,13 @@ class PowerRESTClient(object):
raise RuntimeError("Missing address when trying to create reverse")
rec = self.get_ptr_record(address, ipv6)
if not rec: # Create
domain_id = self.get_reverse_domain_id(ipv6)
if ipv6:
reverse_record = reverse_dns6(address)
else:
reverse_record = reverse_dns(address)
domain_id = self.get_reverse_domain_id(ipv6, reverse_record)
data = {'content': ptr,
'name': reverse_record,
'domain_id': domain_id,
......
Markdown is supported
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