summaryrefslogtreecommitdiffstats
path: root/libvir.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@redhat.com>2006-01-31 10:24:12 +0000
committerDaniel Veillard <veillard@redhat.com>2006-01-31 10:24:12 +0000
commitfb54944e588be376fcd3fc9e01d8592a86731c41 (patch)
treefb429f11ee08c69237125a2330e00cfb139c10d0 /libvir.c
parent0955d746e83c9af235aec6f4c2cb568e6ab4f1ac (diff)
downloadlibvirt-python-v6-fb54944e588be376fcd3fc9e01d8592a86731c41.tar.gz
libvirt-python-v6-fb54944e588be376fcd3fc9e01d8592a86731c41.tar.xz
libvirt-python-v6-fb54944e588be376fcd3fc9e01d8592a86731c41.zip
* python/*: update of the python bindings, fix names, add
missing features like list of domains and domain info extraction Daniel
Diffstat (limited to 'libvir.c')
-rw-r--r--libvir.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/libvir.c b/libvir.c
index 2f18660..5956fdd 100644
--- a/libvir.c
+++ b/libvir.c
@@ -48,6 +48,58 @@ libvir_virConnectClose(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
return(py_retval);
}
+static PyObject *
+libvir_virConnectListDomainsID(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args) {
+ PyObject *py_retval;
+ int ids[500], 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 = virConnectListDomains(conn, &ids[0], 500);
+ if (c_retval < 0) {
+ Py_INCREF(Py_None);
+ return(Py_None);
+ }
+ py_retval = PyList_New(c_retval);
+ for (i = 0;i < c_retval;i++) {
+ PyList_SetItem(py_retval, i, libvir_intWrap(ids[i]));
+ }
+ return(py_retval);
+}
+
+static PyObject *
+libvir_virDomainGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
+ PyObject *py_retval;
+ int c_retval;
+ virDomainPtr domain;
+ PyObject *pyobj_domain;
+ virDomainInfo info;
+
+ if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetInfo", &pyobj_domain))
+ return(NULL);
+ domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+ c_retval = virDomainGetInfo(domain, &info);
+ if (c_retval < 0) {
+ Py_INCREF(Py_None);
+ return(Py_None);
+ }
+ py_retval = PyList_New(5);
+ PyList_SetItem(py_retval, 0, libvir_intWrap((int) info.state));
+ PyList_SetItem(py_retval, 1, libvir_longWrap((long) info.maxMem));
+ PyList_SetItem(py_retval, 2, libvir_longWrap((long) info.memory));
+ PyList_SetItem(py_retval, 3, libvir_intWrap((int) info.nrVirtCpu));
+ PyList_SetItem(py_retval, 4,
+ libvir_longlongWrap((unsigned long long) info.cpuTime));
+ return(py_retval);
+}
+
/************************************************************************
* *
* The registration stuff *
@@ -57,6 +109,8 @@ static PyMethodDef libvirMethods[] = {
#include "libvir-export.c"
{(char *) "virDomainFree", libvir_virDomainFree, METH_VARARGS, NULL},
{(char *) "virConnectClose", libvir_virConnectClose, METH_VARARGS, NULL},
+ {(char *) "virConnectListDomainsID", libvir_virConnectListDomainsID, METH_VARARGS, NULL},
+ {(char *) "virDomainGetInfo", libvir_virDomainGetInfo, METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
};