[PATCH 0 of 5] [TEST] #3 Added tc to verify StorageVol deletion and creation/deletion errors

Please base this patch on the patch "Modifying common_util.py for netnfs"

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1253106314 25200 # Node ID 741c93090d6f7cffadc7684563590282b073149d # Parent d35d1a2956a81c7798712ec3b6d4a3906c75e480 [TEST] #4 Modified pool.py to support RPCS CreateResourceInPool. Patch 4: -------- 1) Moved cleanup_pool_vol() to pool.py as it referenced by couple of tests PS: will update RPCS/10*py to reference cleanup_pool_vol() from pool.py once these patches get accepted. Patch 3: -------- 1) Moved get_sto_vol_rasd() to pool.py as get_sto_vol_rasd_for_pool(), since it is used in RPCS/13*py and RPCS/14*py Patch 2: ------- 1) Added check in get_stovol_rasd_from_sdc() 2) Added get_diskpool() to pool.py as it is used in 10*py/11*py, RPCS/12*py and will be useful for further tests as well 3) Added rev for storagevol deletion NOTE: Please base this patch on the patch "Modifying common_util.py for netnfs" Patch 1: -------- Added the following two functions which are used in RPCS/10*py and RPCS/11*py 1) get_stovol_rasd_from_sdc() to get the stovol rasd from sdc 2) get_stovol_default_settings() to get default sto vol settings Also, modified common_util.py to remove the backed up exportfs file Added RAW_VOL_TYPE which is the FormatType supported by RPCS currently Once this patch gets accepted we can modify RPCS/10*py to refer to these functions. Tested with KVM and current sources on SLES11. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r d35d1a2956a8 -r 741c93090d6f suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Wed Sep 16 06:05:10 2009 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Wed Sep 16 06:05:14 2009 -0700 @@ -582,6 +582,8 @@ try: # Backup the original exports file. if (os.path.exists(exports_file)): + if os.path.exists(back_exports_file): + os.remove(back_exports_file) move_file(exports_file, back_exports_file) fd = open(exports_file, "w") line = "\n %s %s(rw)" %(src_dir_for_mnt, server) diff -r d35d1a2956a8 -r 741c93090d6f suites/libvirt-cim/lib/XenKvmLib/pool.py --- a/suites/libvirt-cim/lib/XenKvmLib/pool.py Wed Sep 16 06:05:10 2009 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/pool.py Wed Sep 16 06:05:14 2009 -0700 @@ -21,11 +21,13 @@ # import sys +import os +from VirtLib import utils from CimTest.Globals import logger, CIM_NS from CimTest.ReturnCodes import PASS, FAIL, SKIP from XenKvmLib.classes import get_typed_class, inst_to_mof from XenKvmLib.const import get_provider_version, default_pool_name -from XenKvmLib.enumclass import EnumInstances, GetInstance +from XenKvmLib.enumclass import EnumInstances, GetInstance, EnumNames from XenKvmLib.assoc import Associators from VirtLib.utils import run_remote from XenKvmLib.xm_virt_util import virt2uri, net_list @@ -34,11 +36,14 @@ from CimTest.CimExt import CIMClassMOF from XenKvmLib.vxml import NetXML, PoolXML from XenKvmLib.xm_virt_util import virsh_version +from XenKvmLib.vsms import RASD_TYPE_STOREVOL +from XenKvmLib.common_util import destroy_diskpool cim_errno = pywbem.CIM_ERR_NOT_SUPPORTED cim_mname = "CreateChildResourcePool" input_graphics_pool_rev = 757 libvirt_cim_child_pool_rev = 837 +libvirt_rasd_spool_del_changes = 971 DIR_POOL = 1L FS_POOL = 2L @@ -48,6 +53,9 @@ LOGICAL_POOL = 6L SCSI_POOL = 7L +#Volume types +RAW_VOL_TYPE = 1 + def pool_cn_to_rasd_cn(pool_cn, virt): if pool_cn.find('ProcessorPool') >= 0: return get_typed_class(virt, "ProcResourceAllocationSettingData") @@ -297,3 +305,100 @@ status = PASS return status + +def get_stovol_rasd_from_sdc(virt, server, dp_inst_id): + rasd = None + ac_cn = get_typed_class(virt, "AllocationCapabilities") + an_cn = get_typed_class(virt, "SettingsDefineCapabilities") + key_list = {"InstanceID" : dp_inst_id} + + try: + inst = GetInstance(server, ac_cn, key_list) + if inst == None: + raise Exception("Failed to GetInstance for %s" % dp_inst_id) + + rasd = Associators(server, an_cn, ac_cn, InstanceID=inst.InstanceID) + if len(rasd) < 4: + raise Exception("Failed to get default StorageVolRASD , "\ + "Expected atleast 4, Got '%s'" % len(rasd)) + + except Exception, detail: + logger.error("Exception: %s", detail) + return FAIL, None + + return PASS, rasd + +def get_stovol_default_settings(virt, server, dp_cn, + pool_name, path, vol_name): + + dp_inst_id = "%s/%s" % (dp_cn, pool_name) + status, dp_rasds = get_stovol_rasd_from_sdc(virt, server, dp_inst_id) + if status != PASS: + logger.error("Failed to get the StorageVol RASD's") + return None + + for dpool_rasd in dp_rasds: + if dpool_rasd['ResourceType'] == RASD_TYPE_STOREVOL and \ + 'Default' in dpool_rasd['InstanceID']: + + dpool_rasd['PoolID'] = dp_inst_id + dpool_rasd['Path'] = path + dpool_rasd['VolumeName'] = vol_name + break + + if not pool_name in dpool_rasd['PoolID']: + return None + + return dpool_rasd + +def get_diskpool(server, virt, dp_cn, pool_name): + dp_inst = None + dpool_cn = get_typed_class(virt, dp_cn) + pools = EnumNames(server, dpool_cn) + + dp_inst_id = "%s/%s" % (dp_cn, pool_name) + for pool in pools: + if pool['InstanceID'] == dp_inst_id: + dp_inst = pool + break + + return dp_inst + +def get_sto_vol_rasd_for_pool(virt, server, dp_cn, pool_name, exp_vol_path): + dv_rasds = None + dp_inst_id = "%s/%s" % (dp_cn, pool_name) + status, rasds = get_stovol_rasd_from_sdc(virt, server, dp_inst_id) + if status != PASS: + logger.error("Failed to get the StorageVol for '%s' vol", exp_vol_path) + return FAIL + + for item in rasds: + if item['Address'] == exp_vol_path and item['PoolID'] == dp_inst_id: + dv_rasds = item + break + + return dv_rasds + +def cleanup_pool_vol(server, virt, pool_name, exp_vol_path): + try: + status = destroy_diskpool(server, virt, pool_name) + if status != PASS: + raise Exception("Unable to destroy diskpool '%s'" % pool_name) + else: + status = undefine_diskpool(server, virt, pool_name) + if status != PASS: + raise Exception("Unable to undefine diskpool '%s'" % pool_name) + + if os.path.exists(exp_vol_path): + cmd = "rm -rf %s" % exp_vol_path + ret, out = utils.run_remote(server, cmd) + if ret != 0: + raise Exception("'%s' was not removed, please remove it "\ + "manually" % exp_vol_path) + + except Exception, details: + logger.error("Exception details: %s", details) + return FAIL + + return PASS +

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1253106316 25200 # Node ID 681307f145a51198349c2915c39bc6064da886b2 # Parent 741c93090d6f7cffadc7684563590282b073149d [TEST] #2 Added new tc to verify the RPCS error values with dir type pool. Patch 2: -------- 1) cleaned the pool at the end the verify_vol_err() 2) Created new dir pool to vefify the errors 3) Moved clean_pool_vol() to pool.py as this is refernced in RPCS/10*py RPCS/11*py and will be handy for future tests as well. Patch 1: ------- This test case verifies the creation of the StorageVol using the CreateResourceInPool method of RPCS returns an error when invalid values are passed. The test case checks for the errors when: 1) FormatType field in the StoragePoolRASD set to value other than RAW_TYPE 2) Trying to create 2 Vol in the same Path Tested with KVM and current sources on SLES11. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 741c93090d6f -r 681307f145a5 suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/11_create_dir_storagevolume_errs.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/11_create_dir_storagevolume_errs.py Wed Sep 16 06:05:16 2009 -0700 @@ -0,0 +1,165 @@ +#!/usr/bin/python +# +# Copyright 2009 IBM Corp. +# +# Authors: +# Deepti B. Kalakeri<dkalaker@in.ibm.com> +# +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# This test case verifies the creation of the StorageVol using the +# CreateResourceInPool method of RPCS returns an error when invalid values +# are passed. +# The test case checks for the errors when: +# 1) FormatType field in the StoragePoolRASD set to value other than RAW_TYPE +# 2) Trying to create 2 Vol in the same Path +# +# -Date: 04-09-2009 + +import sys +import os +from random import randint +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 CimTest.ReturnCodes import FAIL, PASS, SKIP +from XenKvmLib.classes import get_typed_class, inst_to_mof +from XenKvmLib.rasd import libvirt_rasd_storagepool_changes +from XenKvmLib.const import do_main, platform_sup, get_provider_version +from XenKvmLib.pool import create_pool, RAW_VOL_TYPE, DIR_POOL, get_diskpool,\ + get_stovol_default_settings, cleanup_pool_vol + +dir_pool_attr = { "Path" : "/tmp" } +vol_name = "cimtest-vol.img" + +INVALID_FTYPE = RAW_VOL_TYPE + randint(20,100) +exp_err_no = CIM_ERR_FAILED +exp_err_values = { 'INVALID_FTYPE': { 'msg' : "Unable to generate XML "\ + "for new resource" }, + 'DUP_VOL_PATH' : { 'msg' : "Unable to create storage volume"} + } + +def get_inputs(virt, server, dp_cn, key, exp_vol_path): + sv_rasd = dp_inst = None + try: + sv_rasd = get_stovol_default_settings(virt, server, dp_cn, + key, exp_vol_path, + vol_name) + if sv_rasd == None: + raise Exception("Failed to get the defualt StorageVolRASD info") + + if key == "INVALID_FTYPE": + sv_rasd['FormatType'] = Uint64(INVALID_FTYPE) + + sv_settings = inst_to_mof(sv_rasd) + dp_inst = get_diskpool(server, virt, dp_cn, key) + if dp_inst == None: + raise Exception("DiskPool instance for '%s' not found!" % key) + + except Exception, details: + logger.error("In get_inputs() Exception details: %s", details) + return FAIL, None, None + + return PASS, sv_settings, dp_inst + +def verify_vol_err(virt, server, dp_cn, key, exp_vol_path): + status, sv_settings, dp_inst = get_inputs(virt, server, dp_cn, key, + exp_vol_path) + if status != PASS: + return status + + status = FAIL + res = ret = [FAIL] + try: + logger.info("Verifying err for '%s'...", key) + rpcs = get_typed_class(virt, "ResourcePoolConfigurationService") + rpcs_conn = eval("rpcs_service." + rpcs)(server) + ret = rpcs_conn.CreateResourceInPool(Settings=sv_settings, + Pool=dp_inst) + + # For duplicate vol path verfication we should have been able to + # create the first dir pool successfully before attempting the next + if key == 'DUP_VOL_PATH' and ret[0] == PASS: + # Trying to create the vol in the same vol path should return + # an error + res = rpcs_conn.CreateResourceInPool(Settings=sv_settings, + Pool=dp_inst) + + except CIMError, (err_no, err_desc): + if res[0] != PASS and exp_err_values[key]['msg'] in err_desc \ + and exp_err_no == err_no: + logger.error("Got the expected error message: '%s' with '%s'", + err_desc, key) + status = PASS + else: + logger.error("Failed to get the error message '%s'", + exp_err_values[key]['msg']) + + if (res[0] == PASS and key == 'DUP_VOL_PATH') or \ + (ret[0] == PASS and key == 'INVALID_FTYPE'): + logger.error("Should not have been able to create Vol %s", vol_name) + + return status + +@do_main(platform_sup) +def main(): + options = main.options + server = options.ip + virt = options.virt + + 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: + logger.info("Storage Volume creation support is available with Libvirt" + "version >= 0.4.1 and Libvirt-CIM rev '%s'", + libvirt_rasd_storagepool_changes) + return SKIP + + dp_types = ['DUP_VOL_PATH', 'INVALID_FTYPE'] + dp_cn = "DiskPool" + exp_vol_path = "%s/%s" % (dir_pool_attr['Path'], vol_name) + + try: + # pool_name will contain either INVALID_FTYPE/DUP_VOL_PATH + # to be able access the err mesg + for pool_name in dp_types: + status = create_pool(server, virt, pool_name, dir_pool_attr, + mode_type=DIR_POOL, pool_type=dp_cn) + + if status != PASS: + logger.error("Failed to create pool '%s'", pool_name) + return status + + status = FAIL + status = verify_vol_err(virt, server, dp_cn, pool_name, exp_vol_path) + if status != PASS : + raise Exception("Failed to verify the Invlaid '%s'" % pool_name) + + ret = cleanup_pool_vol(server, virt, pool_name, exp_vol_path) + if ret != PASS: + raise Exception("Failed to clean the env") + + except Exception, details: + logger.error("In main() Exception details: %s", details) + status = FAIL + + + return status +if __name__ == "__main__": + sys.exit(main())

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1253106990 25200 # Node ID a8323b02007b6210f78bf92183c939e9e52b1f60 # Parent 681307f145a51198349c2915c39bc6064da886b2 [TEST] #2 Added new tc to verify the RPCS error values for netfs pool. Patch 2: -------- 1) Used the cleanup_pool_vol() from pool.py Patch 1: -------- This test case verifies the creation of the StorageVol using the CreateResourceInPool method of RPCS returns an error when invalid values are passed. The test case checks for the errors when, Trying to create a Vol in a netfs storage pool. Tested with KVM and current sources on SLES11. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 681307f145a5 -r a8323b02007b suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/12_create_netfs_storagevolume_errs.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/12_create_netfs_storagevolume_errs.py Wed Sep 16 06:16:30 2009 -0700 @@ -0,0 +1,167 @@ +#!/usr/bin/python +# +# Copyright 2009 IBM Corp. +# +# Authors: +# Deepti B. Kalakeri<dkalaker@in.ibm.com> +# +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# This test case verifies the creation of the StorageVol using the +# CreateResourceInPool method of RPCS returns an error when invalid values +# are passed. +# The test case checks for the errors when, +# Trying to create a Vol in a netfs storage pool +# +# -Date: 04-09-2009 + +import sys +from pywbem import CIM_ERR_FAILED, CIMError +from CimTest.Globals import logger +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.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, \ + get_stovol_default_settings, cleanup_pool_vol + +vol_name = "cimtest-vol.img" +vol_path = "/tmp/" + +exp_err_no = CIM_ERR_FAILED +exp_err_values = { 'NETFS_POOL' : { 'msg' : "This function does not "\ + "support this resource type"} + } + +def get_pool_attr(server, pool_type): + pool_attr = { } + status , host_addr, src_mnt_dir, dir_mnt_dir = nfs_netfs_setup(server) + if status != PASS: + logger.error("Failed to get pool_attr for NETFS diskpool type") + return status, pool_attr + + pool_attr['Host'] = host_addr + pool_attr['SourceDirectory'] = src_mnt_dir + pool_attr['Path'] = dir_mnt_dir + + return PASS, pool_attr + +def get_inputs(virt, server, dp_cn, pool_name, exp_vol_path): + sv_rasd = dp_inst = None + try: + sv_rasd = get_stovol_default_settings(virt, server, dp_cn, pool_name, + exp_vol_path, vol_name) + if sv_rasd == None: + raise Exception("Failed to get the defualt StorageVolRASD info") + + sv_settings = inst_to_mof(sv_rasd) + + dp_inst = get_diskpool(server, virt, dp_cn, pool_name) + if dp_inst == None: + raise Exception("DiskPool instance for '%s' not found!" \ + % pool_name) + + except Exception, details: + logger.error("Exception details: %s", details) + return FAIL, sv_rasd, dp_inst + + return PASS, sv_settings, dp_inst + +def verify_vol_err(server, virt, dp_cn, pool_name, exp_vol_path): + + status, sv_settings, dp_inst = get_inputs(virt, server, dp_cn, + pool_name, exp_vol_path) + if status != PASS: + return status + + status = FAIL + res = [FAIL] + try: + rpcs = get_typed_class(virt, "ResourcePoolConfigurationService") + rpcs_conn = eval("rpcs_service." + rpcs)(server) + res = rpcs_conn.CreateResourceInPool(Settings=sv_settings, + Pool=dp_inst) + + except CIMError, (err_no, err_desc): + if res[0] != PASS and exp_err_values[pool_name]['msg'] in err_desc \ + and exp_err_no == err_no: + logger.error("Got the expected error message: '%s' with '%s'", + err_desc, pool_name) + return PASS + else: + logger.error("Failed to get the error message '%s'", + exp_err_values[pool_name]['msg']) + if res[0] == PASS: + logger.error("Should not have been able to create the StorageVol '%s'", + vol_name) + + return FAIL + + +@do_main(platform_sup) +def main(): + options = main.options + server = options.ip + virt = options.virt + + 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: + logger.info("Storage Volume creation support is available with Libvirt" + "version >= 0.4.1 and Libvirt-CIM rev '%s'", + libvirt_rasd_storagepool_changes) + return SKIP + + pool_name = "NETFS_POOL" + pool_type = NETFS_POOL + exp_vol_path = "%s/%s" % (vol_path, vol_name) + dp_cn = "DiskPool" + + try: + status = FAIL + status, pool_attr = get_pool_attr(server, pool_type) + if status != PASS: + return status + + # Creating NETFS pool to verify RPCS error + status = create_pool(server, virt, pool_name, pool_attr, + mode_type=pool_type, pool_type=dp_cn) + + if status != PASS: + logger.error("Failed to create pool '%s'", pool_name) + return status + + status = verify_vol_err(server, virt, dp_cn, pool_name, exp_vol_path) + if status != PASS : + raise Exception("Failed to verify the Invlaid '%s' " % pool_name) + + + except Exception, details: + logger.error("Exception details: %s", details) + status = FAIL + + netfs_cleanup(server, pool_attr) + ret = cleanup_pool_vol(server, virt, pool_name, exp_vol_path) + if status != PASS or ret != PASS : + return FAIL + + return PASS +if __name__ == "__main__": + sys.exit(main())

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1253107262 25200 # Node ID fac3bdc5d14cd1e71bb21bf73c2a43bf83217439 # Parent a8323b02007b6210f78bf92183c939e9e52b1f60 [TEST] #3 Add new tc to verify the DeleteResourceInPool(). Patch 3: -------- 1) Used the cleanup_pool_vol() from pool.py Patch2: ------ 1) Added the missing test case. 2) Included get_sto_vol_rasd_for_pool() from pool.py Tested with KVM and current sources on SLES11. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r a8323b02007b -r fac3bdc5d14c suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/13_delete_storagevolume.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/13_delete_storagevolume.py Wed Sep 16 06:21:02 2009 -0700 @@ -0,0 +1,127 @@ +#!/usr/bin/python +# +# Copyright 2009 IBM Corp. +# +# Authors: +# Deepti B. Kalakeri<dkalaker@in.ibm.com> +# +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# This test case verifies the deletion of the StorageVol using the +# DeleteResourceInPool method of RPCS. +# +# -Date: 08-09-2009 + +import sys +from CimTest.Globals import logger +from CimTest.ReturnCodes import FAIL, PASS, SKIP +from XenKvmLib.xm_virt_util import virsh_version +from XenKvmLib.const import do_main, platform_sup, get_provider_version +from XenKvmLib import rpcs_service +from XenKvmLib.classes import get_typed_class, inst_to_mof +from XenKvmLib.pool import create_pool, DIR_POOL, \ + libvirt_rasd_spool_del_changes, get_diskpool, \ + get_stovol_default_settings, cleanup_pool_vol,\ + get_sto_vol_rasd_for_pool + +pool_attr = { 'Path' : "/tmp" } +vol_name = "cimtest-vol.img" + +@do_main(platform_sup) +def main(): + options = main.options + server = options.ip + virt = options.virt + + 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_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) + return SKIP + + dp_cn = "DiskPool" + exp_vol_path = "%s/%s" % (pool_attr['Path'], vol_name) + + # For now the test case support only the deletion of dir type based + # vol, we can extend dp_types to include netfs etc ..... + dp_types = { "DISK_POOL_DIR" : DIR_POOL } + + for pool_name, pool_type in dp_types.iteritems(): + status = FAIL + res = del_res = [FAIL] + try: + status = create_pool(server, virt, pool_name, pool_attr, + mode_type=pool_type, pool_type=dp_cn) + + if status != PASS: + logger.error("Failed to create pool '%s'", pool_name) + return status + + sv_rasd = get_stovol_default_settings(virt, server, dp_cn, pool_name, + exp_vol_path, vol_name) + if sv_rasd == None: + raise Exception("Failed to get the defualt StorageVolRASD info") + + sv_settings = inst_to_mof(sv_rasd) + + dp_inst = get_diskpool(server, virt, dp_cn, pool_name) + if dp_inst == None: + raise Exception("DiskPool instance for '%s' not found!" \ + % pool_name) + + rpcs = get_typed_class(virt, "ResourcePoolConfigurationService") + rpcs_conn = eval("rpcs_service." + rpcs)(server) + res = rpcs_conn.CreateResourceInPool(Settings=sv_settings, + Pool=dp_inst) + if res[0] != PASS: + raise Exception("Failed to create the Vol %s" % vol_name) + + res_settings = get_sto_vol_rasd_for_pool(virt, server, dp_cn, + pool_name, exp_vol_path) + if res_settings == None: + raise Exception("Failed to get the resource settings for '%s'" \ + " Vol" % vol_name) + + resource_setting = inst_to_mof(res_settings) + del_res = rpcs_conn.DeleteResourceInPool(Resource=resource_setting, + Pool=dp_inst) + + res_settings = get_sto_vol_rasd_for_pool(virt, server, dp_cn, + pool_name, exp_vol_path) + if res_settings != None: + raise Exception("'%s' vol of '%s' pool was not deleted" \ + % (vol_name, pool_name)) + else: + logger.info("Vol '%s' of '%s' pool deleted successfully by " + "DeleteResourceInPool()", vol_name, pool_name) + + ret = cleanup_pool_vol(server, virt, pool_name, exp_vol_path) + if del_res[0] == PASS and ret == PASS : + status = PASS + else: + return FAIL + + except Exception, details: + logger.error("Exception details: %s", details) + status = FAIL + + + return status +if __name__ == "__main__": + sys.exit(main())

