Commit 97090cd9 authored by Sigmund Augdal's avatar Sigmund Augdal

Added script to remove entries for deleted VMs from mac/address binding table in etcd

parent 8fb38e5d
import etcd
from nova_router import neighbors
from scvmm_client import odata
import logging
def main():
key = "/home/sigmunda/Devel/nova/etcd_client.key"
cert = "/home/sigmunda/Devel/nova/etcd_client.crt"
cacert = "/home/sigmunda/Devel/nova/etcd_ca.crt"
vmm_baseurl = ''
username = 'bs-unsi\spfsvc'
password = 'Laste8il'
etcd_client = etcd.Etcd("", ssl_key=key, ssl_cert=cert, verify=cacert)
vmm_client = odata.VMMClient(vmm_baseurl, username, password)
nics = set()
for nic in vmm_client.query_collection("VirtualNetworkAdapters"):
mac =["MACAddress"]
if mac is not None:
for entry in etcd_client.list("/nova/iaas/instances"):
if not entry.dir:
mac = entry.key.split("/")[-1].lower()
if not mac in nics:
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:"Removing address {} from mac {}".format(ipaddr, mac))
neighbors.remove_pair(etcd_client, mac, ipaddr, addrtype)
logging.debug("found owner for mac {}".format(mac))
if __name__ == '__main__':
......@@ -10,6 +10,7 @@ requires = [
......@@ -26,5 +27,6 @@ setup(name='router-services',
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