[Kimchi-devel] [PATCH V2 2/7] (WIP) Storagepool SCSI/FC: Function to check libvirt version

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Fri Jan 24 00:29:55 UTC 2014


As Kimchi supports a large range of Linux distributions and libvirt
versions may differ. Libvirt functionalities may not be available,
what requires different implementations of kimchi code. This patch
implements a function to help identify libvirt version.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
 src/kimchi/utils.py | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/kimchi/utils.py b/src/kimchi/utils.py
index c7ececf..0475eda 100644
--- a/src/kimchi/utils.py
+++ b/src/kimchi/utils.py
@@ -28,11 +28,12 @@ import urllib2
 
 
 from cherrypy.lib.reprconf import Parser
-from kimchi.exception import TimeoutExpired
+from libvirt import getVersion
+from threading import Timer
 
 
 from kimchi import config
-from threading import Timer
+from kimchi.exception import TimeoutExpired
 
 
 kimchi_log = cherrypy.log.error_log
@@ -178,3 +179,16 @@ def patch_find_nfs_target(nfs_server):
         target['type'] = 'nfs'
         target['host_name'] = nfs_server
     return targets
+
+
+def is_libvirt_version_lesser(version):
+    """
+    Receives an string as version (ex: '0.7.1' or '1.1.2') and compares with
+    system libvirt version.
+    Returns booleanr: True if libvirt version lesser than given version
+                      False if libvirt version is greater or equal
+    """
+    # Versions numbers are integers: 1000000*major + 1000*minor + release
+    ver = version.split('.')
+    test_version = 1000000*int(ver[0]) + 1000*int(ver[1]) + int(ver[2])
+    return (cmp(getVersion(), test_version) < 0)
-- 
1.8.4.2




More information about the Kimchi-devel mailing list