
# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1242291170 25200 # Node ID f899232889810985dadbaabeed1198bad05edde2 # Parent 9391439d65e7ec6b88f34923d97f969c6114a237 [TEST]Update RPCS/07 with the latest updates of pool verification Tested for KVM with current sources Signed-off-by: Guolian Yun<yunguol@cn.ibm.com> diff -r 9391439d65e7 -r f89923288981 suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/07_DeleteResourcePool.py --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/07_DeleteResourcePool.py Wed May 13 07:28:33 2009 -0700 +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/07_DeleteResourcePool.py Thu May 14 01:52:50 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,79 @@ 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, EnumNames from XenKvmLib.classes import get_typed_class +from XenKvmLib.common_util import destroy_netpool +from XenKvmLib.pool import create_netpool, verify_pool cim_errno = pywbem.CIM_ERR_NOT_SUPPORTED cim_mname = "DeleteResourcePool" +libvirt_cim_child_pool_rev = 841 +test_pool = "nat_pool" @do_main(platform_sup) def main(): + status = FAIL 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) + 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: + pool_attr = { + "Address" : "192.168.0.8", + "Netmask" : "255.255.255.0", + "IPRangeStart" : "192.168.0.9", + "IPRangeEnd" : "192.168.0.15", + "ForwardMode" : "nat" + } + np = get_typed_class(options.virt, 'NetworkPool') + np_id = "NetworkPool/%s" % test_pool + + status = create_netpool(options.ip, options.virt, test_pool, pool_attr) + if status != PASS: + logger.error("Error in networkpool creation") return FAIL - - logger.error("The execution should not have reached here!!") - return FAIL + + status = verify_pool(options.ip, options.virt, np, + test_pool, pool_attr) + if status != PASS: + logger.error("Error in networkpool verification") + destroy_netpool(options.ip, options.virt, test_pool) + return FAIL + + netpool = EnumNames(options.ip, np) + for i in range(0, len(netpool)): + ret_pool = netpool[i].keybindings['InstanceID'] + if ret_pool == np_id: + pool_settings = netpool[i] + break + try: + rpcs_conn.DeleteResourcePool(Pool = pool_settings) + 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) + status = PASS + except Exception, details: + logger.error(details) + return FAIL + + return status + if __name__ == "__main__": sys.exit(main()) -