scripts/kvm-ifup
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 add_iface_to_bridge():
    iface = sys.argv[1]
    bridge = "kvm_bridge_%s" % iface
    if bridge in os.environ:
        bridge = os.environ[bridge]
        cmd = ["brctl", "addif", bridge, iface]
        call(cmd)
    iface_up = ["ip", "link", "set", iface, "up"]
    call(iface_up)

add_iface_to_bridge()