Commit ed1f8dc8 authored by Morten Knutsen's avatar Morten Knutsen

Handle different addresstypes differently when cleaning dns

parent f4064583
......@@ -63,15 +63,34 @@ def main():
# Remove ip/mac binding
logging.info("Removing address {} from mac {}".format(ipaddr, mac))
neighbors.remove_pair(etcd_client, mac, ipaddr, addrtype)
# Remove DNS PTR record
logging.info("Cleaning DNS PTR record for address {}".format(ipaddr))
ptr_record = dns_rr.get_ptr_record(pdns_url, ipaddr, addrtype != neighbors.V4)
dns_rr.remove_record(pdns_url, ptr_record['id'])
if addrtype == neighbors.V6_LL:
continue
if addrtype == neighbors.V6_PUB:
# Remove DNS PTR record
logging.info("Cleaning DNS PTR record for address {}".format(ipaddr))
ptr_record = dns_rr.get_ptr_record(pdns_url, ipaddr, addrtype != neighbors.V4)
dns_rr.remove_record(pdns_url, ptr_record['id'])
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['content'] = dns_rr.generate_ptr(ipaddr)
dns_rr.update_record(pdns_url, ptr_record)
else:
logging.info("Would have removed address {} from mac {}".format(ipaddr, mac))
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)
logging.info("Would have clean record: {}".format(ptr_record))
if addrtype == neighbors.V6_LL:
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)
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)
logging.info("Would have updates record: {}".format(ptr_record))
ptr_record['content'] = dns_rr.generate_ptr(ipaddr)
logging.info("New name: {}".format(ptr_record['content']))
else:
logging.debug("found owner for mac {}".format(mac))
......
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