[Libvirt-cim] [PATCH] [TEST] Fixing the EAFP/01_forward.py and VSSDC/02_reverse.py by using cim_define() and cim_start()

Deepti B. Kalakeri deeptik at linux.vnet.ibm.com
Mon Feb 2 12:04:48 UTC 2009


# HG changeset patch
# User Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>
# Date 1233576225 28800
# Node ID aa594a83ba23554622b360346bb18088d510e293
# Parent  2ef1704ac58621c6e35bf604a32dd311e3bc6a3a
[TEST] Fixing the EAFP/01_forward.py and VSSDC/02_reverse.py by using cim_define() and cim_start().

Common changes to EAFP/01_forward.py and VSSDC/02_reverse.py:
-------------------------------------------------------------
Modified the tc to use cim_define() and cim_start() instead of create()
which was causing the tc to fail with Xen.

Changes to EAFP/01_forward.py:
------------------------------
1) Added try, except block.

Changes to VSSDC/02_reverse.py:
-------------------------------
1) Removed unnecessary Global import statement.
2) Did some Indentation changes to the tc to fit 80 columns.

The test cases can be further improved in the next cycle to make use of EnumInstances() and compare_all_prop()
to reduce the code and make it look more cleaner.

Tested for Xen with current sources.

Signed-off-by: Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>

