ia64/xen-unstable

view tools/misc/netfix @ 1820:3d4f8eb89670

bitkeeper revision 1.1106.1.2 (40faa780dekT3E5arFwcbQDu1MbX6g)

Cleaned up Xen's instruction emulator.
author kaf24@scramble.cl.cam.ac.uk
date Sun Jul 18 16:38:24 2004 +0000 (2004-07-18)
parents e04e40b4615f
children 4bf285a87365 eb0280fe0abf 0a4b76b6b5a0
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 (xen-br0).
7 # Only works if the bridge control utils (brctl) have been installed.
8 #============================================================================
10 from getopt import getopt
11 from xen.util.Brctl import *
13 short_options = 'hvqni:b:c'
14 long_options = ['help', 'verbose', 'quiet',
15 'interface=', 'bridge=', 'create']
17 defaults['interface'] = 'eth0'
18 defaults['bridge'] = 'xen-br0'
20 def usage():
21 print """Usage:
22 %s [options]
24 Reconfigure routing so that <bridge> has the IP address from
25 <interface>. This lets IP carry on working when <interface>
26 is attached to <bridge> for virtual networking.
27 Uses brctl to add <interface> to <bridge>,
28 so this can be run before any domains have been created.
29 """ % sys.argv[0]
30 print """
31 -i, --interface <interface> interface, default %(interface)s.
32 -b, --bridge <bridge> bridge, default %(bridge)s.
33 -c, --create create the bridge.
34 -v, --verbose Print commands.
35 -q, --quiet Don't print commands.
36 -n, --dry-run Don't execute commands.
37 -h, --help Print this help.
38 """ % defaults
39 sys.exit(1)
42 def main():
43 lopts = set_opts(Opts(defaults))
44 lopts.dryrun = 0
45 (options, args) = getopt(sys.argv[1:], short_options, long_options)
46 if args: usage()
47 for k, v in options:
48 if k in ['-h', '--help']:
49 usage()
50 elif k in ['-c', '--create']:
51 lopts.create = 1
52 elif k in ['-i', '--interface']:
53 lopts.interface = v
54 elif k in ['-b', '--bridge']:
55 lopts.bridge = v
56 elif k in ['-q', '--quiet']:
57 lopts.verbose = 0
58 elif k in ['-v', '--verbose']:
59 lopts.verbose = 1
60 elif k in ['-n', '--dry-run']:
61 lopts.dryrun = 1
62 reconfigure(lopts.interface, lopts.bridge)
64 if __name__ == '__main__':
65 main()