Commit 2cc68758 authored by Sigmund Augdal's avatar Sigmund Augdal

Made the dns_rr module object oriented so common info regarding the connection...

Made the dns_rr module object oriented so common info regarding the connection to powerrest can be kept in one location
parent df5cc635
......@@ -48,6 +48,7 @@ def main():
vmm_client = odata.VMMClient(conf.get('spf', 'vmm_baseurl'), conf.get('spf', 'username'),
conf.get('spf', 'password'))
pdns_url = conf.get('pdns', 'url')
dns = dns_rr.PowerRESTClient(pdns_url)
nics = set()
for nic in vmm_client.query_collection("VirtualNetworkAdapters"):
......@@ -75,13 +76,13 @@ def main():
continue
if addrtype == neighbors.V6_PUB:
logging.info("Would have cleaned DNS PTR records for address {}".format(ipaddr))
ptr_record = dns_rr.get_ptr_record(pdns_url, ipaddr, addrtype != neighbors.V4)
ptr_record = dns.get_ptr_record(ipaddr, addrtype != neighbors.V4)
if ptr_record:
logging.info("Would have cleaned record: {}".format(ptr_record))
else:
# Remove DNS PTR record
logging.info("Resetting DNS PTR record for address {}".format(ipaddr))
ptr_record = dns_rr.get_ptr_record(pdns_url, ipaddr, addrtype != neighbors.V4)
ptr_record = dns.get_ptr_record(ipaddr, addrtype != neighbors.V4)
logging.info("Would have updates record: {}".format(ptr_record))
if ptr_record:
ptr_record['content'] = dns_rr.generate_ptr(ipaddr)
......
This diff is collapsed.
......@@ -26,7 +26,7 @@ def main(args):
return
record = dict(name=args.record, type=args.type, content=args.content, domain_id=domain_id,
ttl=int(args.ttl))
if not dns_rr.create_record(args.url, record):
if not dns_rr.PowerRESTClient(args.url).create_record(record):
print("Failed to create record")
print("Created record in domain id {}".format(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