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

yunguol at cn.ibm.com yunguol at cn.ibm.com
Thu Apr 16 07:55:30 UTC 2009


# HG changeset patch
# User Guolian Yun <yunguol at 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 at 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())
     




More information about the Libvirt-cim mailing list