summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Denemark <jdenemar@redhat.com>2011-04-22 13:31:35 +0200
committerJiri Denemark <jdenemar@redhat.com>2011-05-16 10:04:18 +0200
commita35962b1af2077e18b93966b903d9061779f1ff7 (patch)
tree5c9a8a510c95bdb9af13cd96b1f896ffbfa580a1
parent0aa2b90fc0a9975221ae8f8e94df61bb788877bc (diff)
downloadlibvirt-python-v6-a35962b1af2077e18b93966b903d9061779f1ff7.tar.gz
libvirt-python-v6-a35962b1af2077e18b93966b903d9061779f1ff7.tar.xz
libvirt-python-v6-a35962b1af2077e18b93966b903d9061779f1ff7.zip
virDomainGetState public API
This API is supposed to replace virDomainGetInfo when the only purpose of calling it is getting current domain status.
-rwxr-xr-xgenerator.py1
-rw-r--r--libvirt-override-api.xml6
-rw-r--r--libvirt-override.c30
3 files changed, 37 insertions, 0 deletions
diff --git a/generator.py b/generator.py
index 4fa4f65..b395caf 100755
--- a/generator.py
+++ b/generator.py
@@ -293,6 +293,7 @@ skip_impl = (
'virConnGetLastError',
'virGetLastError',
'virDomainGetInfo',
+ 'virDomainGetState',
'virDomainGetBlockInfo',
'virDomainGetJobInfo',
'virNodeGetInfo',
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index 54deeb5..ec08e69 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -48,6 +48,12 @@
<return type='int *' info='the list of information or None in case of error'/>
<arg name='domain' type='virDomainPtr' info='a domain object'/>
</function>
+ <function name='virDomainGetState' file='python'>
+ <info>Extract domain state.</info>
+ <return type='int *' info='the list containing state and reason or None in case of error'/>
+ <arg name='domain' type='virDomainPtr' info='a domain object'/>
+ <arg name='flags' type='unsigned int' info='additional flags'/>
+ </function>
<function name='virDomainGetBlockInfo' file='python'>
<info>Extract information about a domain block device size</info>
<return type='int *' info='the list of information or None in case of error'/>
diff --git a/libvirt-override.c b/libvirt-override.c
index 4a9b432..11e1d0c 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -1068,6 +1068,35 @@ libvirt_virDomainGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
}
static PyObject *
+libvirt_virDomainGetState(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
+{
+ PyObject *py_retval;
+ int c_retval;
+ virDomainPtr domain;
+ PyObject *pyobj_domain;
+ int state;
+ int reason;
+ unsigned int flags;
+
+ if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetState",
+ &pyobj_domain, &flags))
+ return NULL;
+
+ domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_retval = virDomainGetState(domain, &state, &reason, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+ if (c_retval < 0)
+ return VIR_PY_NONE;
+
+ py_retval = PyList_New(2);
+ PyList_SetItem(py_retval, 0, libvirt_intWrap(state));
+ PyList_SetItem(py_retval, 1, libvirt_intWrap(reason));
+ return py_retval;
+}
+
+static PyObject *
libvirt_virDomainGetBlockInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
PyObject *py_retval;
int c_retval;
@@ -3527,6 +3556,7 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virConnectDomainEventRegisterAny", libvirt_virConnectDomainEventRegisterAny, METH_VARARGS, NULL},
{(char *) "virConnectDomainEventDeregisterAny", libvirt_virConnectDomainEventDeregisterAny, METH_VARARGS, NULL},
{(char *) "virDomainGetInfo", libvirt_virDomainGetInfo, METH_VARARGS, NULL},
+ {(char *) "virDomainGetState", libvirt_virDomainGetState, METH_VARARGS, NULL},
{(char *) "virDomainGetBlockInfo", libvirt_virDomainGetBlockInfo, METH_VARARGS, NULL},
{(char *) "virNodeGetInfo", libvirt_virNodeGetInfo, METH_VARARGS, NULL},
{(char *) "virDomainGetUUID", libvirt_virDomainGetUUID, METH_VARARGS, NULL},