summaryrefslogtreecommitdiffstats
path: root/tests/node.py
blob: 2e33fb70cc09245d6e89e5c7fdb29d21a64aeaad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python -u
import libvirt
import sys
import os

if not os.access("/proc/xen", os.R_OK):
    print 'System is not running a Xen kernel'
    sys.exit(1)

conn = libvirt.openReadOnly(None)
if conn == None:
    print 'Failed to open connection to the hypervisor'
    sys.exit(1)

try:
    (model, memory, cpus, mhz, nodes, socket, cores, threads) = conn.getInfo()
except:
    print 'Failed to extract the current node informations'
    sys.exit(1)

print "Xen running on %d %s processors at %d MHz, %d MBytes of memory" % (
       cpus, model, mhz, memory)

if cpus > nodes * socket * cores * threads:
    print "Erroneous CPU informations"
    sys.exit(1)

if cpus < nodes * socket * cores * threads:
    print "Strange, running in degrated mode, some CPU are not available"

del conn
print "OK"

sys.exit(0)