[libvirt-users] How to use Python Binding with Lbivirt.

arpita k arpitak29 at gmail.com
Wed Feb 9 11:18:07 UTC 2011


HI,

I am using ubuntu host machine and KVM is present as guest in that
machine.Two virtual machines are there.I am using Python binding to query on
the hypervisor and extract the VM related information.

Here is my  simple code:


#!/*usr*/local/bin/*python
*

import libvirt

import sys

conn = libvirt.openReadOnly(None)

if conn == None:

print *'Failed to open connection to the hypervisor'
*

sys.exit(1)

try:

domIds = conn.listDomainsID()

for id in domIds:

dom0 = conn.lookupByID(id)

dom0.info()

print *"Domain 0: id %d running %s"* % (dom0.ID(), dom0.OSType())

print dom0.info()

except:

print *'Failed to find the main domain'
*

sys.exit()
The output is :

Domain 0: id 2 running hvm
[1, 131072L, 131072L, 1, 14921710000000L]
Domain 0: id 3 running hvm
[1, 131072L, 131072L, 1, 30880000000L]

Here I am not able to understand these values are represent what type of
information, which value is representing what resource of host machine.Could
you please help me to understand how I could find out CPU,VM ,memory related
information seperately through python binding?.
I didn't find Python binding Reference in the Libvirt site.Could you help me
by providing the Reference link for Python binding?

Thanks in Advance!!

Arpita
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20110209/4240a6ee/attachment.htm>


More information about the libvirt-users mailing list