
# HG changeset patch # User Yun Guo Lian <yunguol@cn.ibm.com> # Date 1242713086 25200 # Node ID 848683648c95f9367486db4d027b1d93683561dd # Parent 6dc2d815e480237c91115cd0d86f6325503e33f7 [TEST] #3 Update RPCS/04 with the latest updatesof pool verification Updates from 2 to 3: Pull the NetPoolRASDs from get_pool_rasds() instead of setting the properties appropriately and then create netpool for each types Tested for KVM with current sources Signed-off-by: Guolian Yun<yunguol@cn.ibm.com diff -r 6dc2d815e480 -r 848683648c95 suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py Sun May 17 23:34:58 2009 -0700 +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py Mon May 18 23:04:46 2009 -0700 @@ -39,45 +39,70 @@ # OUT -- Error -- String -- Encoded error instance if the operation # failed and did not return a job # -# REVISIT : -# -------- -# As of now the CreateChildResourcePool() simply throws an Exception. -# We must improve this tc once the service is implemented. -# -# -Date: 20.02.2008 - +# Exception details before Revision 837 +# ----- +# Error code: CIM_ERR_NOT_SUPPORTED +# +# After revision 837, the service is implemented +# +# -Date: 20.02.2008 import sys -import pywbem -from XenKvmLib import rpcs_service +import random from CimTest.Globals import logger from CimTest.ReturnCodes import FAIL, PASS from XenKvmLib.const import do_main, platform_sup from XenKvmLib.classes import get_typed_class +from XenKvmLib.common_util import destroy_netpool +from XenKvmLib.pool import create_netpool, verify_pool, undefine_netpool -cim_errno = pywbem.CIM_ERR_NOT_SUPPORTED -cim_mname = "CreateChildResourcePool" +test_pool = "testpool" @do_main(platform_sup) def main(): options = main.options - rpcs_conn = eval("rpcs_service." + get_typed_class(options.virt, \ - "ResourcePoolConfigurationService"))(options.ip) - 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 - - logger.error("The execution should not have reached here!!") - return FAIL + + np = get_typed_class(options.virt, 'NetworkPool') + np_id = "NetworkPool/%s" % test_pool + + subnet = '192.168.0.' + ip_base = random.randint(1, 100) + addr = subnet+'%d' % ip_base + range_addr_start = subnet+'%d' % (ip_base + 1) + range_addr_end = subnet+'%d' %(ip_base + 10) + pool_attr = { + "Address" : addr, + "Netmask" : "255.255.255.0", + "IPRangeStart" : range_addr_start, + "IPRangeEnd" : range_addr_end + } + + status = create_netpool(options.ip, options.virt, + test_pool, pool_attr) + if status != PASS: + logger.error("Error in networkpool creation") + 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) + undefine_netpool(options.ip, options.virt, test_pool) + return FAIL + + status = destroy_netpool(options.ip, options.virt, test_pool) + if status != PASS: + logger.error("Unable to destroy networkpool %s", test_pool) + return FAIL + + status = undefine_netpool(options.ip, options.virt, test_pool) + if status != PASS: + logger.error("Unable to undefine networkpool %s", test_pool) + return FAIL + + status = PASS + return status + if __name__ == "__main__": sys.exit(main()) - diff -r 6dc2d815e480 -r 848683648c95 suites/libvirt-cim/lib/XenKvmLib/pool.py --- a/suites/libvirt-cim/lib/XenKvmLib/pool.py Sun May 17 23:34:58 2009 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/pool.py Mon May 18 23:04:46 2009 -0700 @@ -177,15 +177,16 @@ logger.error("We can not get NetPoolRASDs") return FAIL else: - net_pool_rasds[0]['PoolID'] = "NetworkPool/%s" % test_pool - for attr, val in pool_attr_list.iteritems(): - net_pool_rasds[0][attr] = val - - pool_settings = inst_to_mof(net_pool_rasds[0]) + pool_settings = [] + for i in range(0, len(net_pool_rasds)): + net_pool_rasds[i]['PoolID'] = "NetworkPool/%s" % test_pool + for attr, val in pool_attr_list.iteritems(): + net_pool_rasds[i][attr] = val + pool_settings.append(inst_to_mof(net_pool_rasds[i])) try: rpcs_conn.CreateChildResourcePool(ElementName=test_pool, - Settings=[pool_settings]) + Settings=pool_settings) except Exception, details: logger.error("Error in childpool creation") logger.error(details) diff -r 6dc2d815e480 -r 848683648c95 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Sun May 17 23:34:58 2009 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Mon May 18 23:04:46 2009 -0700 @@ -274,13 +274,11 @@ def xml_get_netpool_attr_list(self): pool_attr_list = [] - npoolmode = self.get_value_xpath('/network/forward/@mode') npooladdr = self.get_value_xpath('/network/ip/@address') npoolmask = self.get_value_xpath('/network/ip/@netmask') npoolstart = self.get_value_xpath('/network/ip/dhcp/range/@start') npoolend = self.get_value_xpath('/network/ip/dhcp/range/@end') - pool_attr_list.append(npoolmode) pool_attr_list.append(npooladdr) pool_attr_list.append(npoolmask) pool_attr_list.append(npoolstart)