
We cannot have two storage pools referencing the same path. Since the cimtest-diskpool is already created at /var/lib/libvirt/images, we'll use that (e.g. _image_dir symbol) to create a subdirectory for the test. We'll also delete that directory when we're done. --- .../08_CreateDiskResourcePool.py | 26 +++++++++++++++++----- .../09_DeleteDiskPool.py | 19 +++++++++++----- .../15_DiskPoolAutostart.py | 11 ++++++++- 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py index c82b5b0..636f59c 100644 --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py @@ -48,6 +48,7 @@ # -Date: 26.05.2009 import sys +import os from CimTest.Globals import logger from XenKvmLib.xm_virt_util import virsh_version from CimTest.ReturnCodes import FAIL, PASS, SKIP @@ -55,8 +56,9 @@ from XenKvmLib.const import do_main, platform_sup from XenKvmLib.classes import get_typed_class from XenKvmLib.common_util import destroy_diskpool, nfs_netfs_setup, \ netfs_cleanup -from XenKvmLib.pool import create_pool, verify_pool, undefine_diskpool -from XenKvmLib.const import get_provider_version +from XenKvmLib.pool import create_pool, verify_pool, undefine_diskpool, \ + DIR_POOL, NETFS_POOL +from XenKvmLib.const import get_provider_version, _image_dir libvirt_disk_pool_support=837 libvirt_netfs_pool_support=869 @@ -94,19 +96,20 @@ def main(): curr_cim_rev, changeset = get_provider_version(virt, server) if curr_cim_rev >= libvirt_disk_pool_support: - dp_types["DISK_POOL_DIR"] = 1 + dp_types["DISK_POOL_DIR"] = DIR_POOL if curr_cim_rev >= libvirt_netfs_pool_support: - dp_types["DISK_POOL_NETFS"] = 3 + dp_types["DISK_POOL_NETFS"] = NETFS_POOL if len(dp_types) == 0 : - logger.info("No disk pool types in list , hence skipping the test...") + logger.info("No disk pool types in list, hence skipping the test...") return SKIP status = FAIL pool_attr = None # For now the test case support only the creation of # dir type disk pool, netfs later change to fs and disk pooltypes etc - for key, value in dp_types.iteritems(): + for key, value in dp_types.iteritems(): + del_path = False try: logger.info("Verifying '%s'.....", key) test_pool = key @@ -115,6 +118,15 @@ def main(): if status != PASS: return FAIL + # Cannot have two pools that use the same location/path, so + # since cimtest-diskpool already exists + if key == 'DISK_POOL_DIR': + path = os.path.join(_image_dir, 'temppool') + if not os.path.exists(path): + os.mkdir(path) + del_path = True + pool_attr["Path"] = path + status = create_pool(server, virt, test_pool, pool_attr, mode_type=value, pool_type= "DiskPool") @@ -152,6 +164,8 @@ def main(): if key == 'DISK_POOL_NETFS': netfs_cleanup(server, pool_attr) + if del_path: + os.rmdir(path) return status if __name__ == "__main__": diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/09_DeleteDiskPool.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/09_DeleteDiskPool.py index 31e3f22..8bd15e2 100644 --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/09_DeleteDiskPool.py +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/09_DeleteDiskPool.py @@ -44,6 +44,7 @@ # -Date: 26.05.2009 import sys +import os import pywbem from XenKvmLib import rpcs_service from CimTest.Globals import logger @@ -88,13 +89,17 @@ def main(): elif curr_cim_rev >= libvirt_cim_child_pool_rev: + del_path = False try: - pool_attr = { "Path" : _image_dir } + path = os.path.join(_image_dir, 'deltest') + if not os.path.exists(path): + os.mkdir(path) + del_path = True + pool_attr = { "Path" : path } status = create_pool(server, virt, test_pool, pool_attr, pool_type="DiskPool", mode_type=TYPE) if status != PASS: - logger.error("Failed to create diskpool '%s'", test_pool) - return status + raise Exception("Failed to create diskpool '%s'" % test_pool) status = verify_pool(server, virt, test_pool, pool_attr, pool_type="DiskPool") @@ -112,8 +117,8 @@ def main(): break if pool_settings == None: - logger.error("Failed to get poolsettings for '%s'", test_pool) - return FAIL + raise Exception("Failed to get poolsettings for '%s'" \ + % test_pool) rpcs_conn.DeleteResourcePool(Pool = pool_settings) pool = EnumInstances(server, dp) @@ -127,8 +132,10 @@ def main(): logger.error("Exception details: %s", details) destroy_diskpool(server, virt, test_pool) undefine_diskpool(server, virt, test_pool) - return FAIL + status = FAIL + if del_path: + os.rmdir(path) return status if __name__ == "__main__": diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py index b6b758c..b7e72a8 100644 --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py @@ -23,6 +23,7 @@ # -Date: 04.14.2011 import sys +import os from pywbem import cim_types from CimTest.Globals import logger from XenKvmLib.xm_virt_util import virsh_version @@ -77,12 +78,17 @@ def main(): pool_attr = None key = 'DISK_POOL_DIR' value = 1 + del_path = False try: logger.info("Verifying '%s'.....", key) test_pool = key - pool_attr = { "Path" : "/var/lib/libvirt/images", + pool_attr = { "Path" : "/var/lib/libvirt/images/autotest", "Autostart" : cim_types.Uint16(1) } + if not os.path.exists(pool_attr["Path"]): + os.mkdir(pool_attr["Path"]) + del_path = True + status = create_pool(server, virt, test_pool, pool_attr, mode_type=value, pool_type= "DiskPool") @@ -112,6 +118,9 @@ def main(): status = FAIL logger.error("Exception details: %s", details) + if del_path: + os.rmdir(pool_attr["Path"]) + return status if __name__ == "__main__": -- 1.8.1.4