[Libvirt-cim] [PATCH] [TEST] #3 Update SettingsDefineCapabilities.01 to return less valeus in pool related function

yunguol at cn.ibm.com yunguol at cn.ibm.com
Fri Aug 1 05:37:18 UTC 2008


# HG changeset patch
# User Guolian Yun <yunguol at cn.ibm.com>
# Date 1217569031 25200
# Node ID bc7f9edeaa5ff372bf79e5ed699654a2a1aa26a3
# Parent  a289fb981e70e916ed1f0bbf1b7ba579e96502c6
[TEST] #3 Update SettingsDefineCapabilities.01 to return less valeus in pool related function

Signed-off-by: Guolian Yun <yunguol at cn.ibm.com>

diff -r a289fb981e70 -r bc7f9edeaa5f suites/libvirt-cim/cimtest/SettingsDefineCapabilities/01_forward.py
--- a/suites/libvirt-cim/cimtest/SettingsDefineCapabilities/01_forward.py	Wed Jul 30 20:01:53 2008 -0700
+++ b/suites/libvirt-cim/cimtest/SettingsDefineCapabilities/01_forward.py	Thu Jul 31 22:37:11 2008 -0700
@@ -63,7 +63,7 @@
 CIM_ERROR_GETINSTANCE, CIM_ERROR_ASSOCIATORS
 from XenKvmLib.classes import get_typed_class
 from XenKvmLib.common_util import cleanup_restore, create_diskpool_conf, \
-create_netpool_conf
+create_netpool_conf, destroy_netpool
 from XenKvmLib.common_util import print_field_error
 
 platform_sup = ['Xen', 'KVM', 'XenFV', 'LXC']
@@ -87,21 +87,21 @@
     return instance
 
 
-def init_list(virt, dpool, npool, mpool, ppool):
+def init_list(virt, pool):
     """
         Creating the lists that will be used for comparisons.
     """
-
+    
     if virt == 'LXC':
-        instlist = [ mpool.InstanceID ]
+        instlist = [ pool[1].InstanceID ]
         cllist = [ get_typed_class(virt, "MemResourceAllocationSettingData") ]
         rtype = { get_typed_class(virt, "MemResourceAllocationSettingData")  :  4 }
     else:    
         instlist = [ 
-                    dpool.InstanceID,
-                    mpool.InstanceID, 
-                    npool.InstanceID, 
-                    ppool.InstanceID
+                    pool[0].InstanceID,
+                    pool[1].InstanceID, 
+                    pool[2].InstanceID, 
+                    pool[3].InstanceID
                    ]
         cllist = [ 
                   get_typed_class(virt, "DiskResourceAllocationSettingData"),
@@ -130,10 +130,11 @@
 
 def get_pool_details(virt, server):  
     dpool = npool  = mpool  = ppool = None
+    pool_set = []
     try :
         status, diskid = create_diskpool_conf(server, virt)
         if status != PASS:
-            return status,  dpool, npool, mpool, ppool
+            return status, pool_set, None
 
         dpool = get_pool_info(virt, server, diskid, poolname="DiskPool")
         mpool = get_pool_info(virt, server, memid, poolname= "MemoryPool")
@@ -141,16 +142,23 @@
 
         status, test_network = create_netpool_conf(server, virt)
         if status != PASS:
-            return status,  dpool, npool, mpool, ppool
+            return status, pool_set, test_network
 
         netid = "%s/%s" % ("NetworkPool", test_network)
         npool = get_pool_info(virt, server, netid, poolname= "NetworkPool")
-    
+        if dpool.InstanceID == None or mpool.InstanceID == None \
+           or npool.InstanceID == None or ppool.InstanceID == None:
+           logger.error("Get pool None") 
+           cleanup_restore(server, virt)
+           destroy_netpool(server, virt, test_network)
+           return FAIL
+        else:
+           pool_set = [dpool, mpool, ppool, npool]      
     except Exception, detail:
         logger.error("Exception: %s", detail)
-        return FAIL, dpool, npool, mpool, ppool
+        return FAIL, pool_set, test_network
 
-    return PASS, dpool, npool, mpool, ppool
+    return PASS, pool_set, test_network
 
 def verify_rasd_fields(loop, assoc_info, cllist, rtype, rangelist):
     for inst in assoc_info:
@@ -164,10 +172,9 @@
 
     return PASS
 
-def verify_sdc_with_ac(virt, server, dpool, npool, mpool, ppool):
+def verify_sdc_with_ac(virt, server, pool):
     loop = 0 
-    instlist, cllist, rtype, rangelist = init_list(virt, dpool, npool, mpool, 
-                                                   ppool)
+    instlist, cllist, rtype, rangelist = init_list(virt, pool)
     assoc_cname = get_typed_class(virt, "SettingsDefineCapabilities")
     cn =  get_typed_class(virt, "AllocationCapabilities")
     for instid in sorted(instlist):
@@ -200,14 +207,15 @@
     server = options.ip
     virt = options.virt
 
-    status, dpool, npool, mpool, ppool = get_pool_details(virt, server)
-    if status != PASS or dpool.InstanceID == None or mpool.InstanceID == None \
-       or npool.InstanceID == None or ppool.InstanceID == None:
+    status, pool, test_network = get_pool_details(virt, server)
+    if status != PASS:
         cleanup_restore(server, virt)
+        destroy_netpool(server, virt, test_network)
         return FAIL
 
-    status = verify_sdc_with_ac(virt, server, dpool, npool, mpool, ppool)
+    status = verify_sdc_with_ac(virt, server, pool)
     cleanup_restore(server, virt)
+    destroy_netpool(server, virt, test_network)
     return status
     
 if __name__ == "__main__":




More information about the Libvirt-cim mailing list