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
0
d05fbfd9a5cf build repository new
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
     1
#!/usr/bin/env python
d05fbfd9a5cf build repository new
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
     2
d05fbfd9a5cf build repository new
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
     3
import sys
d05fbfd9a5cf build repository new
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
     4
import os
d05fbfd9a5cf build repository new
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
     5
from subprocess import call
d05fbfd9a5cf build repository new
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
     6
d05fbfd9a5cf build repository new
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
     7
def add_iface_to_bridge():
55
1d4c061d1502 update and fixes for new structur
Jens Kasten <jens@kasten-edv.de>
parents: 0
diff changeset
     8
    iface = sys.argv[1]
1d4c061d1502 update and fixes for new structur
Jens Kasten <jens@kasten-edv.de>
parents: 0
diff changeset
     9
    bridge = "kvm_bridge_%s" % iface
1d4c061d1502 update and fixes for new structur
Jens Kasten <jens@kasten-edv.de>
parents: 0
diff changeset
    10
    if bridge in os.environ:
1d4c061d1502 update and fixes for new structur
Jens Kasten <jens@kasten-edv.de>
parents: 0
diff changeset
    11
        bridge = os.environ[bridge]
0
d05fbfd9a5cf build repository new
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    12
        cmd = ["brctl", "addif", bridge, iface]
d05fbfd9a5cf build repository new
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    13
        call(cmd)
55
1d4c061d1502 update and fixes for new structur
Jens Kasten <jens@kasten-edv.de>
parents: 0
diff changeset
    14
    iface_up = ["ip", "link", "set", iface, "up"]
1d4c061d1502 update and fixes for new structur
Jens Kasten <jens@kasten-edv.de>
parents: 0
diff changeset
    15
    call(iface_up)
0
d05fbfd9a5cf build repository new
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    16
d05fbfd9a5cf build repository new
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    17
add_iface_to_bridge()