summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOsier Yang <jyang@redhat.com>2012-09-14 16:38:51 +0800
committerOsier Yang <jyang@redhat.com>2012-09-17 13:18:51 +0800
commit4a8290241b6308c0a1827073ca9d5eeb7fbe6a0a (patch)
tree6d9237c554009105743d493cb628c1d6e6960364
parentc29d33763777b68fd43f9d8d0e73f10e18677612 (diff)
downloadlibvirt-python-split-4a8290241b6308c0a1827073ca9d5eeb7fbe6a0a.zip
libvirt-python-split-4a8290241b6308c0a1827073ca9d5eeb7fbe6a0a.tar.gz
libvirt-python-split-4a8290241b6308c0a1827073ca9d5eeb7fbe6a0a.tar.xz
list: Expose virConnectListAllSecrets 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: Implementation for listAllSecrets. python/libvirt-override.c: Implementation for the wrapper.
-rw-r--r--libvirt-override-api.xml6
-rw-r--r--libvirt-override-virConnect.py12
-rw-r--r--libvirt-override.c48
3 files changed, 66 insertions, 0 deletions
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index b8ab823..4f609ee 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -368,6 +368,12 @@
<arg name='conn' type='virConnectPtr' info='virConnect connection'/>
<return type='str *' info='the list of secret IDs or None in case of error'/>
</function>
+ <function name='virConnectListAllSecrets' file='python'>
+ <info>returns list of all interfaces</info>
+ <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
+ <arg name='flags' type='unsigned int' info='optional flags'/>
+ <return type='secret *' info='the list of secrets or None in case of error'/>
+ </function>
<function name='virSecretSetValue' file='libvirt' module='libvirt'>
<info>Associates a value with a secret.</info>
<return type='int' info='0 on success, -1 on failure.'/>
diff --git a/libvirt-override-virConnect.py b/libvirt-override-virConnect.py
index caca982..6bec66d 100644
--- a/libvirt-override-virConnect.py
+++ b/libvirt-override-virConnect.py
@@ -266,3 +266,15 @@
retlist.append(virNWFilter(self, _obj=filter_ptr))
return retlist
+
+ def listAllSecrets(self, flags):
+ """Returns a list of secret objects"""
+ ret = libvirtmod.virConnectListAllSecrets(self._o, flags)
+ if ret is None:
+ raise libvirtError("virConnectListAllSecrets() failed", conn=self)
+
+ retlist = list()
+ for secret_ptr in ret:
+ retlist.append(virSecret(self, _obj=secret_ptr))
+
+ return retlist
diff --git a/libvirt-override.c b/libvirt-override.c
index 0f8e4af..57f2c45 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -3596,6 +3596,53 @@ libvirt_virConnectListSecrets(PyObject *self ATTRIBUTE_UNUSED,
}
static PyObject *
+libvirt_virConnectListAllSecrets(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args)
+{
+ PyObject *pyobj_conn;
+ PyObject *py_retval = NULL;
+ PyObject *tmp = NULL;
+ virConnectPtr conn;
+ virSecretPtr *secrets = NULL;
+ int c_retval = 0;
+ int i;
+ unsigned int flags;
+
+ if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllSecrets",
+ &pyobj_conn, &flags))
+ return NULL;
+ conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_retval = virConnectListAllSecrets(conn, &secrets, 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_virSecretPtrWrap(secrets[i])) ||
+ PyList_SetItem(py_retval, i, tmp) < 0) {
+ Py_XDECREF(tmp);
+ Py_DECREF(py_retval);
+ py_retval = NULL;
+ goto cleanup;
+ }
+ /* python steals the pointer */
+ secrets[i] = NULL;
+ }
+
+cleanup:
+ for (i = 0; i < c_retval; i++)
+ if (secrets[i])
+ virSecretFree(secrets[i]);
+ VIR_FREE(secrets);
+ return py_retval;
+}
+
+static PyObject *
libvirt_virSecretGetValue(PyObject *self ATTRIBUTE_UNUSED,
PyObject *args) {
PyObject *py_retval;
@@ -6187,6 +6234,7 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virSecretGetUUIDString", libvirt_virSecretGetUUIDString, METH_VARARGS, NULL},
{(char *) "virSecretLookupByUUID", libvirt_virSecretLookupByUUID, METH_VARARGS, NULL},
{(char *) "virConnectListSecrets", libvirt_virConnectListSecrets, METH_VARARGS, NULL},
+ {(char *) "virConnectListAllSecrets", libvirt_virConnectListAllSecrets, METH_VARARGS, NULL},
{(char *) "virSecretGetValue", libvirt_virSecretGetValue, METH_VARARGS, NULL},
{(char *) "virSecretSetValue", libvirt_virSecretSetValue, METH_VARARGS, NULL},
{(char *) "virNWFilterGetUUID", libvirt_virNWFilterGetUUID, METH_VARARGS, NULL},