]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
+Tue May 29 15:56:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
authorRichard W.M. Jones <rjones@redhat.com>
Tue, 29 May 2007 14:58:27 +0000 (14:58 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Tue, 29 May 2007 14:58:27 +0000 (14:58 +0000)
+
+       * python/generator.py, python/libvir.c, python/libvir.py:
+         Wrap the virGetVersion call as Python libvirt.getVersion.
+
+       * src/libvirt.c: Change virGetVersion so that the driver name
+         is case insensitive.
+

ChangeLog
python/generator.py
python/libvir.c
python/libvir.py
src/libvirt.c

index c6d1674a0ebaac8b0624efda47ffe2108c560b1a..22a2a51617bdec9a595896a64a89db0734e1d5ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Tue May 29 15:56:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
+
+       * python/generator.py, python/libvir.c, python/libvir.py:
+         Wrap the virGetVersion call as Python libvirt.getVersion.
+
+       * src/libvirt.c: Change virGetVersion so that the driver name
+         is case insensitive.
+
 Tue May 29 15:41:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
 
        * TODO: Added a note about requiring C++ compiler because of a
index c3c79dc2cf3ded663f5924e21ae0b4971dd176a0..3dc321234d5ed9ab59cde0c7d7a78ca59fd28433 100755 (executable)
@@ -287,6 +287,8 @@ def skip_function(name):
         return 1
     if name == "vshRunConsole":
         return 1
+    if name == "virGetVersion":
+        return 1
     return 0
 
 def print_function_wrapper(name, output, export, include):
index 82341b8a2bfa117abf01f3270eea7ccb412afdf5..f1281f19db901155fe38d9e7460d89181dc27c6a 100644 (file)
@@ -178,6 +178,36 @@ libvirt_virRegisterErrorHandler(ATTRIBUTE_UNUSED PyObject * self,
  *                                                                     *
  ************************************************************************/
 
+static PyObject *
+libvirt_virGetVersion (PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
+{
+    char *type = NULL;
+    unsigned long libVer, typeVer = 0;
+    int c_retval;
+
+    if (!PyArg_ParseTuple (args, (char *) "|s", &type))
+        return NULL;
+
+    LIBVIRT_BEGIN_ALLOW_THREADS;
+
+    if (type == NULL)
+        c_retval = virGetVersion (&libVer, NULL, NULL);
+    else
+        c_retval = virGetVersion (&libVer, type, &typeVer);
+
+    LIBVIRT_END_ALLOW_THREADS;
+
+    if (c_retval == -1) {
+        Py_INCREF(Py_None);
+        return (Py_None);
+    }
+
+    if (type == NULL)
+        return PyInt_FromLong (libVer);
+    else
+        return Py_BuildValue ((char *) "kk", libVer, typeVer);
+}
+
 static PyObject *
 libvirt_virDomainFree(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
     PyObject *py_retval;
@@ -628,6 +658,7 @@ libvirt_virNetworkGetAutostart(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
  ************************************************************************/
 static PyMethodDef libvirtMethods[] = {
 #include "libvirt-export.c"
+    {(char *) "virGetVersion", libvirt_virGetVersion, METH_VARARGS, NULL},
     {(char *) "virDomainFree", libvirt_virDomainFree, METH_VARARGS, NULL},
     {(char *) "virConnectClose", libvirt_virConnectClose, METH_VARARGS, NULL},
     {(char *) "virConnectListDomainsID", libvirt_virConnectListDomainsID, METH_VARARGS, NULL},
@@ -664,3 +695,17 @@ initlibvirtmod(void)
 
     initialized = 1;
 }
+
+/*
+ * vim: set tabstop=4:
+ * vim: set shiftwidth=4:
+ * vim: set expandtab:
+ */
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
index e1c4ff3feebbc2c744160fbad47ecde124b57fe5..e108b3a98dd1f4895da04fc74f67fc36201ec84f 100644 (file)
@@ -83,6 +83,29 @@ def registerErrorHandler(f, ctx):
        Returns 1 in case of success."""
     return libvirtmod.virRegisterErrorHandler(f,ctx)
 
+#
+# Return library version.
+#
+def getVersion (name = None):
+    """If no name parameter is passed (or name is None) then the
+    version of the libvirt library is returned as an integer.
+
+    If a name is passed and it refers to a driver linked to the
+    libvirt library, then this returns a tuple of (library version,
+    driver version).
+
+    If the name passed refers to a non-existent driver, then you
+    will get the exception 'no support for hypervisor'.
+
+    Versions numbers are integers: 1000000*major + 1000*minor + release."""
+    if name is None:
+        ret = libvirtmod.virGetVersion ();
+    else:
+        ret = libvirtmod.virGetVersion (name);
+    if ret is None: raise libvirtError ("virGetVersion() failed")
+    return ret
+
+
 # WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
 #
 # Everything before this line comes from libvir.py
index b1c3d39d9582e85b0d81cb3227d244840b927182..9918a9166a0f69996bb2a30d5832cfbbb0f6e597 100644 (file)
@@ -249,7 +249,7 @@ virGetVersion(unsigned long *libVer, const char *type,
            type = "Xen";
        for (i = 0;i < virDriverTabCount;i++) {
            if ((virDriverTab[i] != NULL) &&
-               (!strcmp(virDriverTab[i]->name, type))) {
+               (!strcasecmp(virDriverTab[i]->name, type))) {
                *typeVer = virDriverTab[i]->ver;
                break;
            }