[Libvirt-cim] [PATCH] [TEST] #2 Modifying ResourcePool/01_enum.py to accomodate verifying Parent DiskPool and NetworkPool

Deepti B. Kalakeri deeptik at linux.vnet.ibm.com
Mon Jun 1 09:28:19 UTC 2009


# HG changeset patch
# User Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>
# Date 1243848479 25200
# Node ID 7e1e9ac3a390df22b3fbd8f8c760dd13e41aff88
# Parent  fe2f7e27210c2437d410484bd8f16a0714994321
[TEST] #2 Modifying ResourcePool/01_enum.py to accomodate verifying Parent DiskPool and NetworkPool.

Updates:
--------
Including the diskpool and netpool for LXC as well.

Tested with KVM on F10 with current sources.
Signed-off-by: Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>

diff -r fe2f7e27210c -r 7e1e9ac3a390 suites/libvirt-cim/cimtest/ResourcePool/01_enum.py
--- a/suites/libvirt-cim/cimtest/ResourcePool/01_enum.py	Fri May 29 02:01:50 2009 -0700
+++ b/suites/libvirt-cim/cimtest/ResourcePool/01_enum.py	Mon Jun 01 02:27:59 2009 -0700
@@ -30,9 +30,8 @@
 from XenKvmLib.enumclass import EnumInstances
 from XenKvmLib.classes import get_typed_class
 from XenKvmLib import vxml
-from CimTest import Globals
-from CimTest.Globals import logger
-from XenKvmLib.const import do_main, default_pool_name
+from CimTest.Globals import logger, CIM_ERROR_ENUMERATE
+from XenKvmLib.const import do_main, default_pool_name, LXC_netns_support
 from CimTest.ReturnCodes import PASS, FAIL, SKIP
 from XenKvmLib.xm_virt_util import net_list
 from XenKvmLib.vsms import RASD_TYPE_PROC, RASD_TYPE_MEM, RASD_TYPE_NET_ETHER, \
@@ -56,8 +55,8 @@
         netxml = vxml.NetXML(server, bridgename, test_network, virt)
         ret = netxml.create_vnet()
         if not ret:
-            logger.error("Failed to create the Virtual Network '%s'", \
-                                                           test_network)
+            logger.error("Failed to create the Virtual Network '%s'",
+                          test_network)
             return SKIP, None
 
     disk_instid = '%s/%s' % (dp_cn, default_pool_name)
@@ -77,25 +76,30 @@
     logger.error("Returned %s instead of %s", ret_value, exp_value)
 
 def verify_fields(pool_list, poolname, cn):
-    status = PASS
     if len(poolname) < 1:
         logger.error("%s return %i instances, expected atleast 1 instance",
                      cn, len(poolname))
         return FAIL
-    exp_value = pool_list[cn][0]
+
     for i in range(0, len(poolname)):
-        ret_value = poolname[i].InstanceID
-        if ret_value == exp_value:
-            break
-        elif ret_value != exp_value and i == len(poolname)-1:
-            print_error('InstanceID', ret_value, exp_value)
-            status = FAIL
-    ret_value = poolname[0].ResourceType
-    exp_value = pool_list[cn][1]
-    if ret_value != exp_value:
-        print_error('ResourceType', ret_value, exp_value)
-        status = FAIL
-    return status
+
+        rtype_ret_value = poolname[i].ResourceType
+        rtype_exp_value = pool_list[cn][1]
+        if rtype_ret_value != rtype_exp_value:
+            print_error('ResourceType', rtype_ret_value, rtype_exp_value)
+            return FAIL
+
+        inst_ret_value = poolname[i].InstanceID
+        inst_exp_value = pool_list[cn][0]
+        if "DiskPool/0" == inst_ret_value or "NetworkPool/0" == inst_ret_value:
+            if poolname[i].Primordial != True:
+                print_error('Primordial', poolname[i].Primordial, "True")
+                return FAIL
+        elif inst_ret_value != inst_exp_value and i == len(poolname)-1:
+            print_error('InstanceID', inst_ret_value, inst_exp_value)
+            return FAIL
+
+    return PASS
 
 
 @do_main(sup_types)
@@ -114,37 +118,24 @@
     mp = get_typed_class(virt, mp_cn)
     pp = get_typed_class(virt, pp_cn)
     dp = get_typed_class(virt, dp_cn)
-    np = get_typed_class(virt, np_cn)
+    cn_list = [ mp, pp, dp ]
 
-    try:
-        mempool = EnumInstances(ip, mp)
-    except Exception:
-        logger.error(Globals.CIM_ERROR_ENUMERATE, mp)
-        return FAIL
-    status = verify_fields(pool_list, mempool, mp)
-    
-    try:
-        propool = EnumInstances(ip, pp)
-    except Exception:
-        logger.error(Globals.CIM_ERROR_ENUMERATE, pp)
-        return FAIL
-    status = verify_fields(pool_list, propool, pp)
-   
-    if virt != 'LXC': 
+    if virt == 'LXC' and LXC_netns_support is False:
+        pass
+    else:
+        np = get_typed_class(virt, np_cn)
+        cn_list.append(np)
+
+    for cn in cn_list:
         try:
-            diskpool = EnumInstances(ip, dp)
-        except Exception:
-            logger.error(Globals.CIM_ERROR_ENUMERATE, dp)
+            pool = EnumInstances(ip, cn)
+        except Exception, details:
+            logger.error(CIM_ERROR_ENUMERATE, cn)
+            logger.error("Exception details: %s", details)
             return FAIL
-        status = verify_fields(pool_list, diskpool, dp)
-    
-    try:
-        netpool = EnumInstances(ip, np)
-    except Exception:
-        logger.error(Globals.CIM_ERROR_ENUMERATE, np)
-        return FAIL
-    status = verify_fields(pool_list, netpool, np)
-    
+        status = verify_fields(pool_list, pool, cn)
+        if status != PASS:
+            return status
     return status
 
 if __name__ == "__main__":




More information about the Libvirt-cim mailing list