diff options
author | Cole Robinson <crobinso@redhat.com> | 2009-11-20 16:22:42 +0100 |
---|---|---|
committer | Daniel Veillard <veillard@redhat.com> | 2009-11-20 16:22:42 +0100 |
commit | 8153376d7776d820cb1e1948530b945dfb93593f (patch) | |
tree | c6a612a74626c91fe60e1f8e200005da81b7f199 /libvirt-override.c | |
parent | d0e7cc1264533d6a6e4ad2a5b9252f97dc96cba3 (diff) | |
download | libvirt-python-v6-8153376d7776d820cb1e1948530b945dfb93593f.tar.gz libvirt-python-v6-8153376d7776d820cb1e1948530b945dfb93593f.tar.xz libvirt-python-v6-8153376d7776d820cb1e1948530b945dfb93593f.zip |
* python/generator.py python/libvirt-override-api.xml
python/libvirt-override.c: implement the bindings for
virConnectListInterfaces() and virConnectListDefinedInterfaces()
Diffstat (limited to 'libvirt-override.c')
-rw-r--r-- | libvirt-override.c | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/libvirt-override.c b/libvirt-override.c index 20037ef..b885190 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -1761,6 +1761,106 @@ libvirt_virSecretSetValue(PyObject *self ATTRIBUTE_UNUSED, return py_retval; } +static PyObject * +libvirt_virConnectListInterfaces(PyObject *self ATTRIBUTE_UNUSED, + PyObject *args) { + PyObject *py_retval; + char **names = NULL; + int c_retval, i; + virConnectPtr conn; + PyObject *pyobj_conn; + + + if (!PyArg_ParseTuple(args, (char *)"O:virConnectListInterfaces", &pyobj_conn)) + return(NULL); + conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn); + + c_retval = virConnectNumOfInterfaces(conn); + if (c_retval < 0) + return VIR_PY_NONE; + + if (c_retval) { + names = malloc(sizeof(*names) * c_retval); + if (!names) + return VIR_PY_NONE; + c_retval = virConnectListInterfaces(conn, names, c_retval); + if (c_retval < 0) { + free(names); + return VIR_PY_NONE; + } + } + py_retval = PyList_New(c_retval); + if (py_retval == NULL) { + if (names) { + for (i = 0;i < c_retval;i++) + free(names[i]); + free(names); + } + return VIR_PY_NONE; + } + + if (names) { + for (i = 0;i < c_retval;i++) { + PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i])); + free(names[i]); + } + free(names); + } + + return(py_retval); +} + + +static PyObject * +libvirt_virConnectListDefinedInterfaces(PyObject *self ATTRIBUTE_UNUSED, + PyObject *args) { + PyObject *py_retval; + char **names = NULL; + int c_retval, i; + virConnectPtr conn; + PyObject *pyobj_conn; + + + if (!PyArg_ParseTuple(args, (char *)"O:virConnectListDefinedInterfaces", + &pyobj_conn)) + return(NULL); + conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn); + + c_retval = virConnectNumOfDefinedInterfaces(conn); + if (c_retval < 0) + return VIR_PY_NONE; + + if (c_retval) { + names = malloc(sizeof(*names) * c_retval); + if (!names) + return VIR_PY_NONE; + c_retval = virConnectListDefinedInterfaces(conn, names, c_retval); + if (c_retval < 0) { + free(names); + return VIR_PY_NONE; + } + } + py_retval = PyList_New(c_retval); + if (py_retval == NULL) { + if (names) { + for (i = 0;i < c_retval;i++) + free(names[i]); + free(names); + } + return VIR_PY_NONE; + } + + if (names) { + for (i = 0;i < c_retval;i++) { + PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i])); + free(names[i]); + } + free(names); + } + + return(py_retval); +} + /******************************************* * Helper functions to avoid importing modules * for every callback @@ -2472,6 +2572,8 @@ static PyMethodDef libvirtMethods[] = { {(char *) "virConnectListSecrets", libvirt_virConnectListSecrets, METH_VARARGS, NULL}, {(char *) "virSecretGetValue", libvirt_virSecretGetValue, METH_VARARGS, NULL}, {(char *) "virSecretSetValue", libvirt_virSecretSetValue, METH_VARARGS, NULL}, + {(char *) "virConnectListInterfaces", libvirt_virConnectListInterfaces, METH_VARARGS, NULL}, + {(char *) "virConnectListDefinedInterfaces", libvirt_virConnectListDefinedInterfaces, METH_VARARGS, NULL}, {NULL, NULL, 0, NULL} }; |