mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
python: Expose virStorageListAllStoragePools 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-virConnect.py: Add listAllStoragePools python/libvirt-override.c: Implementation for the wrapper.
This commit is contained in:
parent
93a346d353
commit
9278578069
@ -306,6 +306,12 @@
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<return type='str *' info='the list of Names of None in case of error'/>
|
||||
</function>
|
||||
<function name='virConnectListAllStoragePools' file='python'>
|
||||
<info>returns list of all storage pools</info>
|
||||
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
|
||||
<arg name='flags' type='unsigned int' info='optional flags'/>
|
||||
<return type='pool *' info='the list of pools or None in case of error'/>
|
||||
</function>
|
||||
<function name='virStoragePoolListVolumes' file='python'>
|
||||
<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'/>
|
||||
|
@ -206,3 +206,15 @@
|
||||
retlist.append(virDomain(self, _obj=domptr))
|
||||
|
||||
return retlist
|
||||
|
||||
def listAllStoragePools(self, flags):
|
||||
"""Returns a list of storage pool objects"""
|
||||
ret = libvirtmod.virConnectListAllStoragePools(self._o, flags)
|
||||
if ret is None:
|
||||
raise libvirtError("virConnectListAllStoragePools() failed", conn=self)
|
||||
|
||||
retlist = list()
|
||||
for poolptr in ret:
|
||||
retlist.append(virStoragePool(self, _obj=poolptr))
|
||||
|
||||
return retlist
|
||||
|
@ -2983,6 +2983,52 @@ libvirt_virConnectListDefinedStoragePools(PyObject *self ATTRIBUTE_UNUSED,
|
||||
return py_retval;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
libvirt_virConnectListAllStoragePools(PyObject *self ATTRIBUTE_UNUSED,
|
||||
PyObject *args)
|
||||
{
|
||||
PyObject *pyobj_conn;
|
||||
PyObject *py_retval = NULL;
|
||||
PyObject *tmp = NULL;
|
||||
virConnectPtr conn;
|
||||
virStoragePoolPtr *pools = NULL;
|
||||
int c_retval = 0;
|
||||
int i;
|
||||
unsigned int flags;
|
||||
|
||||
if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllStoragePools",
|
||||
&pyobj_conn, &flags))
|
||||
return NULL;
|
||||
conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
|
||||
|
||||
LIBVIRT_BEGIN_ALLOW_THREADS;
|
||||
c_retval = virConnectListAllStoragePools(conn, &pools, 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_virStoragePoolPtrWrap(pools[i])) ||
|
||||
PyList_SetItem(py_retval, i, tmp) < 0) {
|
||||
Py_XDECREF(tmp);
|
||||
Py_DECREF(py_retval);
|
||||
py_retval = NULL;
|
||||
goto cleanup;
|
||||
}
|
||||
/* python steals the pointer */
|
||||
pools[i] = NULL;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
for (i = 0; i < c_retval; i++)
|
||||
if (pools[i])
|
||||
virStoragePoolFree(pools[i]);
|
||||
VIR_FREE(pools);
|
||||
return py_retval;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
libvirt_virStoragePoolListVolumes(PyObject *self ATTRIBUTE_UNUSED,
|
||||
@ -5878,6 +5924,7 @@ static PyMethodDef libvirtMethods[] = {
|
||||
{(char *) "virDomainGetVcpuPinInfo", libvirt_virDomainGetVcpuPinInfo, METH_VARARGS, NULL},
|
||||
{(char *) "virConnectListStoragePools", libvirt_virConnectListStoragePools, METH_VARARGS, NULL},
|
||||
{(char *) "virConnectListDefinedStoragePools", libvirt_virConnectListDefinedStoragePools, METH_VARARGS, NULL},
|
||||
{(char *) "virConnectListAllStoragePools", libvirt_virConnectListAllStoragePools, METH_VARARGS, NULL},
|
||||
{(char *) "virStoragePoolGetAutostart", libvirt_virStoragePoolGetAutostart, METH_VARARGS, NULL},
|
||||
{(char *) "virStoragePoolListVolumes", libvirt_virStoragePoolListVolumes, METH_VARARGS, NULL},
|
||||
{(char *) "virStoragePoolGetInfo", libvirt_virStoragePoolGetInfo, METH_VARARGS, NULL},
|
||||
|
Loading…
Reference in New Issue
Block a user