no generation if no ptr record

This commit is contained in:
Charlie Jacomme 2018-08-07 10:04:39 +02:00
parent a0b93b94e0
commit fee0f35f45

View file

@ -148,7 +148,7 @@ def write_dns_files(api_client):
aaaa_records=aaaa_records, aaaa_records=aaaa_records,
cname_records=cname_records) cname_records=cname_records)
filename = 'dns.{zone}.zone'.format(zone=zone_name) filename = 'generated/dns.{zone}.zone'.format(zone=zone_name)
with open(filename, 'w+') as f: with open(filename, 'w+') as f:
f.write(zone_file_content) f.write(zone_file_content)
@ -198,6 +198,7 @@ def write_dns_reverse_file(api_client):
# For the ipv4, we need to agregate the subnets together, because # For the ipv4, we need to agregate the subnets together, because
# we can only have reverse for /24, /16 and /8. # we can only have reverse for /24, /16 and /8.
if zone['ptr_records']:
subnets = [] subnets = []
for net in zone['cidrs']: for net in zone['cidrs']:
net = netaddr.IPNetwork(net) net = netaddr.IPNetwork(net)
@ -247,6 +248,7 @@ def write_dns_reverse_file(api_client):
### Continue with the ipv6 reverse ### Continue with the ipv6 reverse
if zone['ptr_v6_records']:
net = netaddr.IPNetwork(zone['prefix_v6']+"/"+str(zone['prefix_v6_length'])) net = netaddr.IPNetwork(zone['prefix_v6']+"/"+str(zone['prefix_v6_length']))
net_class = max(((net.prefixlen - 1) // 4) + 1, 1) net_class = max(((net.prefixlen - 1) // 4) + 1, 1)
zone6_name = ".".join( zone6_name = ".".join(
@ -296,10 +298,10 @@ api_client = Re2oAPIClient(api_hostname, api_username, api_password)
client_hostname = socket.gethostname().split('.', 1)[0] client_hostname = socket.gethostname().split('.', 1)[0]
for service in api_client.list("services/regen/"): #for service in api_client.list("services/regen/"):
# if service['hostname'] == client_hostname and \ # if service['hostname'] == client_hostname and \
# service['service_name'] == 'dns' and \ # service['service_name'] == 'dns' and \
# service['need_regen']: # service['need_regen']:
#write_dns_files(api_client) write_dns_files(api_client)
write_dns_reverse_file(api_client) write_dns_reverse_file(api_client)
# api_client.patch(service['api_url'], data={'need_regen': False}) # api_client.patch(service['api_url'], data={'need_regen': False})