# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1240207150 25200
# Node ID fd53d858ff5fa251862bf36c26eafd79290c2f65
# Parent ced161a8198115797a6036f3f22e02d234439a76
[TEST] #2 Update RPCS/04 to validate that the Network child pool can be created through
the providers
Updates from 1 to 2:
Test all types of networkpool including routed network, nat based network and isolated
network
Tested for KVM with current sources
Signed-off-by: Guolian Yun<yunguol(a)cn.ibm.com>
diff -r ced161a81981 -r fd53d858ff5f
suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py
---
a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py Wed
Apr 15 20:19:31 2009 -0700
+++
b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py Sun
Apr 19 22:59:10 2009 -0700
@@ -41,8 +41,8 @@
#
# REVISIT :
# --------
-# As of now the CreateChildResourcePool() simply throws an Exception.
-# We must improve this tc once the service is implemented.
+# The CreateChildResourcePool() simply throws an Exception before the
+# changeset number of 839, and now the service is implemented.
#
# -Date:
20.02.2008
@@ -52,32 +52,100 @@
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.classes import get_typed_class
+from pywbem.cim_obj import CIMInstanceName, CIMInstance
+from XenKvmLib.enumclass import EnumInstances
+from XenKvmLib.common_util import destroy_netpool
cim_errno = pywbem.CIM_ERR_NOT_SUPPORTED
cim_mname = "CreateChildResourcePool"
+libvirt_cim_child_pool_rev = 837
+test_pool = ["routedpool", "natpool", "isolatedpool"]
+
+def verify_pool(pool_list, poolname):
+ status = FAIL
+ if len(pool_list) < 1:
+ logger.error("Return %i instances, expected at least one instance",
+ len(pool_list))
+ return FAIL
+
+ for i in range(0, len(pool_list)):
+ ret_pool = pool_list[i].InstanceID
+ if ret_pool == poolname:
+ status = PASS
+ break
+ elif ret_pool != poolname and i == len(pool_list)-1:
+ logger.error("Can not find expected pool")
+
+ return status
@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
+
+ 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:
+ nprasd = get_typed_class(options.virt,
+ 'NetPoolResourceAllocationSettingData')
+ for i in range(0, len(test_pool)):
+ np_id = 'NetworkPool/%s' % test_pool[i]
+ iname = CIMInstanceName(nprasd,
+ namespace = 'root/virt',
+ keybindings = {'InstanceID':np_id})
+ np_prop = {
+ "Address" : "192.168.0.30",
+ "Netmask" : "255.255.255.0",
+ "IPRangeStart" : "192.168.0.31",
+ "IPRangeEnd" : "192.168.0.57",
+ }
+ if test_pool == "routedpool":
+ np_prop["ForwardMode"] = "route eth1"
+ elif test_pool == "natpool":
+ np_prop["ForwardMode"] = "nat"
+
+ nrasd = CIMInstance(nprasd, path = iname, properties = np_prop)
+ try:
+ rpcs_conn.CreateChildResourcePool(ElementName=test_pool[i],
+ Settings=[nrasd.tomof()])
+ except pywbem.CIMError, details:
+ logger.error("Invoke CreateChildResourcePool() error when "
+ "create %s", np_id)
+ logger.error(details)
+ return FAIL
+
+ try:
+ np = get_typed_class(options.virt, 'NetworkPool')
+ netpool = EnumInstances(options.ip, np)
+ status = verify_pool(netpool, np_id)
+ if status != PASS:
+ raise Exception("Error in networkpool verification")
+
+ destroy_netpool(options.ip, options.virt, test_pool[i])
+ if status != PASS:
+ raise Exception("Unable to destroy networkpool %s"
+ % test_pool[i])
+ except Exception, details:
+ logger.error(detatils)
+ return FAIL
+
+ return status
+
if __name__ == "__main__":
sys.exit(main())