Discussion:
[libvirt-users] free memory on hypervisor
John Wayne
2012-05-04 06:28:10 UTC
Permalink
i am trying to get the free memory on a hypervisor using libvert, with the python api bindings
as per http://libvirt.org/python.html, it should be pretty easy, however the below is failing:

#conn is a connection object
freemem=libvirt.virNode.getFreeMemory(conn)

although this works fine:

software=libvirt.virConnect.getType(conn)
if software ==  'QEMU':
logging.debug('hypervisor is type QEMU')
Alex Jia
2012-05-04 06:59:57 UTC
Permalink
Post by John Wayne
i am trying to get the free memory on a hypervisor using libvert, with the python api bindings
#conn is a connection object
freemem=libvirt.virNode.getFreeMemory(conn)
There are 2 wrongs in here, the first, libvirt module hasn't 'virNode'
class, it should be 'virNodeDevice';
the second, 'virNodeDevice' class hasn't 'getFreeMemory' method, which
belongs to 'virConnect' class,
Post by John Wayne
import libvirt
conn = libvirt.open(None)
conn.getFreeMemory()
228167680L

or
Post by John Wayne
libvirt.virConnect.getFreeMemory(conn)
227864576L
Post by John Wayne
dir(libvirt)
dir(libvirt. virConnect)
software=libvirt.virConnect.getType(conn)
logging.debug('hypervisor is type QEMU')
_______________________________________________
libvirt-users mailing list
https://www.redhat.com/mailman/listinfo/libvirt-users
Loading...