direct-io.hg

view tools/misc/netfix @ 7477:5a7baecb1c70

Fix an issue for passing arguement from control panel to deivce model
for some arguemnt like 'localtime', 'isa', device model need an argument
"-localtime", instead of "-localtime 1"
Signed-off-by: Xiaofeng Ling <xiaofeng.ling@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Sun Oct 23 16:51:47 2005 +0100 (2005-10-23)
parents 18eb059ae471
children
line source
1 #!/usr/bin/env python
2 # -*- mode: python; -*-
3 #============================================================================
4 # Copyright (C) 2004 Mike Wray <mike.wray@hp.com>
5 #============================================================================
6 # Move the IP address from eth0 onto the Xen bridge (xenbr0).
7 # Only works if the bridge control utils (brctl) have been installed.
8 #============================================================================
10 from getopt import getopt
12 # add fallback path for non-native python path installs if needed
13 sys.path.append('/usr/lib/python')
14 sys.path.append('/usr/lib64/python')
15 from xen.util.Brctl import *
17 short_options = 'hvqni:b:c'
18 long_options = ['help', 'verbose', 'quiet',
19 'interface=', 'bridge=', 'create']
21 defaults['interface'] = 'eth0'
22 defaults['bridge'] = 'xenbr0'
24 def usage():
25 print """Usage:
26 %s [options]
28 Reconfigure routing so that <bridge> has the IP address from
29 <interface>. This lets IP carry on working when <interface>
30 is attached to <bridge> for virtual networking.
31 Uses brctl to add <interface> to <bridge>,
32 so this can be run before any domains have been created.
33 """ % sys.argv[0]
34 print """
35 -i, --interface <interface> interface, default %(interface)s.
36 -b, --bridge <bridge> bridge, default %(bridge)s.
37 -c, --create create the bridge.
38 -v, --verbose Print commands.
39 -q, --quiet Don't print commands.
40 -n, --dry-run Don't execute commands.
41 -h, --help Print this help.
42 """ % defaults
43 sys.exit(1)
46 def main():
47 lopts = set_opts(Opts(defaults))
48 lopts.dryrun = 0
49 (options, args) = getopt(sys.argv[1:], short_options, long_options)
50 if args: usage()
51 for k, v in options:
52 if k in ['-h', '--help']:
53 usage()
54 elif k in ['-c', '--create']:
55 lopts.create = 1
56 elif k in ['-i', '--interface']:
57 lopts.interface = v
58 elif k in ['-b', '--bridge']:
59 lopts.bridge = v
60 elif k in ['-q', '--quiet']:
61 lopts.verbose = 0
62 elif k in ['-v', '--verbose']:
63 lopts.verbose = 1
64 elif k in ['-n', '--dry-run']:
65 lopts.dryrun = 1
66 reconfigure(lopts.interface, lopts.bridge)
68 if __name__ == '__main__':
69 main()