
yunguol@cn.ibm.com wrote:
# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1241688655 25200 # Node ID 18fc8178c29ac30027272af9afe5b3fd01b1380c # Parent 92caf252c2fa8c8a7a9b70548d12b03c52f3935c [TEST] Make RPCS/07 to delete networkpool through providers
Tested for KVM with current sources Signed-off-by: Guolian Yun<yunguol@cn.ibm.com>
diff -r 92caf252c2fa -r 18fc8178c29a suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/07_DeleteResourcePool.py --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/07_DeleteResourcePool.py Mon May 04 03:49:32 2009 -0700 +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/07_DeleteResourcePool.py Thu May 07 02:30:55 2009 -0700 @@ -33,10 +33,12 @@ # 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. -# REVISIT : -# -------- -# As of now the DeleteResourcePool() simply throws an Exception. -# We must improve this tc once the service is implemented. +# +# Exception details before Revision 841 +# ----- +# Error code: CIM_ERR_NOT_SUPPORTED +# +# After revision 841, the service is implemented # # -Date: 20.02.2008
@@ -46,32 +48,64 @@ from XenKvmLib import rpcs_service from CimTest.Globals import logger from CimTest.ReturnCodes import FAIL, PASS -from XenKvmLib.const import do_main, platform_sup +from XenKvmLib.const import do_main, platform_sup, get_provider_version +from XenKvmLib.enumclass import EnumInstances from XenKvmLib.classes import get_typed_class +from XenKvmLib.pool import create_netpool, verify_pool +from pywbem.cim_obj import CIMInstanceName
cim_errno = pywbem.CIM_ERR_NOT_SUPPORTED cim_mname = "DeleteResourcePool" +libvirt_cim_child_pool_rev = 841 +test_pool = "test_pool"
@do_main(platform_sup) def main(): + status = PASS options = main.options - rpcs_conn = eval("rpcs_service." + get_typed_class(options.virt, \ - "ResourcePoolConfigurationService"))(options.ip) - try: - rpcs_conn.DeleteResourcePool() - 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) + rpcs = get_typed_class(options.virt, "ResourcePoolConfigurationService") + rpcs_conn = eval("rpcs_service." + rpcs)(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.DeleteResourcePool() + 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: + addr = "192.168.0.100" + status = create_netpool(options.ip, options.virt, test_pool, + addr, None) + if status != PASS: + logger.error("Error in networkpool creation") return FAIL - - logger.error("The execution should not have reached here!!") - return FAIL + + np = get_typed_class(options.virt, "NetworkPool") + np_id = "NetworkPool/%s" %test_pool + status = verify_pool(options.ip, np, np_id, addr) + if status != PASS: + logger.error("Error in networkpool verification") + return FAIL
You need to destroy/undefine the netpool here before returning.
+ + pool = CIMInstanceName(np, keybindings = {'InstanceID':np_id}) + try: + rpcs_conn.DeleteResourcePool(Pool = pool) + netpool = EnumInstances(options.ip, np) + for i in range(0, len(netpool)): + ret_pool = netpool[i].InstanceID + if ret_pool == np_id: + raise Exception("Failed to delete %s" % test_pool) + except Exception, details: + logger.error(details) + status = FAIL
You need to delete the networkpool when it fails to delete it using the DeleteResourcePool()
+ + return status
if __name__ == "__main__": sys.exit(main()) -
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Thanks and Regards, Deepti B. Kalakeri IBM Linux Technology Center deeptik@linux.vnet.ibm.com