ia64/xen-unstable

view tools/python/xen/xend/XendNode.py @ 11232:4d8ab492bdee

[xend] Add 'xend_config_format' field to the Xend information block.
When running 'xm info' it appears thus:

# xm info
host : 10.13.4.252
release : 2.6.17-1.2157_FC5xen0
version : #1 SMP Tue Jul 11 23:30:05 EDT 2006
machine : x86_64
...snipped rest of data...
cc_compile_domain : build.redhat.com
cc_compile_date : Tue Jul 11 22:50:42 EDT 2006
xend_config_format : 2

It will also appear in the SEXPR returned when doing a GET on the
/xend/node path in XenD's HTTP service:

(node
(system Linux)
(host 10.13.4.252)
(release 2.6.17-1.2157_FC5xen0)
(version '#1 SMP Tue Jul 11 23:30:05 EDT 2006')
(machine x86_64)
...snipped rest of data...
(cc_compile_domain build.redhat.com)
(cc_compile_date 'Tue Jul 11 22:50:42 EDT 2006')
(xend_config_format 2)
)

The patch sets the format to value '2' to indicate that we're on the version
with the new style HVM configuration for CDROM devices. The old style having
implicitly been version '1'.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
author Christian Limpach <Christian.Limpach@xensource.com>
date Mon Aug 21 00:11:17 2006 +0100 (2006-08-21)
parents 234939c0ec3a
children 26b673aeff8b
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.xc()
33 def shutdown(self):
34 return 0
36 def reboot(self):
37 return 0
39 def notify(self, _):
40 return 0
42 def cpu_bvt_slice_set(self, ctx_allow):
43 return self.xc.bvtsched_global_set(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() + self.xeninfo() +
50 self.xendinfo())
52 def nodeinfo(self):
53 (sys, host, rel, ver, mch) = os.uname()
54 return [['system', sys],
55 ['host', host],
56 ['release', rel],
57 ['version', ver],
58 ['machine', mch]]
60 def physinfo(self):
61 info = self.xc.physinfo()
63 info['nr_cpus'] = (info['nr_nodes'] *
64 info['sockets_per_node'] *
65 info['cores_per_socket'] *
66 info['threads_per_core'])
67 info['cpu_mhz'] = info['cpu_khz'] / 1000
68 # physinfo is in KiB
69 info['total_memory'] = info['total_memory'] / 1024
70 info['free_memory'] = info['free_memory'] / 1024
72 ITEM_ORDER = ['nr_cpus',
73 'nr_nodes',
74 'sockets_per_node',
75 'cores_per_socket',
76 'threads_per_core',
77 'cpu_mhz',
78 'hw_caps',
79 'total_memory',
80 'free_memory',
81 ]
83 return [[k, info[k]] for k in ITEM_ORDER]
86 def xeninfo(self):
87 info = self.xc.xeninfo()
89 ITEM_ORDER = ['xen_major',
90 'xen_minor',
91 'xen_extra',
92 'xen_caps',
93 'xen_pagesize',
94 'platform_params',
95 'xen_changeset',
96 'cc_compiler',
97 'cc_compile_by',
98 'cc_compile_domain',
99 'cc_compile_date',
100 ]
102 return [[k, info[k]] for k in ITEM_ORDER]
104 def xendinfo(self):
105 return [['xend_config_format', 2]]
108 def instance():
109 global inst
110 try:
111 inst
112 except:
113 inst = XendNode()
114 return inst