[PATCH] [TEST] Adding create_diskpool() function

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1210684342 25200 # Node ID a6ffa074aab4b3867358eb77c0dcc7c622c595d4 # Parent f81fd5f73b3e71630bf2b6e6e6a51a8f7f254346 [TEST] Adding create_diskpool() function To create the storage pool on machine with libvirt >= 0.4.1 Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r f81fd5f73b3e -r a6ffa074aab4 suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Tue May 13 06:07:27 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Tue May 13 06:12:22 2008 -0700 @@ -1,3 +1,4 @@ +#!/usr/bin/python # # Copyright 2008 IBM Corp. # @@ -32,9 +33,12 @@ from XenKvmLib.classes import get_typed_ from XenKvmLib.classes import get_typed_class from CimTest.Globals import logger, log_param, CIM_ERROR_ENUMERATE from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC -from XenKvmLib.const import CIM_REV +from XenKvmLib.const import CIM_REV, default_pool_name +from VirtLib.live import diskpool_list +from XenKvmLib.vxml import PoolXML test_dpath = "foo" +dpoolname = default_pool_name diskpoolconf_rev = 558 if CIM_REV < diskpoolconf_rev: @@ -294,3 +298,17 @@ def create_diskpool_file(): return conf_file() +def create_diskpool(server, virt='KVM'): + dpool_list = diskpool_list(server, virt='KVM') + if len(dpool_list) > 0: + dpoolname=dpool_list[0] + else: + global dpoolname + diskxml = PoolXML(server, virt=virt) + ret = diskxml.create_vpool() + if not ret: + logger.error('Failed to create the disk pool "%s"', + dpoolname) + return FAIL + logger.info("Disk Pool on machine is: %s ", dpoolname) + return PASS

+def create_diskpool(server, virt='KVM'): + dpool_list = diskpool_list(server, virt='KVM') + if len(dpool_list) > 0: + dpoolname=dpool_list[0] + else: + global dpoolname
Don't use a global here. Globals should be avoided, especially in this case where this function is modifying a value that is used by multiple test cases. Instead, have this function return the name of the diskpool it uses.
+ diskxml = PoolXML(server, virt=virt) + ret = diskxml.create_vpool() + if not ret: + logger.error('Failed to create the disk pool "%s"', + dpoolname) + return FAIL + logger.info("Disk Pool on machine is: %s ", dpoolname) + return PASS -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Deepti B. Kalakeri
-
Kaitlin Rupert