2011/2/8 arpita k <arpitak29(a)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 libvirt
Currently 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