mirror of https://gitee.com/openkylin/libvirt.git
list: Expose virStoragePoolListAllVolumes to Python binding
The implementation is done manually as the generator does not support wrapping lists of C pointers into Python objects. python/libvirt-override-api.xml: Document python/libvirt-override-virStoragePool.py: * New file, includes implementation of listAllVolumes. python/libvirt-override.c: Implementation for the wrapper.
This commit is contained in:
parent
7e9548fce3
commit
fa2e35a336
|
@ -315,7 +315,13 @@
|
||||||
<function name='virStoragePoolListVolumes' file='python'>
|
<function name='virStoragePoolListVolumes' file='python'>
|
||||||
<info>list the storage volumes, stores the pointers to the names in @names</info>
|
<info>list the storage volumes, stores the pointers to the names in @names</info>
|
||||||
<arg name='pool' type='virStoragePoolPtr' info='pointer to the storage pool'/>
|
<arg name='pool' type='virStoragePoolPtr' info='pointer to the storage pool'/>
|
||||||
<return type='str *' info='the list of Names of None in case of error'/>
|
<return type='str *' info='the list of Names or None in case of error'/>
|
||||||
|
</function>
|
||||||
|
<function name='virStoragePoolListAllVolumes' file='python'>
|
||||||
|
<info>return list of storage volume objects</info>
|
||||||
|
<arg name='pool' type='virStoragePoolPtr' info='pointer to the storage pool'/>
|
||||||
|
<arg name='flags' type='unsigned int' info='optional flags'/>
|
||||||
|
<return type='volume *' info='the list of volumes or None in case of error'/>
|
||||||
</function>
|
</function>
|
||||||
<function name='virStoragePoolGetInfo' file='python'>
|
<function name='virStoragePoolGetInfo' file='python'>
|
||||||
<info>Extract information about a storage pool. Note that if the connection used to get the domain is limited only a partial set of the information can be extracted.</info>
|
<info>Extract information about a storage pool. Note that if the connection used to get the domain is limited only a partial set of the information can be extracted.</info>
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
def listAllVolumes(self, flags):
|
||||||
|
"""List all storage volumes and returns a list of storage volume objects"""
|
||||||
|
ret = libvirtmod.virStoragePoolListAllVolumes(self._o, flags)
|
||||||
|
if ret is None:
|
||||||
|
raise libvirtError("virStoragePoolListAllVolumes() failed", conn=self)
|
||||||
|
|
||||||
|
retlist = list()
|
||||||
|
for volptr in ret:
|
||||||
|
retlist.append(virStorageVol(self, _obj=volptr))
|
||||||
|
|
||||||
|
return retlist
|
|
@ -3082,6 +3082,55 @@ libvirt_virStoragePoolListVolumes(PyObject *self ATTRIBUTE_UNUSED,
|
||||||
return py_retval;
|
return py_retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
libvirt_virStoragePoolListAllVolumes(PyObject *self ATTRIBUTE_UNUSED,
|
||||||
|
PyObject *args)
|
||||||
|
{
|
||||||
|
PyObject *py_retval = NULL;
|
||||||
|
PyObject *tmp = NULL;
|
||||||
|
virStoragePoolPtr pool;
|
||||||
|
virStorageVolPtr *vols = NULL;
|
||||||
|
int c_retval = 0;
|
||||||
|
int i;
|
||||||
|
unsigned int flags;
|
||||||
|
PyObject *pyobj_pool;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, (char *)"Oi:virStoragePoolListAllVolumes",
|
||||||
|
&pyobj_pool, &flags))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
pool = (virStoragePoolPtr) PyvirStoragePool_Get(pyobj_pool);
|
||||||
|
|
||||||
|
LIBVIRT_BEGIN_ALLOW_THREADS;
|
||||||
|
c_retval = virStoragePoolListAllVolumes(pool, &vols, flags);
|
||||||
|
LIBVIRT_END_ALLOW_THREADS;
|
||||||
|
if (c_retval < 0)
|
||||||
|
return VIR_PY_NONE;
|
||||||
|
|
||||||
|
if (!(py_retval = PyList_New(c_retval)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
for (i = 0; i < c_retval; i++) {
|
||||||
|
if (!(tmp = libvirt_virStorageVolPtrWrap(vols[i])) ||
|
||||||
|
PyList_SetItem(py_retval, i, tmp) < 0) {
|
||||||
|
Py_XDECREF(tmp);
|
||||||
|
Py_DECREF(py_retval);
|
||||||
|
py_retval = NULL;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
/* python steals the pointer */
|
||||||
|
vols[i] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
for (i = 0; i < c_retval; i++)
|
||||||
|
if (vols[i])
|
||||||
|
virStorageVolFree(vols[i]);
|
||||||
|
VIR_FREE(vols);
|
||||||
|
return py_retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
libvirt_virStoragePoolGetAutostart(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
|
libvirt_virStoragePoolGetAutostart(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
|
||||||
PyObject *py_retval;
|
PyObject *py_retval;
|
||||||
|
@ -5927,6 +5976,7 @@ static PyMethodDef libvirtMethods[] = {
|
||||||
{(char *) "virConnectListAllStoragePools", libvirt_virConnectListAllStoragePools, METH_VARARGS, NULL},
|
{(char *) "virConnectListAllStoragePools", libvirt_virConnectListAllStoragePools, METH_VARARGS, NULL},
|
||||||
{(char *) "virStoragePoolGetAutostart", libvirt_virStoragePoolGetAutostart, METH_VARARGS, NULL},
|
{(char *) "virStoragePoolGetAutostart", libvirt_virStoragePoolGetAutostart, METH_VARARGS, NULL},
|
||||||
{(char *) "virStoragePoolListVolumes", libvirt_virStoragePoolListVolumes, METH_VARARGS, NULL},
|
{(char *) "virStoragePoolListVolumes", libvirt_virStoragePoolListVolumes, METH_VARARGS, NULL},
|
||||||
|
{(char *) "virStoragePoolListAllVolumes", libvirt_virStoragePoolListAllVolumes, METH_VARARGS, NULL},
|
||||||
{(char *) "virStoragePoolGetInfo", libvirt_virStoragePoolGetInfo, METH_VARARGS, NULL},
|
{(char *) "virStoragePoolGetInfo", libvirt_virStoragePoolGetInfo, METH_VARARGS, NULL},
|
||||||
{(char *) "virStorageVolGetInfo", libvirt_virStorageVolGetInfo, METH_VARARGS, NULL},
|
{(char *) "virStorageVolGetInfo", libvirt_virStorageVolGetInfo, METH_VARARGS, NULL},
|
||||||
{(char *) "virStoragePoolGetUUID", libvirt_virStoragePoolGetUUID, METH_VARARGS, NULL},
|
{(char *) "virStoragePoolGetUUID", libvirt_virStoragePoolGetUUID, METH_VARARGS, NULL},
|
||||||
|
|
Loading…
Reference in New Issue