ia64/xen-unstable

view tools/python/xen/xend/server/SrvServer.py @ 4936:e208b160c5f5

bitkeeper revision 1.1419 (4288b44f4jmaJGEAjpgklKaura3Q9g)

SrvServer.py:
Use log.info to output unix server address.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Mon May 16 14:55:11 2005 +0000 (2005-05-16)
parents 16efdf7bbd57
children 0ee061e5b8a8 8799d14bef77
line source
1 #!/usr/bin/python
2 # Copyright (C) 2004 Mike Wray <mike.wray@hp.com>
4 """Example xend HTTP and console server.
6 Can be accessed from a browser or from a program.
7 Do 'python SrvServer.py' to run the server.
8 Then point a web browser at http://localhost:8000/xend and follow the links.
9 Most are stubs, except /domain which has a list of domains and a 'create domain'
10 button.
12 You can also access the server from a program.
13 Do 'python XendClient.py' to run a few test operations.
15 The data served differs depending on the client (as defined by User-Agent
16 and Accept in the HTTP headers). If the client is a browser, data
17 is returned in HTML, with interactive forms. If the client is a program,
18 data is returned in SXP format, with no forms.
20 The server serves to the world by default. To restrict it to the local host
21 change 'interface' in main().
23 Mike Wray <mike.wray@hp.com>
24 """
25 # todo Support security settings etc. in the config file.
26 # todo Support command-line args.
28 from threading import Thread
30 from xen.web.httpserver import HttpServer, UnixHttpServer
32 from xen.xend import XendRoot; xroot = XendRoot.instance()
33 from xen.xend import Vifctl
34 from xen.xend.XendLogging import log
35 from xen.web.SrvDir import SrvDir
37 from SrvRoot import SrvRoot
39 class XendServers:
41 def __init__(self):
42 self.servers = []
44 def add(self, server):
45 self.servers.append(server)
47 def start(self):
48 Vifctl.network('start')
49 for server in self.servers:
50 thread = Thread(target=server.run)
51 thread.start()
53 def create():
54 root = SrvDir()
55 root.putChild('xend', SrvRoot())
56 servers = XendServers()
57 if xroot.get_xend_http_server():
58 port = xroot.get_xend_port()
59 interface = xroot.get_xend_address()
60 servers.add(HttpServer(root=root, interface=interface, port=port))
61 if xroot.get_xend_unix_server():
62 path = xroot.get_xend_unix_path()
63 log.info('unix path=' + path)
64 servers.add(UnixHttpServer(path=path, root=root))
65 return servers