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

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Tue Jan 28 20:29:38 UTC 2014


On 01/25/2014 08:27 PM, Aline Manera wrote:
> On 01/23/2014 10:29 PM, Rodrigo Trujillo wrote:
>> 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)
>
> Please, don't compare versions
> Create a feature test to check libvirt has or not support for what you 
> want.
>
>
I don't agree, but its ok.
ACK

> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>




More information about the Kimchi-devel mailing list