debuggers.hg

view tools/python/xen/xend/server/SrvConsoleDir.py @ 4672:d781b9d08e80

bitkeeper revision 1.1327.2.4 (426918a34Af7gihN8mTkq-P3KrAZXg)

Remove twisted from save/migrate handling.
This needs to use threads, so add thread support for
http server requests.

Signed-off-by: Mike Wray <mike.wray@hp.com>
author mjw@wray-m-3.hpl.hp.com
date Fri Apr 22 15:30:43 2005 +0000 (2005-04-22)
parents dae98734f12e
children 16efdf7bbd57
line source
1 # Copyright (C) 2004 Mike Wray <mike.wray@hp.com>
3 from SrvDir import SrvDir
4 from SrvConsole import SrvConsole
5 from xen.xend import XendConsole
6 from xen.xend import sxp
8 class SrvConsoleDir(SrvDir):
9 """Console directory.
10 """
12 def __init__(self):
13 SrvDir.__init__(self)
14 self.xconsole = XendConsole.instance()
16 def console(self, x):
17 val = None
18 try:
19 info = self.xconsole.console_get(x)
20 val = SrvConsole(info)
21 except KeyError, ex:
22 print 'SrvConsoleDir>', ex
23 pass
24 return val
26 def get(self, x):
27 v = SrvDir.get(self, x)
28 if v is not None:
29 return v
30 v = self.console(x)
31 return v
33 def render_GET(self, req):
34 if self.use_sxp(req):
35 req.setHeader("Content-Type", sxp.mime_type)
36 self.ls_console(req, 1)
37 else:
38 req.write("<html><head></head><body>")
39 self.print_path(req)
40 self.ls(req)
41 self.ls_console(req)
42 #self.form(req.wfile)
43 req.write("</body></html>")
45 def ls_console(self, req, use_sxp=0):
46 url = req.prePathURL()
47 if not url.endswith('/'):
48 url += '/'
49 if use_sxp:
50 consoles = self.xconsole.console_ls()
51 sxp.show(consoles, out=req)
52 else:
53 consoles = self.xconsole.consoles()
54 consoles.sort(lambda x, y: cmp(x.console_port, y.console_port))
55 req.write('<ul>')
56 for c in consoles:
57 cid = str(c.console_port)
58 req.write('<li><a href="%s%s"> %s</a></li>' % (url, cid, cid))
59 req.write('</ul>')