mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
python: Actually implement list*Interfaces bindings
* python/generator.py python/libvirt-override-api.xml python/libvirt-override.c: implement the bindings for virConnectListInterfaces() and virConnectListDefinedInterfaces()
This commit is contained in:
committed by
Daniel Veillard
parent
7d43c80bc4
commit
c7e1cfc9f4
@@ -260,13 +260,13 @@ skip_impl = (
|
|||||||
'virConnectListDefinedDomains',
|
'virConnectListDefinedDomains',
|
||||||
'virConnectListNetworks',
|
'virConnectListNetworks',
|
||||||
'virConnectListDefinedNetworks',
|
'virConnectListDefinedNetworks',
|
||||||
'virConnectListInterfaces',
|
|
||||||
'virConnectListDefinedInterfaces',
|
|
||||||
'virConnectListSecrets',
|
'virConnectListSecrets',
|
||||||
|
'virConnectListInterfaces',
|
||||||
'virConnectListStoragePools',
|
'virConnectListStoragePools',
|
||||||
'virConnectListDefinedStoragePools',
|
'virConnectListDefinedStoragePools',
|
||||||
'virConnectListStorageVols',
|
'virConnectListStorageVols',
|
||||||
'virConnectListDefinedStorageVols',
|
'virConnectListDefinedStorageVols',
|
||||||
|
'virConnectListDefinedInterfaces',
|
||||||
'virConnGetLastError',
|
'virConnGetLastError',
|
||||||
'virGetLastError',
|
'virGetLastError',
|
||||||
'virDomainGetInfo',
|
'virDomainGetInfo',
|
||||||
|
|||||||
@@ -211,5 +211,15 @@
|
|||||||
<return type='char *' info='the UUID string or None in case of error'/>
|
<return type='char *' info='the UUID string or None in case of error'/>
|
||||||
<arg name='secret' type='virSecretPtr' info='a secret object'/>
|
<arg name='secret' type='virSecretPtr' info='a secret object'/>
|
||||||
</function>
|
</function>
|
||||||
|
<function name='virConnectListInterfaces' file='python'>
|
||||||
|
<info>list the running interfaces, stores the pointers to the names in @names</info>
|
||||||
|
<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='virConnectListDefinedInterfaces' file='python'>
|
||||||
|
<info>list the defined interfaces, stores the pointers to the names in @names</info>
|
||||||
|
<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>
|
||||||
</symbols>
|
</symbols>
|
||||||
</api>
|
</api>
|
||||||
|
|||||||
@@ -1761,6 +1761,106 @@ libvirt_virSecretSetValue(PyObject *self ATTRIBUTE_UNUSED,
|
|||||||
return py_retval;
|
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
|
* Helper functions to avoid importing modules
|
||||||
* for every callback
|
* for every callback
|
||||||
@@ -2472,6 +2572,8 @@ static PyMethodDef libvirtMethods[] = {
|
|||||||
{(char *) "virConnectListSecrets", libvirt_virConnectListSecrets, METH_VARARGS, NULL},
|
{(char *) "virConnectListSecrets", libvirt_virConnectListSecrets, METH_VARARGS, NULL},
|
||||||
{(char *) "virSecretGetValue", libvirt_virSecretGetValue, METH_VARARGS, NULL},
|
{(char *) "virSecretGetValue", libvirt_virSecretGetValue, METH_VARARGS, NULL},
|
||||||
{(char *) "virSecretSetValue", libvirt_virSecretSetValue, 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}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user