From 300aa2d3f92c981cd8df9ccc0546b93251d796cf Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Wed, 29 Mar 2006 12:46:03 +0000 Subject: * include/libvirt.h[.in] include/virterror.h src/driver.h src/internal.h src/libvirt_sym.version src/xen_internal.c src/xs_internal.c: added a new entry point to get node hardware informations virGetNodeInfo, and associated driver hook. * src/xend_internal.c: implemented the node and version information hooks for the Xen Daemon * python/libvir.c python/libvirt-python-api.xml python/generator.py: also added Python bindings for the new call Daniel --- generator.py | 4 ++++ libvir.c | 30 ++++++++++++++++++++++++++++++ libvirt-python-api.xml | 11 ++++++++--- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/generator.py b/generator.py index af44cae..497f3b4 100755 --- a/generator.py +++ b/generator.py @@ -261,6 +261,7 @@ foreign_encoding_args = ( skip_impl = ( 'virConnectListDomainsID', 'virDomainGetInfo', + 'virNodeGetInfo', 'virDomainGetUUID', 'virDomainLookupByUUID', ) @@ -562,6 +563,9 @@ def nameFixup(name, classe, type, file): elif name[0:9] == "virDomain": func = name[9:] func = string.lower(func[0:1]) + func[1:] + elif name[0:7] == "virNode": + func = name[7:] + func = string.lower(func[0:1]) + func[1:] elif name[0:10] == "virConnect": func = name[10:] func = string.lower(func[0:1]) + func[1:] diff --git a/libvir.c b/libvir.c index 1d97037..ede3949 100644 --- a/libvir.c +++ b/libvir.c @@ -197,6 +197,35 @@ libvirt_virDomainGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { return(py_retval); } +static PyObject * +libvirt_virNodeGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { + PyObject *py_retval; + int c_retval; + virConnectPtr conn; + PyObject *pyobj_conn; + virNodeInfo info; + + if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetInfo", &pyobj_conn)) + return(NULL); + conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn); + + c_retval = virNodeGetInfo(conn, &info); + if (c_retval < 0) { + Py_INCREF(Py_None); + return(Py_None); + } + py_retval = PyList_New(8); + PyList_SetItem(py_retval, 0, libvirt_charPtrWrap(&info.model[0])); + PyList_SetItem(py_retval, 1, libvirt_longWrap((long) info.memory)); + PyList_SetItem(py_retval, 2, libvirt_intWrap((int) info.cpus)); + PyList_SetItem(py_retval, 3, libvirt_intWrap((int) info.mhz)); + PyList_SetItem(py_retval, 4, libvirt_intWrap((int) info.nodes)); + PyList_SetItem(py_retval, 5, libvirt_intWrap((int) info.sockets)); + PyList_SetItem(py_retval, 6, libvirt_intWrap((int) info.cores)); + PyList_SetItem(py_retval, 7, libvirt_intWrap((int) info.threads)); + return(py_retval); +} + PyObject * libvirt_virDomainGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { PyObject *py_retval; @@ -255,6 +284,7 @@ static PyMethodDef libvirtMethods[] = { {(char *) "virConnectClose", libvirt_virConnectClose, METH_VARARGS, NULL}, {(char *) "virConnectListDomainsID", libvirt_virConnectListDomainsID, METH_VARARGS, NULL}, {(char *) "virDomainGetInfo", libvirt_virDomainGetInfo, METH_VARARGS, NULL}, + {(char *) "virNodeGetInfo", libvirt_virNodeGetInfo, METH_VARARGS, NULL}, {(char *) "virDomainGetUUID", libvirt_virDomainGetUUID, METH_VARARGS, NULL}, {(char *) "virDomainLookupByUUID", libvirt_virDomainLookupByUUID, METH_VARARGS, NULL}, {(char *) "virRegisterErrorHandler", libvirt_virRegisterErrorHandler, METH_VARARGS, NULL}, diff --git a/libvirt-python-api.xml b/libvirt-python-api.xml index 3b75525..302ba02 100644 --- a/libvirt-python-api.xml +++ b/libvirt-python-api.xml @@ -12,12 +12,17 @@ - - Extract information about a domain. Note that if the connection used to get the domain is limited only a partial set of the informations can be extracted. + + Extract informations about a domain. Note that if the connection used to get the domain is limited only a partial set of the informations can be extracted. - + + Extract hardware informations about the Node. + + + + Extract the UUID unique Identifier of a domain. -- cgit