+import sys +from CimTest.Globals import logger +from CimTest.ReturnCodes import FAIL, PASS, SKIP +from XenKvmLib.xm_virt_util import virsh_version +from XenKvmLib.const import do_main, platform_sup, get_provider_version +from XenKvmLib import rpcs_service +from XenKvmLib.classes import get_typed_class, inst_to_mof +from XenKvmLib.pool import create_pool, DIR_POOL, \ + libvirt_rasd_spool_del_changes, get_diskpool, \ + get_stovol_default_settings, cleanup_pool_vol,\ + get_sto_vol_rasd_for_pool + +pool_attr = { 'Path' : "/tmp" } +vol_name = "cimtest-vol.img" + +@do_main(platform_sup) +def main(): + options = main.options + server = options.ip + virt = options.virt + + 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_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) + return SKIP + + dp_cn = "DiskPool" + exp_vol_path = "%s/%s" % (pool_attr['Path'], vol_name)
I think this test suffers from the same problem 10 does. The path for your volume is "/tmp/cimtest-vol.img" but you want to create it in DIR_POOL. So I think you have a mismatch here. In that case, you don't even need to create a new pool - just create the volume in the default pool and then clean it up when the test exits. How about holding off on submitting this test until 10 is fixed correctly?
+ + # For now the test case support only the deletion of dir type based + # vol, we can extend dp_types to include netfs etc ..... + dp_types = { "DISK_POOL_DIR" : DIR_POOL } + + for pool_name, pool_type in dp_types.iteritems(): + status = FAIL + res = del_res = [FAIL] + try: + status = create_pool(server, virt, pool_name, pool_attr, + mode_type=pool_type, pool_type=dp_cn) +
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1253123447 25200 # Node ID bfe0b7369b698ec8ed47bca99bf0e1581dc00d65 # Parent fac3bdc5d14cd1e71bb21bf73c2a43bf83217439 [TEST] #3 Add new tc to verify the err values for RPCS DeleteResourceInPool() Patch 3: ------- 1) Included cleanup_pool_vol() of pool.py 2) Created a new dir pool Patch 2: -------- 1) Added exception to verify_rpcs_err_val() to catch exceptions returned other than for DeleteResourceInPool() 2) Included get_sto_vol_rasd_for_pool() from pool.py Tested with KVM and current sources on SLES11. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r fac3bdc5d14c -r bfe0b7369b69 suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/14_delete_storagevolume_errs.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/14_delete_storagevolume_errs.py Wed Sep 16 10:50:47 2009 -0700 @@ -0,0 +1,175 @@ +#!/usr/bin/python +# +# Copyright 2009 IBM Corp. +# +# Authors: +# Deepti B. Kalakeri<dkalaker@in.ibm.com> +# +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# This test case verifies the deletion of the StorageVol using the +# DeleteResourceInPool method of RPCS returns error when invalid values are +# passed. +# +# -Date: 08-09-2009 + +import sys +import os +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.const import do_main, platform_sup, get_provider_version +from XenKvmLib import rpcs_service +from XenKvmLib.classes import get_typed_class, inst_to_mof +from XenKvmLib.pool import create_pool, DIR_POOL, \ + libvirt_rasd_spool_del_changes, get_diskpool, \ + get_stovol_default_settings, cleanup_pool_vol, \ + get_sto_vol_rasd_for_pool + +pool_attr = { 'Path' : "/tmp" } +vol_name = "cimtest-vol.img" +invalid_scen = { "INVALID_ADDRESS" : { 'val' : 'Junkvol_path', + 'msg' : 'no storage vol with '\ + 'matching path' }, + "NO_ADDRESS_FIELD" : { 'msg' :'Missing Address in '\ + 'resource RASD' }, + "MISSING_RESOURCE" : { 'msg' :"Missing argument `Resource'"}, + "MISSING_POOL" : { 'msg' :"Missing argument `Pool'"} + } + + +def verify_rpcs_err_val(virt, server, rpcs_conn, dp_cn, pool_name, + exp_vol_path, dp_inst): + + for err_scen in invalid_scen.keys(): + logger.info("Verifying errors for '%s'....", err_scen) + status = FAIL + del_res = [FAIL] + try: + res_settings = get_sto_vol_rasd_for_pool(virt, server, dp_cn, + pool_name, exp_vol_path) + if res_settings == None: + raise Exception("Failed getting resource settings for '%s' vol"\ + " when executing '%s'" % (vol_name, err_scen)) + + if not "MISSING" in err_scen: + exp_err_no = CIM_ERR_FAILED + + if "NO_ADDRESS_FIELD" in err_scen: + del res_settings['Address'] + elif "INVALID_ADDRESS" in err_scen: + res_settings['Address'] = invalid_scen[err_scen]['val'] + + resource = inst_to_mof(res_settings) + del_res = rpcs_conn.DeleteResourceInPool(Resource=resource, + Pool=dp_inst) + else: + exp_err_no = CIM_ERR_INVALID_PARAMETER + + if err_scen == "MISSING_RESOURCE": + del_res = rpcs_conn.DeleteResourceInPool(Pool=dp_inst) + elif err_scen == "MISSING_POOL": + resource = inst_to_mof(res_settings) + del_res = rpcs_conn.DeleteResourceInPool(Resource=resource) + + except CIMError, (err_no, err_desc): + if del_res[0] != PASS and invalid_scen[err_scen]['msg'] in err_desc\ + and exp_err_no == err_no: + logger.error("Got the expected error message: '%s' for '%s'", + err_desc, err_scen) + status = PASS + else: + logger.error("Unexpected error msg, Expected '%s'-'%s', Got" + "'%s'-'%s'", exp_err_no, + invalid_scen[err_scen]['msg'], err_no, err_desc) + return FAIL + + except Exception, details: + logger.error("Exception details: %s", details) + return FAIL + + if del_res[0] == PASS or status != PASS: + logger.error("Should not have been able to delete Vol %s", vol_name) + return FAIL + + return status + +@do_main(platform_sup) +def main(): + options = main.options + server = options.ip + virt = options.virt + + 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_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) + return SKIP + + dp_cn = "DiskPool" + exp_vol_path = "%s/%s" % (pool_attr['Path'], vol_name) + + pool_name = 'DIR_POOL_VOL' + status = FAIL + res = del_res = [FAIL] + try: + status = create_pool(server, virt, pool_name, pool_attr, + mode_type=DIR_POOL, pool_type=dp_cn) + + if status != PASS: + logger.error("Failed to create pool '%s'", pool_name) + return status + + sv_rasd = get_stovol_default_settings(virt, server, dp_cn, pool_name, + exp_vol_path, vol_name) + if sv_rasd == None: + raise Exception("Failed to get the defualt StorageVolRASD info") + + sv_settings = inst_to_mof(sv_rasd) + + dp_inst = get_diskpool(server, virt, dp_cn, pool_name) + if dp_inst == None: + raise Exception("DiskPool instance for '%s' not found!" \ + % pool_name) + + rpcs = get_typed_class(virt, "ResourcePoolConfigurationService") + rpcs_conn = eval("rpcs_service." + rpcs)(server) + res = rpcs_conn.CreateResourceInPool(Settings=sv_settings, + Pool=dp_inst) + if res[0] != PASS: + raise Exception("Failed to create the Vol %s" % vol_name) + + status = verify_rpcs_err_val(virt, server, rpcs_conn, dp_cn, + pool_name, exp_vol_path, dp_inst) + if status != PASS : + raise Exception("Verification Failed for DeleteResourceInPool()") + + except Exception, details: + logger.error("Exception details: %s", details) + status = FAIL + + ret = cleanup_pool_vol(server, virt, pool_name, exp_vol_path) + if status != PASS or ret != PASS: + return FAIL + + return status +if __name__ == "__main__": + sys.exit(main())

+ +pool_attr = { 'Path' : "/tmp" } +vol_name = "cimtest-vol.img"
+ +@do_main(platform_sup) +def main(): + options = main.options + server = options.ip + virt = options.virt + + 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_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) + return SKIP + + dp_cn = "DiskPool" + exp_vol_path = "%s/%s" % (pool_attr['Path'], vol_name) + + pool_name = 'DIR_POOL_VOL'
This test has the same problem as test 10. You're creating the volume in /tmp, and the default pool already uses this location. So you might as well create this volume in the default pool. No need to create a new pool just for this volume. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Deepti B. Kalakeri
-
Kaitlin Rupert