diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml index 67ef36e3076935e76a5204b0731009ad781d0ee2..d16755c260504ca560c56e48f110f540a9be78dd 100644 --- a/python/libvirt-override-api.xml +++ b/python/libvirt-override-api.xml @@ -306,6 +306,12 @@ + + returns list of all storage pools + + + + list the storage volumes, stores the pointers to the names in @names diff --git a/python/libvirt-override-virConnect.py b/python/libvirt-override-virConnect.py index 50177abb49a638a72f16941018d36b11c328ef8c..87a737f1fb6587dae6f4eace6bb876aa17bbcb9b 100644 --- a/python/libvirt-override-virConnect.py +++ b/python/libvirt-override-virConnect.py @@ -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 diff --git a/python/libvirt-override.c b/python/libvirt-override.c index 65e8c69ddc370576ec45a84ec86cc76fe5c59511..1e3ad89f10383dbcd4a3efc19ef41a899d193ad4 100644 --- a/python/libvirt-override.c +++ b/python/libvirt-override.c @@ -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},