Added binding for virConnectListDefinedDomains api

This commit is contained in:
Daniel P. Berrange 2006-11-16 00:17:10 +00:00
parent 18035eddd3
commit a26b33cb15
4 changed files with 58 additions and 0 deletions

View File

@ -1,3 +1,8 @@
Wed Nov 15 18:23:13 EST 2006 Daniel Berrange <berrange@redhat.com>
* python/generator.py, python/libvir.c, python/libvirt-python-api.xml:
Added binding for virConnectListDefinedDomains API.
Wed Nov 15 15:08:13 EST 2006 Daniel Berrange <berrange@redhat.com>
* src/xen_internal.c, src/xs_internal.c, src/xend_internal.c,

View File

@ -260,6 +260,7 @@ foreign_encoding_args = (
# code is still automatically generated (so they are not in skip_function()).
skip_impl = (
'virConnectListDomainsID',
'virConnectListDefinedDomains',
'virConnGetLastError',
'virGetLastError',
'virDomainGetInfo',

View File

@ -240,6 +240,52 @@ libvirt_virConnectListDomainsID(PyObject *self ATTRIBUTE_UNUSED,
return(py_retval);
}
static PyObject *
libvirt_virConnectListDefinedDomains(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:virConnectListDomains", &pyobj_conn))
return(NULL);
conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
c_retval = virConnectNumOfDefinedDomains(conn);
if (c_retval < 0) {
Py_INCREF(Py_None);
return (Py_None);
}
if (c_retval) {
names = malloc(sizeof(char *) * c_retval);
if (!names) {
Py_INCREF(Py_None);
return (Py_None);
}
c_retval = virConnectListDefinedDomains(conn, (const char **)names, c_retval);
if (c_retval < 0) {
free(names);
Py_INCREF(Py_None);
return(Py_None);
}
}
py_retval = PyList_New(c_retval);
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_virDomainGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
PyObject *py_retval;
@ -364,6 +410,7 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virDomainFree", libvirt_virDomainFree, METH_VARARGS, NULL},
{(char *) "virConnectClose", libvirt_virConnectClose, METH_VARARGS, NULL},
{(char *) "virConnectListDomainsID", libvirt_virConnectListDomainsID, METH_VARARGS, NULL},
{(char *) "virConnectListDefinedDomains", libvirt_virConnectListDefinedDomains, METH_VARARGS, NULL},
{(char *) "virDomainGetInfo", libvirt_virDomainGetInfo, METH_VARARGS, NULL},
{(char *) "virNodeGetInfo", libvirt_virNodeGetInfo, METH_VARARGS, NULL},
{(char *) "virDomainGetUUID", libvirt_virDomainGetUUID, METH_VARARGS, NULL},

View File

@ -6,6 +6,11 @@
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
<return type='int *' info="the list of ID or None in case of error"/>
</function>
<function name='virConnectListDefinedDomains' file='python'>
<info>list the defined domains, 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='virDomainLookupByUUID' file='python'>
<info>Try to lookup a domain on the given hypervisor based on its UUID.</info>
<return type='virDomainPtr' info='a new domain object or NULL in case of failure'/>