Hi, This is Arpita. I am using Libvirt API in the Windows Vista system.VMware is installed over there.I have installed Libvirt and Python 2.6 in the Windows Vista system andhave written a small test file in Python. Here is the code: import libvirt* * import sys conn = libvirt.openReadOnly(None) if conn == None: print *'Failed to open connection to the hypervisor' * sys.exit(1) try: dom0 = conn.lookupByName(*"vmware1"*) except: print *'Failed to find the main domain' * sys.exit(1) print *"Domain 0: id %d running %s"* % (dom0.ID(), dom0.OSType()) print dom0.info() When I am trying to execute this python code I received error message that : ImportError: No module named libvirt Please help me. Regards, Arpita -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20110208/62886499/attachment.htm>
2011/2/8 arpita k <arpitak29 at gmail.com>:> Hi, > > This is Arpita. > > I am using Libvirt API in the Windows Vista system.VMware is installed over > there.I have installed Libvirt and Python 2.6 in the Windows Vista system > andhave written a small test file in Python.You mean you're trying to connect to an VMware ESX or Workstation or Player installed on another computer?> Here is the code: > > import libvirt > > import > > sys > > conn = libvirt.openReadOnly( > > None)If you try to connect to a VMware thing on another computer you need to specify the URI (including hostname or IP address) to the libvirt.openReadOnly call: libvirt.openReadOnly("esx://your-esx-server.com") Passing None only works for autodetection on local connections. Also in order to connect to an ESX server you need to use the openAuth function instead of the openReadOnly one.> if > > conn == None: > > print 'Failed to open connection to the hypervisor' > > sys.exit( > > 1) > > try > > : > > dom0 = conn.lookupByName( > > "vmware1") > > except > > : > > print 'Failed to find the main domain' > > sys.exit( > > 1) > > print > > "Domain 0: id %d running %s" % (dom0.ID(), dom0.OSType()) > > print > > dom0.info() > > When I am trying to execute this python code I received error message that : > > ImportError: No module named libvirtCurrently the libvirt installer for Windows includes the Python bindings but doesn't try to detect an installed Python to put the bindings into the right place yet. You have to do this manually. Copy libvirt.py and libvirtmod.py from the python subdirectory of your libvirt installation to the Lib\site-packages subdirectory in your Python 2.6 installation, for example C:\Python26\Lib\site-packages. Now Python should be able to find the libvirt module. Matthias
Reasonably Related Threads
- How to use Python Binding with Lbivirt.
- Not able to capture detailed CPU information of the guest machine using Libvirt API.
- Unable to close open libvirt connections
- unable to get domain list of KVM guests from libvirt as non-root user
- How to retrieve Memory stat of the KVM using python binding with Libvirt API