# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1240825724 25200
# Node ID b1920cf4a6c61d3bfda1103bc454c277294745cb
# Parent e8dc06eefada41252ba8d27b08fcef8ef6604251
[TEST] #2 Add new tc to validate that the Disk child pool can be created through the
providers
Updates from 1 to 2:
1)Combine CIM_NS and logger
2)Move verify_pool function into library
Tested for KVM with current sources
Signed-off-by: Guolian Yun<yunguol(a)cn.ibm.com>
diff -r e8dc06eefada -r b1920cf4a6c6
suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateChildResourcePool_Disk.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++
b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateChildResourcePool_Disk.py Mon
Apr 27 02:48:44 2009 -0700
@@ -0,0 +1,125 @@
+#!/usr/bin/python
+#
+# Copyright 2009 IBM Corp.
+#
+# Authors:
+# Guolian Yun <yunguol(a)cn.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 should test the CreateChildResourcePool service
+# supplied by the RPCS provider.
+# Input
+# -----
+# IN -- ElementName -- String -- The desired name of the resource pool
+# IN -- Settings -- String -- A string representation of a
+# CIM_ResourceAllocationSettingData
+# instance that represents the allocation
+# assigned to this child pool
+# IN -- ParentPool -- CIM_ResourcePool REF -- The parent pool from which
+# to create this pool
+#
+# Output
+# ------
+# OUT -- Pool -- CIM_ResourcePool REF -- The resulting resource pool
+# OUT -- Job -- CIM_ConcreteJob REF -- Returned job if started
+# OUT -- Error -- String -- Encoded error instance if the operation
+# failed and did not return a job
+#
+# Exception details before Revision 837
+# -----
+# Error code: CIM_ERR_NOT_SUPPORTED
+#
+# After revision 837, the service is implemented
+#
+# -Date: 23.04.2009
+
+import sys
+import pywbem
+from XenKvmLib import rpcs_service
+from CimTest.Globals import logger, CIM_NS
+from CimTest.ReturnCodes import FAIL, PASS
+from XenKvmLib.const import do_main, platform_sup, get_provider_version
+from XenKvmLib.classes import get_typed_class
+from pywbem.cim_obj import CIMInstanceName, CIMInstance
+from XenKvmLib.common_util import diskpool_destroy, diskpool_undefine, \
+ verify_pool
+from pywbem.cim_types import Uint16
+
+cim_errno = pywbem.CIM_ERR_NOT_SUPPORTED
+cim_mname = "CreateChildResourcePool"
+libvirt_cim_child_pool_rev = 837
+test_pool = ["dir_pool"]
+
+@do_main(platform_sup)
+def main():
+ options = main.options
+ rpcs_conn = eval("rpcs_service." + get_typed_class(options.virt, \
+ "ResourcePoolConfigurationService"))(options.ip)
+
+ curr_cim_rev, changeset = get_provider_version(options.virt, options.ip)
+ if curr_cim_rev < libvirt_cim_child_pool_rev:
+ try:
+ rpcs_conn.CreateChildResourcePool()
+ except pywbem.CIMError, (err_no, desc):
+ if err_no == cim_errno :
+ logger.info("Got expected exception for '%s'service",
cim_mname)
+ logger.info("Errno is '%s' ", err_no)
+ logger.info("Error string is '%s'", desc)
+ return PASS
+ else:
+ logger.error("Unexpected rc code %s and description %s\n",
+ err_no, desc)
+ return FAIL
+ elif curr_cim_rev >= libvirt_cim_child_pool_rev:
+ dprasd = get_typed_class(options.virt,
+ 'DiskPoolResourceAllocationSettingData')
+ dp_prop = {"Path" : "/tmp"}
+
+ for i in range(0, len(test_pool)):
+ dp_id = 'DiskPool/%s' % test_pool[i]
+ iname = CIMInstanceName(dprasd,
+ namespace = CIM_NS,
+ keybindings = {'InstanceID':dp_id})
+ if test_pool[i] == "dir_pool":
+ dp_prop["Type"] = Uint16(1)
+
+ drasd = CIMInstance(dprasd, path = iname, properties = dp_prop)
+ try:
+ rpcs_conn.CreateChildResourcePool(ElementName=test_pool[i],
+ Settings=[drasd.tomof()])
+ dp = get_typed_class(options.virt, 'DiskPool')
+ status = verify_pool(options.ip, dp, dp_id)
+ if status != PASS:
+ raise Exception("Error in diskpool verification")
+ status = diskpool_destroy(test_pool[i], options.ip, options.virt)
+ if status != PASS:
+ raise Exception("Unable to destroy diskpool %s"
+ % test_pool[i])
+ status = diskpool_undefine(test_pool[i], options.ip, options.virt)
+ if status != PASS:
+ raise Exception("Unable to undefine diskpool %s"
+ % test_pool[i])
+ except Exception, details:
+ logger.error("Error in %s creation and verification"
+ " through provider", dp_id)
+ logger.error(details)
+ return FAIL
+
+ return status
+
+if __name__ == "__main__":
+ sys.exit(main())
diff -r e8dc06eefada -r b1920cf4a6c6 suites/libvirt-cim/lib/XenKvmLib/common_util.py
--- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Tue Apr 21 17:08:06 2009 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Apr 27 02:48:44 2009 -0700
@@ -403,6 +403,22 @@
return cs
+def diskpool_destroy(diskpool, server, virt="Xen"):
+ """Function destroys a given virtual diskpool"""
+
+ cmd = "virsh -c %s pool-destroy %s" % (virt2uri(virt), diskpool)
+ ret, out = utils.run_remote(server, cmd)
+
+ return ret
+
+def diskpool_undefine(diskpool, server, virt="Xen"):
+ """Function undefines a given virtual diskpool"""
+
+ cmd = "virsh -c %s pool-undefine %s" % (virt2uri(virt), diskpool)
+ ret, out = utils.run_remote(server, cmd)
+
+ return ret
+
def check_sblim(server, virt='Xen'):
status = FAIL
prev_namespace = Globals.CIM_NS