Commit 74c40222 authored by Olav Morken's avatar Olav Morken
Browse files

Merge branch 'remove-dns-updates' into 'master'

clean_stale: Stop updating DNS

See merge request !11
parents e4b5ab67 d12df02b
#!/usr/bin/env python
from __future__ import absolute_import, division, print_function, unicode_literals
import argparse
from nova_router import neighbors, security_groups, dns_rr, setupLogfile, etcd_connect
from nova_router import neighbors, security_groups, setupLogfile, etcd_connect
from scvmm_client import odata
import logging
import uuid
......@@ -15,7 +15,6 @@ import time
DESCRIPTION = """
Remove ip/mac bindings for VMs that no longer exists.
Also remove mac-addresses from security groups in etcd.
Also reset PTR-records in DNS.
"""
......@@ -48,7 +47,6 @@ def main():
conf.get('etcd', 'cacert'))
vmm_client = odata.VMMClient(conf.get('spf', 'vmm_baseurl'), conf.get('spf', 'username'),
conf.get('spf', 'password'))
dns = dns_rr.client_from_conf(conf)
nics = set()
for vm in vmm_client.query_collection("VirtualMachines"):
......@@ -65,30 +63,6 @@ def main():
if not mac in nics:
if not args.noop:
neighbors.remove_mac(etcd_client, mac)
for addrtype in (neighbors.V4, neighbors.V6_LL, neighbors.V6_PUB):
ipaddr = neighbors.get_ipaddress_from_mac(etcd_client, mac, addrtype)
if ipaddr is not None:
if not args.noop:
if addrtype == neighbors.V6_LL:
continue
dns.reset_ptr(ipaddr, addrtype != neighbors.V4)
else:
logging.info("Would have removed address {} from mac {}".format(ipaddr, mac))
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.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.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)
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