ia64/xen-unstable

view tools/python/xen/xend/server/SrvNode.py @ 6538:84ee014ebd41

Merge xen-vtx-unstable.hg
author adsharma@los-vmm.sc.intel.com
date Wed Aug 17 12:34:38 2005 -0800 (2005-08-17)
parents 23979fb12c49 f40c6650152e
children 99914b54f7bf
line source
1 #============================================================================
2 # This library is free software; you can redistribute it and/or
3 # modify it under the terms of version 2.1 of the GNU Lesser General Public
4 # License as published by the Free Software Foundation.
5 #
6 # This library is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9 # Lesser General Public License for more details.
10 #
11 # You should have received a copy of the GNU Lesser General Public
12 # License along with this library; if not, write to the Free Software
13 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 #============================================================================
15 # Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
16 #============================================================================
18 import os
20 from xen.web.SrvDir import SrvDir
21 from xen.xend import sxp
22 from xen.xend import XendNode
23 from xen.xend.Args import FormFn
25 class SrvNode(SrvDir):
26 """Information about the node.
27 """
29 def __init__(self):
30 SrvDir.__init__(self)
31 self.xn = XendNode.instance()
32 self.add('dmesg', 'SrvDmesg')
33 self.add('log', 'SrvXendLog')
35 def op_shutdown(self, op, req):
36 val = self.xn.shutdown()
37 return val
39 def op_reboot(self, op, req):
40 val = self.xn.reboot()
41 return val
43 def op_cpu_bvt_slice_set(self, op, req):
44 fn = FormFn(self.xn.cpu_bvt_slice_set,
45 [['ctx_allow', 'int']])
46 val = fn(req.args, {})
47 return val
49 def render_POST(self, req):
50 return self.perform(req)
52 def render_GET(self, req):
53 if self.use_sxp(req):
54 req.setHeader("Content-Type", sxp.mime_type)
55 sxp.show(['node'] + self.info(), out=req)
56 else:
57 url = req.prePathURL()
58 if not url.endswith('/'):
59 url += '/'
60 req.write('<html><head></head><body>')
61 self.print_path(req)
62 req.write('<ul>')
63 for d in self.info():
64 req.write('<li> %10s: %s' % (d[0], str(d[1])))
65 req.write('<li><a href="%sdmesg">Xen dmesg output</a>' % url)
66 req.write('<li><a href="%slog>Xend log</a>' % url)
67 req.write('</ul>')
68 req.write('</body></html>')
70 def info(self):
71 return self.xn.info()