abs path for gen files
This commit is contained in:
parent
a950989980
commit
b4e10b36f0
1 changed files with 13 additions and 7 deletions
20
main.py
20
main.py
|
@ -7,6 +7,11 @@ import netaddr
|
||||||
from re2oapi import Re2oAPIClient
|
from re2oapi import Re2oAPIClient
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
path =(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
config = ConfigParser()
|
config = ConfigParser()
|
||||||
config.read('config.ini')
|
config.read('config.ini')
|
||||||
|
@ -68,9 +73,6 @@ template_reverse = ("$TTL 2D\n"
|
||||||
"{ptr_records}\n")
|
"{ptr_records}\n")
|
||||||
|
|
||||||
|
|
||||||
for arg in sys.argv:
|
|
||||||
if arg=="--force":
|
|
||||||
write_dns_files(api_client)
|
|
||||||
|
|
||||||
def write_dns_files(api_client):
|
def write_dns_files(api_client):
|
||||||
for zone in api_client.list("dns/zones"):
|
for zone in api_client.list("dns/zones"):
|
||||||
|
@ -174,7 +176,7 @@ def write_dns_files(api_client):
|
||||||
aaaa_records=aaaa_records,
|
aaaa_records=aaaa_records,
|
||||||
cname_records=cname_records)
|
cname_records=cname_records)
|
||||||
|
|
||||||
filename = 'generated/dns.{zone}.zone'.format(zone=zone_name)
|
filename = path+'/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)
|
||||||
|
|
||||||
|
@ -272,7 +274,7 @@ def write_dns_reverse_file(api_client):
|
||||||
mx_records=mx_records,
|
mx_records=mx_records,
|
||||||
ptr_records = ptr_records)
|
ptr_records = ptr_records)
|
||||||
|
|
||||||
filename = 'generated/dns.{zone}.zone'.format(zone=zone_name)
|
filename = path+'/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)
|
||||||
|
|
||||||
|
@ -309,7 +311,7 @@ def write_dns_reverse_file(api_client):
|
||||||
ptr_records = ptr_records)
|
ptr_records = ptr_records)
|
||||||
|
|
||||||
|
|
||||||
filename = 'generated/dns.{zone}.zone'.format(zone=zone6_name)
|
filename = path+'/generated/dns.{zone}.zone'.format(zone=zone6_name)
|
||||||
with open(filename, 'a') as f:
|
with open(filename, 'a') as f:
|
||||||
f.write(zone_file_content)
|
f.write(zone_file_content)
|
||||||
else:
|
else:
|
||||||
|
@ -320,7 +322,7 @@ def write_dns_reverse_file(api_client):
|
||||||
ptr_records = ptr_records)
|
ptr_records = ptr_records)
|
||||||
|
|
||||||
|
|
||||||
filename = 'generated/dns.{zone}.zone'.format(zone=zone6_name)
|
filename = path+'/generated/dns.{zone}.zone'.format(zone=zone6_name)
|
||||||
with open(filename, 'w+') as f:
|
with open(filename, 'w+') as f:
|
||||||
f.write(zone_file_content)
|
f.write(zone_file_content)
|
||||||
zone_v6.append(zone6_name)
|
zone_v6.append(zone6_name)
|
||||||
|
@ -329,6 +331,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 arg in sys.argv:
|
||||||
|
if arg=="--force":
|
||||||
|
write_dns_files(api_client)
|
||||||
|
|
||||||
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 \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue