On 05/08/2012 03:39 AM, Syed A. Ali wrote:
there is a disconnect between the methods that help(libvirt) shows for class virStorageVol and the method listed in 
/usr/lib64/python2.6/site-packages/libvirt.py for the same class.
Yeah, in fact, you run 'import libvirt' in interactive python, it will import the above libvirt.py module.
method createXML used for virStorageVolCreateXML is missing when i use help(libvirt) and scroll down to the class virStorageVol, however the method is listed in libvirt.py as:
The virStorageVolCreateXML() is a libvirt C API not python API, you may find its symbol link in libvirtmod.so:

# nm -A -D /usr/lib64/python2.6/site-packages/libvirtmod.so |grep virStorageVolCreateXML
/usr/lib64/python2.6/site-packages/libvirtmod.so:00000000000265c0 T libvirt_virStorageVolCreateXML
/usr/lib64/python2.6/site-packages/libvirtmod.so:00000000000231d0 T libvirt_virStorageVolCreateXMLFrom
/usr/lib64/python2.6/site-packages/libvirtmod.so:                 U virStorageVolCreateXML
/usr/lib64/python2.6/site-packages/libvirtmod.so:                 U virStorageVolCreateXMLFrom

In addition, you may find the following codes in /usr/lib64/python2.6/site-packages/libvirt.py,
the libvirtmod.so shared library is imported by libvirt.py:

<snip>
try:
    import libvirtmod
except ImportError, lib_e:
    try:
        import cygvirtmod as libvirtmod
    except ImportError, cyg_e:
        if str(cyg_e).count("No module named"):
            raise lib_e
</snip>



    def createXML(self, xmldesc, flags):
        """Create a storage volume within a pool based
        on an XML description. Not all pools support
        creation of volumes """
        ret = libvirtmod.virStorageVolCreateXML(self._o, xmldesc, flags)
        if ret is None:raise libvirtError('virStorageVolCreateXML() failed', pool=self)
        __tmp = virStorageVol(self, _obj=ret)
        return __tmp


From: Osier Yang <jyang@redhat.com>
To: Syed A. Ali <syed_a_ali@yahoo.com>
Cc: "libvirt-users@redhat.com" <libvirt-users@redhat.com>
Sent: Monday, May 7, 2012 6:23 AM
Subject: Re: [libvirt-users] list storage pools and volumes using python api calls

On 2012年05月07日 13:26, Syed A. Ali wrote:
> how do i list storage pools and volumes using the python bindings?
> basically the python api calls for virsh pool-list and virsh vol-list
> thanks
>
>

# python
>>> import libvirt
>>> help(libvirt)

You will find "listStoragePools" in class "virConnect",
and "listVolumes" in class "virStoragePool".

Regards,
Osier

_______________________________________________
libvirt-users mailing list
libvirt-users@redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-users

_______________________________________________ libvirt-users mailing list libvirt-users@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-users