The string version comparisons failed when determining if "0.10.2" was a greater version than "0.4.1" (and other similar checks). Needed to create a version comparison method that did the right thing. Also, not change to 12_create_netfs_storagevolume_errs.py to use "or" logic rather than "and" logic on comparison. Other tests within the family use "or" logic. --- .../08_CreateDiskResourcePool.py | 4 ++-- .../10_create_storagevolume.py | 6 ++++-- .../11_create_dir_storagevolume_errs.py | 5 +++-- .../12_create_netfs_storagevolume_errs.py | 5 +++-- .../13_delete_storagevolume.py | 5 +++-- .../14_delete_storagevolume_errs.py | 5 +++-- .../ResourcePoolConfigurationService/15_DiskPoolAutostart.py | 4 ++-- .../cimtest/SettingsDefineCapabilities/01_forward.py | 1 - .../VirtualSystemManagementService/19_definenetwork_ers.py | 8 ++++---- suites/libvirt-cim/lib/XenKvmLib/common_util.py | 9 +++++---- suites/libvirt-cim/lib/XenKvmLib/pool.py | 6 +++--- suites/libvirt-cim/lib/XenKvmLib/rasd.py | 10 ++++++---- suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py | 6 ++++++ 13 files changed, 44 insertions(+), 30 deletions(-) diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py index 636f59c..b5ec5dc 100644 --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py @@ -50,7 +50,7 @@ import sys import os from CimTest.Globals import logger -from XenKvmLib.xm_virt_util import virsh_version +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp from CimTest.ReturnCodes import FAIL, PASS, SKIP from XenKvmLib.const import do_main, platform_sup from XenKvmLib.classes import get_typed_class @@ -89,7 +89,7 @@ def main(): dp_types = { } libvirt_version = virsh_version(server, virt) - if libvirt_version < "0.4.1": + if virsh_version_cmp(libvirt_version, "0.4.1") < 0: logger.info("Storage pool creation support is available in Libvirt " "version >= 0.4.1 , hence skipping the test....") return SKIP diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/10_create_storagevolume.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/10_create_storagevolume.py index 511463b..3b0673f 100644 --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/10_create_storagevolume.py +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/10_create_storagevolume.py @@ -38,7 +38,8 @@ from XenKvmLib.rasd import libvirt_rasd_storagepool_changes from XenKvmLib import rpcs_service from XenKvmLib.assoc import Associators from XenKvmLib.enumclass import GetInstance, EnumNames -from XenKvmLib.xm_virt_util import virsh_version, vol_list, vol_delete +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp, \ + vol_list, vol_delete from XenKvmLib.classes import get_typed_class, inst_to_mof from XenKvmLib.common_util import destroy_diskpool from XenKvmLib.pool import create_pool, undefine_diskpool, DIR_POOL @@ -186,7 +187,8 @@ def main(): libvirt_ver = virsh_version(server, virt) cim_rev, changeset = get_provider_version(virt, server) - if libvirt_ver < "0.4.1" or cim_rev < libvirt_rasd_storagepool_changes: + if virsh_version_cmp(libvirt_ver, "0.4.1") < 0 or \ + cim_rev < libvirt_rasd_storagepool_changes: logger.info("Storage Volume creation support is available with Libvirt" "version >= 0.4.1 and Libvirt-CIM rev '%s'", libvirt_rasd_storagepool_changes) diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/11_create_dir_storagevolume_errs.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/11_create_dir_storagevolume_errs.py index 76e1e8f..318cfa8 100644 --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/11_create_dir_storagevolume_errs.py +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/11_create_dir_storagevolume_errs.py @@ -36,7 +36,7 @@ from CimTest.Globals import logger from XenKvmLib import rpcs_service from pywbem.cim_types import Uint64 from pywbem import CIM_ERR_FAILED, CIMError -from XenKvmLib.xm_virt_util import virsh_version +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp from CimTest.ReturnCodes import FAIL, PASS, SKIP from XenKvmLib.classes import get_typed_class, inst_to_mof from XenKvmLib.rasd import libvirt_rasd_storagepool_changes @@ -125,7 +125,8 @@ def main(): libvirt_ver = virsh_version(server, virt) cim_rev, changeset = get_provider_version(virt, server) - if libvirt_ver < "0.4.1" or cim_rev < libvirt_rasd_storagepool_changes: + if virsh_version_cmp(libvirt_ver, "0.4.1") < 0 or \ + cim_rev < libvirt_rasd_storagepool_changes: logger.info("Storage Volume creation support is available with Libvirt" "version >= 0.4.1 and Libvirt-CIM rev '%s'", libvirt_rasd_storagepool_changes) diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/12_create_netfs_storagevolume_errs.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/12_create_netfs_storagevolume_errs.py index 004af9f..215727f 100644 --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/12_create_netfs_storagevolume_errs.py +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/12_create_netfs_storagevolume_errs.py @@ -36,7 +36,7 @@ from CimTest.ReturnCodes import FAIL, PASS, SKIP from XenKvmLib.const import do_main, platform_sup, get_provider_version from XenKvmLib.rasd import libvirt_rasd_storagepool_changes from XenKvmLib import rpcs_service -from XenKvmLib.xm_virt_util import virsh_version +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp from XenKvmLib.classes import get_typed_class, inst_to_mof from XenKvmLib.common_util import nfs_netfs_setup, netfs_cleanup from XenKvmLib.pool import create_pool, NETFS_POOL, get_diskpool, \ @@ -123,7 +123,8 @@ def main(): libvirt_ver = virsh_version(server, virt) cim_rev, changeset = get_provider_version(virt, server) - if libvirt_ver < "0.4.1" and cim_rev < libvirt_rasd_storagepool_changes: + if virsh_version_cmp(libvirt_ver, "0.4.1") < 0 or \ + cim_rev < libvirt_rasd_storagepool_changes: logger.info("Storage Volume creation support is available with Libvirt" "version >= 0.4.1 and Libvirt-CIM rev '%s'", libvirt_rasd_storagepool_changes) diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/13_delete_storagevolume.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/13_delete_storagevolume.py index d7a6365..3578532 100644 --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/13_delete_storagevolume.py +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/13_delete_storagevolume.py @@ -29,7 +29,7 @@ import sys from CimTest.Globals import logger from CimTest.ReturnCodes import FAIL, PASS, SKIP -from XenKvmLib.xm_virt_util import virsh_version +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp from XenKvmLib.const import do_main, platform_sup, get_provider_version, \ default_pool_name, _image_dir from XenKvmLib import rpcs_service @@ -50,7 +50,8 @@ def main(): libvirt_ver = virsh_version(server, virt) cim_rev, changeset = get_provider_version(virt, server) - if libvirt_ver < "0.4.1" or cim_rev < libvirt_rasd_spool_del_changes: + if virsh_version_cmp(libvirt_ver, "0.4.1") < 0 or \ + cim_rev < libvirt_rasd_spool_del_changes: logger.info("Storage Volume deletion support is available with Libvirt" "version >= 0.4.1 and Libvirt-CIM rev '%s'", libvirt_rasd_spool_del_changes) diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/14_delete_storagevolume_errs.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/14_delete_storagevolume_errs.py index 9e33215..d7ed5ad 100644 --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/14_delete_storagevolume_errs.py +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/14_delete_storagevolume_errs.py @@ -33,7 +33,7 @@ from VirtLib import utils from CimTest.Globals import logger from pywbem import CIM_ERR_FAILED, CIM_ERR_INVALID_PARAMETER, CIMError from CimTest.ReturnCodes import FAIL, PASS, SKIP -from XenKvmLib.xm_virt_util import virsh_version +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp from XenKvmLib.const import do_main, platform_sup, get_provider_version,\ default_pool_name, _image_dir from XenKvmLib import rpcs_service @@ -119,7 +119,8 @@ def main(): libvirt_ver = virsh_version(server, virt) cim_rev, changeset = get_provider_version(virt, server) - if libvirt_ver < "0.4.1" or cim_rev < libvirt_rasd_spool_del_changes: + if virsh_version_cmp(libvirt_ver, "0.4.1") < 0 or \ + cim_rev < libvirt_rasd_spool_del_changes: logger.info("Storage Volume deletion support is available with Libvirt" "version >= 0.4.1 and Libvirt-CIM rev '%s'", libvirt_rasd_spool_del_changes) diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py index b7e72a8..3cf6321 100644 --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py @@ -26,7 +26,7 @@ import sys import os from pywbem import cim_types from CimTest.Globals import logger -from XenKvmLib.xm_virt_util import virsh_version +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp from CimTest.ReturnCodes import FAIL, PASS, SKIP from XenKvmLib.const import do_main, platform_sup from XenKvmLib.classes import get_typed_class @@ -62,7 +62,7 @@ def main(): dp_types = { } libvirt_version = virsh_version(server, virt) - if libvirt_version < "0.4.1": + if virsh_version_cmp(libvirt_version, "0.4.1") < 0: logger.info("Storage pool creation support is available in Libvirt " "version >= 0.4.1 , hence skipping the test....") return SKIP diff --git a/suites/libvirt-cim/cimtest/SettingsDefineCapabilities/01_forward.py b/suites/libvirt-cim/cimtest/SettingsDefineCapabilities/01_forward.py index 555e3c1..dd19ca0 100644 --- a/suites/libvirt-cim/cimtest/SettingsDefineCapabilities/01_forward.py +++ b/suites/libvirt-cim/cimtest/SettingsDefineCapabilities/01_forward.py @@ -57,7 +57,6 @@ import os from distutils.file_util import move_file from XenKvmLib import assoc from XenKvmLib import enumclass -from XenKvmLib.xm_virt_util import virsh_version from CimTest.ReturnCodes import PASS, FAIL, SKIP from CimTest.Globals import logger, CIM_ERROR_GETINSTANCE, \ CIM_ERROR_ASSOCIATORS diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py index cf461d1..19294db 100644 --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py @@ -33,7 +33,7 @@ from CimTest.Globals import logger from CimTest.ReturnCodes import FAIL, PASS from XenKvmLib.const import default_network_name, do_main, get_provider_version from XenKvmLib.common_util import create_netpool_conf, destroy_netpool -from XenKvmLib.xm_virt_util import virsh_version +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp sup_types = ['Xen', 'KVM', 'XenFV'] default_dom = 'brgtest_domain' @@ -71,7 +71,7 @@ def main(): libvirt_version = virsh_version(options.ip, options.virt) inv_empty_network = "Network not found" if options.virt == "Xen" or options.virt == "XenFV": - if libvirt_version <= "0.3.3": + if virsh_version_cmp(libvirt_version, "0.3.3") <= 0: inv_empty_network = "no network with matching name" inv_br_str = "POST operation failed: (xend.err 'Device 0 (vif) " + \ @@ -89,10 +89,10 @@ def main(): expected_values['invalid']['bridge'] = inv_br_str else: - if libvirt_version >= "0.7.0": + if virsh_version_cmp(libvirt_version, "0.7.0") >= 0: expected_values['empty']['network'] = inv_empty_network expected_values['invalid']['network'] = inv_empty_network - if libvirt_version >= "0.9.8": + if virsh_version_cmp(libvirt_version, "0.9.8") >= 0: expected_values['invalid']['bridge'] = "Cannot get interface "\ "MTU on 'invalid'" else: diff --git a/suites/libvirt-cim/lib/XenKvmLib/common_util.py b/suites/libvirt-cim/lib/XenKvmLib/common_util.py index 43e5e2c..53fb14f 100644 --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py @@ -38,7 +38,8 @@ from XenKvmLib.classes import get_typed_class from CimTest.Globals import logger, CIM_ERROR_ENUMERATE, \ CIM_ERROR_GETINSTANCE from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC, SKIP -from XenKvmLib.xm_virt_util import diskpool_list, virsh_version, net_list,\ +from XenKvmLib.xm_virt_util import diskpool_list, virsh_version,\ + virsh_version_cmp, net_list,\ domain_list, virt2uri, net_destroy from XenKvmLib.vxml import PoolXML, NetXML from VirtLib import utils @@ -308,7 +309,7 @@ def cleanup_restore(server, virt): # libvirt_version >= 0.4.1 # Hence Skipping the logic to delete the new conf file # and just returning PASS - if libvirt_version >= '0.4.1': + if virsh_version_cmp(libvirt_version, '0.4.1') >= 0: return status try: if os.path.exists(back_disk_file): @@ -365,7 +366,7 @@ def create_diskpool(server, virt='KVM', dpool=default_pool_name, def create_diskpool_conf(server, virt, dpool=default_pool_name): libvirt_version = virsh_version(server, virt) - if libvirt_version >= '0.4.1': + if virsh_version_cmp(libvirt_version, '0.4.1') >= 0: status, dpoolname = create_diskpool(server, virt, dpool) diskid = "%s/%s" % ("DiskPool", dpoolname) else: @@ -376,7 +377,7 @@ def create_diskpool_conf(server, virt, dpool=default_pool_name): def destroy_diskpool(server, virt, dpool): libvirt_version = virsh_version(server, virt) - if libvirt_version >= '0.4.1': + if virsh_version_cmp(libvirt_version, '0.4.1') >= 0: if dpool == None: logger.error("No disk pool specified") return FAIL diff --git a/suites/libvirt-cim/lib/XenKvmLib/pool.py b/suites/libvirt-cim/lib/XenKvmLib/pool.py index a5ca331..1a57aba 100644 --- a/suites/libvirt-cim/lib/XenKvmLib/pool.py +++ b/suites/libvirt-cim/lib/XenKvmLib/pool.py @@ -35,7 +35,7 @@ from XenKvmLib import rpcs_service import pywbem from CimTest.CimExt import CIMClassMOF from XenKvmLib.vxml import NetXML, PoolXML -from XenKvmLib.xm_virt_util import virsh_version +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp from XenKvmLib.vsms import RASD_TYPE_STOREVOL from XenKvmLib.common_util import destroy_diskpool @@ -183,7 +183,7 @@ def undefine_netpool(server, virt, net_name): def undefine_diskpool(server, virt, dp_name): libvirt_version = virsh_version(server, virt) - if libvirt_version >= '0.4.1': + if virsh_version_cmp(libvirt_version, '0.4.1') >= 0: if dp_name == None: return FAIL @@ -285,7 +285,7 @@ def verify_pool(server, virt, poolname, pool_attr_list, mode_type=0, ret_mode = net_xml.xml_get_netpool_mode() libvirt_version = virsh_version(server, virt) #Forward mode support was added in 0.4.2 - if libvirt_version >= '0.4.2': + if virsh_version_cmp(libvirt_version, '0.4.2') >= 0: if mode_type == 1 and ret_mode != "nat": logger.error("Error when verifying 'nat' type network") return FAIL diff --git a/suites/libvirt-cim/lib/XenKvmLib/rasd.py b/suites/libvirt-cim/lib/XenKvmLib/rasd.py index d65011e..4d4240a 100644 --- a/suites/libvirt-cim/lib/XenKvmLib/rasd.py +++ b/suites/libvirt-cim/lib/XenKvmLib/rasd.py @@ -31,7 +31,7 @@ from XenKvmLib.assoc import Associators from XenKvmLib.const import default_pool_name, default_network_name, \ get_provider_version, default_net_type from XenKvmLib.pool import enum_volumes -from XenKvmLib.xm_virt_util import virsh_version +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp from XenKvmLib.common_util import parse_instance_id pasd_cn = 'ProcResourceAllocationSettingData' @@ -81,7 +81,8 @@ def rasd_init_list(vsxml, virt, t_disk, t_dom, t_mac, t_mem, server): libvirt_version = virsh_version(server, virt) - if virt == 'LXC' or (virt == 'XenFV' and libvirt_version < "0.6.3"): + if virt == 'LXC' or (virt == 'XenFV' and \ + virsh_version_cmp(libvirt_version, "0.6.3") < 0): point_device = "%s/%s" %(t_dom, "mouse:usb") elif virt == 'Xen': point_device = "%s/%s" %(t_dom, "mouse:xen") @@ -357,7 +358,8 @@ def get_exp_disk_rasd_len(virt, ip, rev, id): rev < libvirt_rasd_new_changes: exp_len = exp_base_num + exp_cdrom - elif rev >= libvirt_rasd_dpool_changes and libvirt_ver >= '0.4.1': + elif rev >= libvirt_rasd_dpool_changes and \ + virsh_version_cmp(libvirt_ver, '0.4.1') >= 0: volumes = enum_volumes(virt, ip) if rev >= libvirt_rasd_floppy_changes: exp_len = ((volumes * exp_base_num) + \ @@ -383,7 +385,7 @@ def get_exp_disk_rasd_len(virt, ip, rev, id): exp_len = (volumes * exp_base_num) + exp_cdrom - if virt != 'LXC' and libvirt_ver >= '0.4.1': + if virt != 'LXC' and virsh_version_cmp(libvirt_ver, '0.4.1') >= 0: if rev >= libvirt_rasd_storagepool_changes: exp_len += exp_storagevol_rasd diff --git a/suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py b/suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py index f365a54..7749fb7 100644 --- a/suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py +++ b/suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py @@ -23,6 +23,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # import os +import re from VirtLib import utils import socket from VirtLib.live import fv_cap @@ -223,6 +224,11 @@ def network_by_bridge(bridge, server, virt="Xen"): return None +def virsh_version_cmp(version1, version2): + def normalize(v): + return [int(x) for x in re.sub(r'(\.0+)*$','', v).split(".")] + return cmp(normalize(version1), normalize(version2)) + def virsh_version(server, virt="KVM"): cmd = "virsh -c %s -v 2>/dev/null" % virt2uri(virt) ret, out = utils.run_remote(server, cmd) -- 1.8.1.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list