aboutsummaryrefslogtreecommitdiffstats
path: root/tools/python/xen/xend/Vifctl.py
blob: 49df8f6bd06ca459c7bfc11adc4534839b079153 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
import os.path
import sys

VIFCTL = '/etc/xen/xend/vifctl'

def init():
    os.system(VIFCTL + ' init ')

def up(vif, mac=None, bridge=None, ipaddr=[]):
    args = ['vif=%s' % vif]
    if mac:
        args.append('mac=%s' % mac)
    if bridge:
        args.append('bridge=%s' % bridge)
    if ipaddr:
        args.append('ipaddr=%s' % ','.join(ipaddr))
    os.system(VIFCTL + ' up ' + ' '.join(args))

def down(vif, mac=None, bridge=None, ipaddr=[]):
    args = ['vif=%s' % vif]
    if mac:
        args.append('mac=%s' % mac)
    if bridge:
        args.append('bridge=%s' % bridge)
    if ipaddr:
        args.append('ipaddr=%s' % ','.join(ipaddr))
    os.system(VIFCTL + ' down ' + ' '.join(args))