diff -r 2ef1704ac586 -r aa594a83ba23 suites/libvirt-cim/cimtest/ElementAllocatedFromPool/01_forward.py
--- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/01_forward.py	Fri Jan 30 13:05:27 2009 -0800
+++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/01_forward.py	Mon Feb 02 04:03:45 2009 -0800
@@ -96,7 +96,6 @@ def get_pool_details(server, virt, vsxml
         key_list = {"InstanceID" : k}
         inst = get_inst(server, virt, cn, key_list)
         if inst is None:
-            vsxml.destroy(server)
             return FAIL, gi_inst_list 
         cn = get_typed_class(virt, cn)
         gi_inst_list[cn] = { 'InstanceID' : inst.InstanceID, 
@@ -127,9 +126,11 @@ def verify_eafp_values(server, virt, in_
             if assoc_eafp_info['InstanceID'] != gi_inst['InstanceID']:
                 field_err(assoc_eafp_info, gi_inst, 'InstanceID')
                 return FAIL
+
             if assoc_eafp_info['PoolID'] != gi_inst['PoolID']:
                 field_err(assoc_eafp_info, gi_inst, 'PoolID')
                 return FAIL
+
         except Exception, detail:
             logger.error(CIM_ERROR_ASSOCIATORS, an)
             logger.error("Exception: %s", detail)
@@ -156,31 +157,40 @@ def main():
         vsxml = virt_type(test_dom, vcpus = test_vcpus, mac = test_mac,
                        disk = test_disk)
 
-    ret = vsxml.create(server)
+    ret = vsxml.cim_define(server)
     if not ret:
-        logger.error("Failed to Create the dom: '%s'", test_dom)
+        logger.error("Failed to define the dom: '%s'", test_dom)
         return FAIL
-    
-    mem_cn  = get_typed_class(virt, "Memory")
-    ldlist = {
-                 mem_cn      : "%s/%s" % (test_dom, "mem"),
-             }
 
-    if virt != 'LXC':
-        disk_cn = get_typed_class(virt, "LogicalDisk") 
-        net_cn  = get_typed_class(virt, "NetworkPort")
-        proc_cn =  get_typed_class(virt, "Processor")
-        ldlist[disk_cn] = "%s/%s" % (test_dom, test_disk)
-        ldlist[net_cn]  = "%s/%s" % (test_dom, test_mac)
-        ldlist[proc_cn] = "%s/%s" % (test_dom, "0")
+    status = vsxml.cim_start(server)
+    if status != PASS:
+        logger.error("Failed to start the dom: '%s'", test_dom)
+        vsxml.undefine(server)
+        return FAIL
+    try: 
+        mem_cn  = get_typed_class(virt, "Memory")
+        ldlist = { mem_cn      : "%s/%s" % (test_dom, "mem") }
 
-    status, gi_inst_list = get_pool_details(server, virt, vsxml, 
-                                            default_pool_name)
-    if status != PASS:
-        return status
-     
-    status = verify_eafp_values(server, virt, ldlist, gi_inst_list)
+        if virt != 'LXC':
+            disk_cn = get_typed_class(virt, "LogicalDisk") 
+            net_cn  = get_typed_class(virt, "NetworkPort")
+            proc_cn =  get_typed_class(virt, "Processor")
+            ldlist[disk_cn] = "%s/%s" % (test_dom, test_disk)
+            ldlist[net_cn]  = "%s/%s" % (test_dom, test_mac)
+            ldlist[proc_cn] = "%s/%s" % (test_dom, "0")
+
+        status, gi_inst_list = get_pool_details(server, virt, vsxml, 
+                                                default_pool_name)
+        if status != PASS:
+            raise Exception("Failed to get pool details")
+ 
+        status = verify_eafp_values(server, virt, ldlist, gi_inst_list)
+    except Exception, details:
+        logger.error("Exception details : %s", details) 
+
     vsxml.destroy(server)
+    vsxml.undefine(server)
+
     return status
     
 if __name__ == "__main__":
diff -r 2ef1704ac586 -r aa594a83ba23 suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/02_reverse.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/02_reverse.py	Fri Jan 30 13:05:27 2009 -0800
+++ b/suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/02_reverse.py	Mon Feb 02 04:03:45 2009 -0800
@@ -47,13 +47,12 @@ import sys
 import sys
 from XenKvmLib import enumclass
 from VirtLib import utils
-from CimTest import Globals 
 from XenKvmLib import assoc
 from XenKvmLib.test_doms import destroy_and_undefine_all 
 from XenKvmLib import vxml
 from XenKvmLib.classes import get_typed_class
 from XenKvmLib.rasd import InstId_err
-from CimTest.Globals import logger
+from CimTest.Globals import logger, CIM_ERROR_ASSOCIATORS
 from XenKvmLib.const import do_main
 from CimTest.ReturnCodes import PASS, FAIL
 
@@ -157,16 +156,24 @@ def main():
         test_disk = "xvdb"
     else:
         test_disk = "hdb"
+
     virt_xml = vxml.get_class(options.virt)
     if options.virt == 'LXC':
         cxml = virt_xml(test_dom)
     else:
-        cxml = virt_xml(test_dom, vcpus = test_vcpus, mac = test_mac, disk = test_disk)
-    ret = cxml.create(options.ip)
+        cxml = virt_xml(test_dom, vcpus = test_vcpus, 
+                        mac = test_mac, disk = test_disk)
+
+    ret = cxml.cim_define(options.ip)
     if not ret:
-        logger.error("Failed to create the dom: %s", test_dom)
-        status = FAIL
-        return status
+        logger.error("Failed to define the dom: %s", test_dom)
+        return FAIL
+
+    ret = cxml.cim_start(options.ip)
+    if ret != PASS:
+        cxml.undefine(options.ip)
+        logger.error("Failed to start the dom: %s", test_dom)
+        return ret
 
     if options.virt == "XenFV":
         instIdval = "Xen:%s" % test_dom
@@ -179,10 +186,10 @@ def main():
         assoc_info = assoc.AssociatorNames(options.ip, an, cn,
                                            InstanceID = instIdval)
         status = assoc_values(options.ip, assoc_info, options.virt)
+
     except  Exception, detail :
-        logger.error(Globals.CIM_ERROR_ASSOCIATORS, 
-                     'VirtualSystemSettingDataComponent')
-        logger.error("Exception : %s" % detail)
+        logger.error(CIM_ERROR_ASSOCIATORS, an)
+        logger.error("Exception : %s", detail)
         status = FAIL
 
     cxml.destroy(options.ip)




More information about the Libvirt-cim mailing list