ia64/xen-unstable

view tools/python/xen/xend/XendNode.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 """Handler for node operations.
19 Has some persistent state:
20 - logs
21 - notification urls
23 """
25 import os
26 import xen.lowlevel.xc
28 class XendNode:
30 def __init__(self):
31 self.xc = xen.lowlevel.xc.new()
33 def shutdown(self):
34 return 0
36 def reboot(self):
37 return 0
39 def notify(self, uri):
40 return 0
42 def cpu_bvt_slice_set(self, ctx_allow):
43 return self.xc.bvtsched_global_set(ctx_allow=ctx_allow)
45 def cpu_bvt_slice_get(self):
46 return self.xc.bvtsched_global_get()
48 def info(self):
49 return self.nodeinfo() + self.physinfo()
51 def nodeinfo(self):
52 (sys, host, rel, ver, mch) = os.uname()
53 return [['system', sys],
54 ['host', host],
55 ['release', rel],
56 ['version', ver],
57 ['machine', mch]]
59 def physinfo(self):
60 pinfo = self.xc.physinfo()
61 info = [['cores_per_socket', pinfo['cores_per_socket']],
62 ['threads_per_core', pinfo['threads_per_core']],
63 ['cpu_mhz', pinfo['cpu_khz']/1000],
64 ['memory', pinfo['total_pages']/256],
65 ['free_memory', pinfo['free_pages']/256]]
66 return info
70 def instance():
71 global inst
72 try:
73 inst
74 except:
75 inst = XendNode()
76 return inst