[PATCH] [TEST]Update RPCS/04 to validate that the Network child pool can be created through the providers

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1239868524 25200 # Node ID 860c994006a12104618e29bf051730993568bcc1 # Parent 4ec367c94c356de7fac5a19ffe215c316d0cdcd1 [TEST]Update RPCS/04 to validate that the Network child pool can be created through the providers Follow up patch will valide Disk child pool creation and verification in the same tc Tested for KVM with current sources Signed-off-by: Guolian Yun<yunguol@cn.ibm.com> diff -r 4ec367c94c35 -r 860c994006a1 suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py Wed Apr 08 02:22:53 2009 -0700 +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py Thu Apr 16 00:55:24 2009 -0700 @@ -52,32 +52,84 @@ 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 +testpool = "mypool" + +def verify_pool(pool_list, poolname): + status = PASS + if len(pool_list) < 1: + logger.error("Returen %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: + break + elif ret_pool != poolname and i == len(pool_list)-1: + logger.error("Can not find expected pool") + status = FAIL + + 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) + + 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') + np_id = 'NetworkPool/%s' % testpool + iname = CIMInstanceName(nprasd, + namespace = 'root/virt', + keybindings = {'InstanceID':np_id}) + logger.info('iname is %s', iname) + nrasd = CIMInstance(nprasd, path = iname, + properties ={ + "Address" : "192.168.0.30", + "Netmask" : "255.255.255.0", + "IPRangeStart" : "192.168.0.31", + "IPRangeEnd" : "192.168.0.57", + "ForwardMode":"route eth1"}) + try: + rpcs_conn.CreateChildResourcePool(ElementName=testpool, + Settings=[nrasd.tomof()]) + except pywbem.CIMError, details: + logger.error("Invoke CreateChildResourcePool() error") + logger.error(details) return FAIL - - logger.error("The execution should not have reached here!!") - return FAIL + + np = get_typed_class(options.virt, 'NetworkPool') + netpool = EnumInstances(options.ip, np) + status = verify_pool(netpool, np_id) + + destroy_netpool(options.ip, options.virt, testpool) + return status + if __name__ == "__main__": sys.exit(main())

