Revision 0105bad3 lib/hypervisor/hv_xen.py
b/lib/hypervisor/hv_xen.py | ||
---|---|---|
199 | 199 |
def GetNodeInfo(self): |
200 | 200 |
"""Return information about the node. |
201 | 201 |
|
202 |
@return: a dict with the following keys (values in MiB): |
|
202 |
@return: a dict with the following keys (memory values in MiB):
|
|
203 | 203 |
- memory_total: the total memory size on the node |
204 | 204 |
- memory_free: the available memory on the node for instances |
205 | 205 |
- memory_dom0: the memory used by the node itself, if available |
206 |
- nr_cpus: total number of CPUs |
|
207 |
- nr_nodes: in a NUMA system, the number of domains |
|
208 |
- nr_sockets: the number of physical CPU sockets in the node |
|
206 | 209 |
|
207 | 210 |
""" |
208 | 211 |
# note: in xen 3, memory has changed to total_memory |
... | ... | |
214 | 217 |
|
215 | 218 |
xmoutput = result.stdout.splitlines() |
216 | 219 |
result = {} |
220 |
cores_per_socket = threads_per_core = nr_cpus = None |
|
217 | 221 |
for line in xmoutput: |
218 | 222 |
splitfields = line.split(":", 1) |
219 | 223 |
|
... | ... | |
225 | 229 |
elif key == 'free_memory': |
226 | 230 |
result['memory_free'] = int(val) |
227 | 231 |
elif key == 'nr_cpus': |
228 |
result['cpu_total'] = int(val) |
|
232 |
nr_cpus = result['cpu_total'] = int(val) |
|
233 |
elif key == 'nr_nodes': |
|
234 |
result['cpu_nodes'] = int(val) |
|
235 |
elif key == 'cores_per_socket': |
|
236 |
cores_per_socket = int(val) |
|
237 |
elif key == 'threads_per_core': |
|
238 |
threads_per_core = int(val) |
|
239 |
|
|
240 |
if (cores_per_socket is not None and |
|
241 |
threads_per_core is not None and nr_cpus is not None): |
|
242 |
result['cpu_sockets'] = nr_cpus / (cores_per_socket * threads_per_core) |
|
243 |
|
|
229 | 244 |
dom0_info = self.GetInstanceInfo("Domain-0") |
230 | 245 |
if dom0_info is not None: |
231 | 246 |
result['memory_dom0'] = dom0_info[2] |
Also available in: Unified diff