ia64/xen-unstable

view tools/misc/xend @ 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 0a953bcc44bb
children 1908bce36fa8 dae98734f12e
line source
1 #!/usr/bin/env python
2 # -*- mode: python; -*-
3 #============================================================================
4 # Copyright (C) 2004 Mike Wray <mike.wray@hp.com>
5 #============================================================================
7 """Xen management daemon. Lives in /usr/sbin.
8 Provides console server and HTTP management api.
10 Run:
12 xend start
14 The daemon is stopped with:
16 xend stop
18 The daemon should reconnect to device control interfaces
19 and recover its state when restarted.
20 """
21 import os
22 import sys
23 from xen.xend.server import SrvDaemon
25 def check_twisted_version():
26 """Check twisted version and print a warning if not high enough.
27 """
28 from twisted.copyright import version
29 # Supported twisted release and major version.
30 RELEASE = 1
31 MAJOR = 3
32 (release, major, minor) = version.split('.')
33 release = int(release)
34 major = int(major)
35 if release > RELEASE: return
36 if release == RELEASE and major >= MAJOR: return
37 print >>sys.stderr, "*" * 60
38 print >>sys.stderr, "*" * 3, "Warning: Twisted version not supported: %s" % version
39 print >>sys.stderr, "*" * 3, "Use Twisted version %d.%d.0 or higher" % (RELEASE, MAJOR)
40 print >>sys.stderr, "*" * 60
42 def main():
43 check_twisted_version()
44 daemon = SrvDaemon.instance()
45 if not sys.argv[1:]:
46 print 'usage: %s {start|stop|restart}' % sys.argv[0]
47 elif os.fork():
48 pid, status = os.wait()
49 return status >> 8
50 elif sys.argv[1] == 'start':
51 return daemon.start()
52 elif sys.argv[1] == 'trace_start':
53 return daemon.start(trace=1)
54 elif sys.argv[1] == 'stop':
55 return daemon.stop()
56 elif sys.argv[1] == 'restart':
57 return daemon.stop() or daemon.start()
58 else:
59 print 'not an option:', sys.argv[1]
60 return 1
62 if __name__ == '__main__':
63 sys.exit(main())