scripts/kvm-ifdown
author Jens Kasten <jens@kasten-edv.de>
Mon, 19 Mar 2012 04:19:05 +0100
changeset 87 228ce8fbd4ff
parent 55 1d4c061d1502
permissions -rw-r--r--
update readme
#!/usr/bin/env python

import sys
import os
from subprocess import call

def del_iface_from_bridge():
    iface = sys.argv[1]
    bridge = "kvm_bridge_%s" % iface
    if bridge in os.environ:
        bridge = os.environ[bridge]
        cmd = ["brctl", "delif", bridge, iface] 
        call(cmd)
    # bring down interface
    iface_down = ["ip", "link", "set", iface , "down"]
    call(iface_down)
    # remove tun-tap device
    del_iface_from_tun = ["tunctl", "-d", iface]

del_iface_from_bridge()