yunguol@cn.ibm.com wrote:
# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1239868524 25200 # Node ID 860c994006a12104618e29bf051730993568bcc1 # Parent 4ec367c94c356de7fac5a19ffe215c316d0cdcd1 [TEST]Update RPCS/04 to validate that the Network child pool can be created through the providers
Follow up patch will valide Disk child pool creation and verification in the same tc
libvirt supports several different disk pool types. Not all of these are supported in libvirt-cim yet, but they will be in the future. I would put the disk pool verification in a different test, otherwise, this test might become to cluttered / confusing.
Tested for KVM with current sources Signed-off-by: Guolian Yun<yunguol@cn.ibm.com>
diff -r 4ec367c94c35 -r 860c994006a1 suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py Wed Apr 08 02:22:53 2009 -0700 +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py Thu Apr 16 00:55:24 2009 -0700 @@ -52,32 +52,84 @@
Can you update the comment block at the top of the test?
+ +def verify_pool(pool_list, poolname): + status = PASS + if len(pool_list) < 1: + logger.error("Returen %i instances, expected at least one instance",
Typo here.. this should be "Return"
+ len(pool_list)) + return FAIL + + for i in range(0, len(pool_list)): + ret_pool = pool_list[i].InstanceID + if ret_pool == poolname: + break + elif ret_pool != poolname and i == len(pool_list)-1: + logger.error("Can not find expected pool") + status = FAIL
This for loop is a little odd. Why not set status to FAIL at the top of the function. If you find the pool you are looking for, set status to PASS and break from the loop. If you don't find the pool, then status will be FAIL at the end of the loop.
+ elif curr_cim_rev >= libvirt_cim_child_pool_rev: + nprasd = get_typed_class(options.virt, + 'NetPoolResourceAllocationSettingData') + np_id = 'NetworkPool/%s' % testpool + iname = CIMInstanceName(nprasd, + namespace = 'root/virt', + keybindings = {'InstanceID':np_id}) + logger.info('iname is %s', iname) + nrasd = CIMInstance(nprasd, path = iname, + properties ={ + "Address" : "192.168.0.30", + "Netmask" : "255.255.255.0", + "IPRangeStart" : "192.168.0.31", + "IPRangeEnd" : "192.168.0.57", + "ForwardMode":"route eth1"})
Since this test will be network pool specific, can you also test the other types of network pools (http://libvirt.org/formatnetwork.html#examples)
+ try: + rpcs_conn.CreateChildResourcePool(ElementName=testpool, + Settings=[nrasd.tomof()]) + except pywbem.CIMError, details: + logger.error("Invoke CreateChildResourcePool() error") + logger.error(details) return FAIL - - logger.error("The execution should not have reached here!!") - return FAIL + + np = get_typed_class(options.virt, 'NetworkPool') + netpool = EnumInstances(options.ip, np) + status = verify_pool(netpool, np_id) + + destroy_netpool(options.ip, options.virt, testpool)
Also be sure to undefine the pool as well.

libvirt-cim-bounces@redhat.com wrote on 2009-04-17 07:04:05:
yunguol@cn.ibm.com wrote:
# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1239868524 25200 # Node ID 860c994006a12104618e29bf051730993568bcc1 # Parent 4ec367c94c356de7fac5a19ffe215c316d0cdcd1 [TEST]Update RPCS/04 to validate that the Network child pool can be created through the providers
Follow up patch will valide Disk child pool creation and verification in the same tc
libvirt supports several different disk pool types. Not all of these are
supported in libvirt-cim yet, but they will be in the future. I would put the disk pool verification in a different test, otherwise, this test
might become to cluttered / confusing.
Tested for KVM with current sources Signed-off-by: Guolian Yun<yunguol@cn.ibm.com>
diff -r 4ec367c94c35 -r 860c994006a1 suites/libvirt-
cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py
--- a/suites/libvirt- cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool. py Wed Apr 08 02:22:53 2009 -0700 +++ b/suites/libvirt- cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool. py Thu Apr 16 00:55:24 2009 -0700 @@ -52,32 +52,84 @@
Can you update the comment block at the top of the test?
+ +def verify_pool(pool_list, poolname): + status = PASS + if len(pool_list) < 1: + logger.error("Returen %i instances, expected at least oneinstance",
Typo here.. this should be "Return"
+ len(pool_list)) + return FAIL + + for i in range(0, len(pool_list)): + ret_pool = pool_list[i].InstanceID + if ret_pool == poolname: + break + elif ret_pool != poolname and i == len(pool_list)-1: + logger.error("Can not find expected pool") + status = FAIL
This for loop is a little odd. Why not set status to FAIL at the top of the function. If you find the pool you are looking for, set status to PASS and break from the loop. If you don't find the pool, then status will be FAIL at the end of the loop.
+ elif curr_cim_rev >= libvirt_cim_child_pool_rev: + nprasd = get_typed_class(options.virt, + 'NetPoolResourceAllocationSettingData') + np_id = 'NetworkPool/%s' % testpool + iname = CIMInstanceName(nprasd, + namespace = 'root/virt', + keybindings = {'InstanceID':np_id}) + logger.info('iname is %s', iname) + nrasd = CIMInstance(nprasd, path = iname, + properties ={ + "Address" : "192.168.0.30", + "Netmask" : "255.255.255.0", + "IPRangeStart" : "192.168.0.31", + "IPRangeEnd" : "192.168.0.57", + "ForwardMode":"route eth1"})
Since this test will be network pool specific, can you also test the other types of network pools (http://libvirt.org/formatnetwork.html#examples)
The NAT based network has to set ForwaredMode by "nat", I'm not sure how to test isolated network? Which properties has to set for this type? Thanks!
+ try: + rpcs_conn.CreateChildResourcePool(ElementName=testpool, + Settings=[nrasd.tomof()]) + except pywbem.CIMError, details: + logger.error("Invoke CreateChildResourcePool() error") + logger.error(details) return FAIL - - logger.error("The execution should not have reached here!!") - return FAIL + + np = get_typed_class(options.virt, 'NetworkPool') + netpool = EnumInstances(options.ip, np) + status = verify_pool(netpool, np_id) + + destroy_netpool(options.ip, options.virt, testpool)
Also be sure to undefine the pool as well.
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

+ elif curr_cim_rev >= libvirt_cim_child_pool_rev: + nprasd = get_typed_class(options.virt, + 'NetPoolResourceAllocationSettingData') + np_id = 'NetworkPool/%s' % testpool + iname = CIMInstanceName(nprasd, + namespace = 'root/virt', + keybindings = {'InstanceID':np_id}) + logger.info('iname is %s', iname) + nrasd = CIMInstance(nprasd, path = iname, + properties ={ + "Address" : "192.168.0.30", + "Netmask" : "255.255.255.0", + "IPRangeStart" : "192.168.0.31", + "IPRangeEnd" : "192.168.0.57", + "ForwardMode":"route eth1"})
Since this test will be network pool specific, can you also test the other types of network pools (http://libvirt.org/formatnetwork.html#examples)
The NAT based network has to set ForwaredMode by "nat", I'm not sure how to test isolated network? Which properties has to set for this type? Isolated would look like:
properties ={ "Address" : "192.168.0.30", "Netmask" : "255.255.255.0", "IPRangeStart" : "192.168.0.31", "IPRangeEnd" : "192.168.0.57"}
participants (3)
-
Guo Lian Yun
-
Kaitlin Rupert
-
yunguol@cn.ibm.com