[Kimchi-devel] [PATCH 2/3] (WIP) Storagepool SCSI/FC: Function to check libvirt version
Rodrigo Trujillo
rodrigo.trujillo at linux.vnet.ibm.com
Fri Jan 10 17:34:41 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 | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/kimchi/utils.py b/src/kimchi/utils.py
index af245c6..64edc1c 100644
--- a/src/kimchi/utils.py
+++ b/src/kimchi/utils.py
@@ -27,6 +27,7 @@ import urllib2
from cherrypy.lib.reprconf import Parser
+from libvirt import getVersion
from kimchi import config
@@ -96,3 +97,16 @@ def check_url_path(path):
return False
return True
+
+
+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.1.4
More information about the Kimchi-devel
mailing list