[Libvirt-cim] [PATCH] [TEST] Add try / except to VSMS 15

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Tue Sep 1 18:35:45 UTC 2009


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1251828184 25200
# Node ID ddb880e221d36151a9f91c3b0ab95f9cca97c2fa
# Parent  95fa64bf447e5bc2bab501564e3d9336edef997d
[TEST] Add try / except to VSMS 15

This will catch any unexpected exceptions.  Otherwise, the exception isn't
caught and the guest may not be properly undefined

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r 95fa64bf447e -r ddb880e221d3 suites/libvirt-cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py	Thu Aug 27 16:39:53 2009 -0700
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py	Tue Sep 01 11:03:04 2009 -0700
@@ -74,72 +74,71 @@
     cxml = vxml.get_class(options.virt)(default_dom, vcpus=cpu)
     service = vsms.get_vsms_class(options.virt)(options.ip)
 
-    for case in test_cases:
-        #Each time through, define guest using a default XML
-        cxml.undefine(options.ip)
-        cxml = vxml.get_class(options.virt)(default_dom, vcpus=cpu)
-        ret = cxml.cim_define(options.ip)
-        if not ret:
-            logger.error("Failed to define the dom: %s", default_dom)
-            cleanup_env(options.ip, cxml)
-            return FAIL
+    try:
 
-        if case == "start":
-            ret = cxml.start(options.ip)
+        for case in test_cases:
+            #Each time through, define guest using a default XML
+            cxml.undefine(options.ip)
+            cxml = vxml.get_class(options.virt)(default_dom, vcpus=cpu)
+            ret = cxml.cim_define(options.ip)
             if not ret:
-                logger.error("Failed to start %s", default_dom)
-                cleanup_env(options.ip, cxml)
-                return FAIL
+                raise Exception("Failed to define the dom: %s", default_dom)
 
-        status, inst = get_vssd(options.ip, options.virt, True)
-        if status != PASS:
-            logger.error("Failed to get the VSSD instance for %s", default_dom)
-            cleanup_env(options.ip, cxml)
-            return FAIL
+            if case == "start":
+                ret = cxml.start(options.ip)
+                if not ret:
+                    raise Exception("Failed to start %s", default_dom)
 
-        inst['AutomaticRecoveryAction'] = pywbem.cim_types.Uint16(RECOVERY_VAL)
-        vssd = inst_to_mof(inst)
+            status, inst = get_vssd(options.ip, options.virt, True)
+            if status != PASS:
+                raise Expcetion("Failed to get the VSSD instance for %s", 
+                                default_dom)
 
-        ret = service.ModifySystemSettings(SystemSettings=vssd) 
-        curr_cim_rev, changeset = get_provider_version(options.virt, options.ip)
-        if curr_cim_rev >= libvirt_modify_setting_changes:
-            if ret[0] != 0:
-                logger.error("Failed to modify dom: %s", default_dom)
-                cleanup_env(options.ip, cxml)
-                return FAIL
+            val = pywbem.cim_types.Uint16(RECOVERY_VAL)
+            inst['AutomaticRecoveryAction'] = val
+            vssd = inst_to_mof(inst)
 
-        if case == "start":
-            #This should be replaced with a RSC to shutdownt he guest
-            cxml.destroy(options.ip)
-            status, cs = poll_for_state_change(options.ip, options.virt, 
-                                               default_dom, DEFINED_STATE)
+            ret = service.ModifySystemSettings(SystemSettings=vssd) 
+            curr_cim_rev, changeset = get_provider_version(options.virt, 
+                                                           options.ip)
+            if curr_cim_rev >= libvirt_modify_setting_changes:
+                if ret[0] != 0:
+                    raise Exception("Failed to modify dom: %s", default_dom)
+
+            if case == "start":
+                #This should be replaced with a RSC to shutdownt he guest
+                cxml.destroy(options.ip)
+                status, cs = poll_for_state_change(options.ip, options.virt, 
+                                                   default_dom, DEFINED_STATE)
+                if status != PASS:
+                    raise Exception("Failed to destroy %s", default_dom)
+
+            status, inst = get_vssd(options.ip, options.virt, False)
             if status != PASS:
-                logger.error("Failed to destroy %s", default_dom)
-                cleanup_env(options.ip, cxml)
-                return FAIL
+                raise Exception("Failed to get the VSSD instance for %s", 
+                                default_dom)
 
-        status, inst = get_vssd(options.ip, options.virt, False)
-        if status != PASS:
-            logger.error("Failed to get the VSSD instance for %s", default_dom)
-            cleanup_env(options.ip, cxml)
-            return FAIL
+            if inst.AutomaticRecoveryAction != RECOVERY_VAL:
+                logger.error("Exp AutomaticRecoveryAction=%d, got %d", 
+                             RECOVERY_VAL, inst.AutomaticRecoveryAction)
+                raise Exception("%s not updated properly.", default_dom)
 
-        if inst.AutomaticRecoveryAction != RECOVERY_VAL:
-            logger.error("%s not updated properly.", default_dom)
-            logger.error("Exp AutomaticRecoveryAction=%d, got %d", RECOVERY_VAL,
-                         inst.AutomaticRecoveryAction)
-            cleanup_env(options.ip, cxml)
-            curr_cim_rev, changeset = get_provider_version(options.virt, options.ip)
-            if curr_cim_rev <= libvirt_f9_revision and options.virt == "KVM":
-                return XFAIL_RC(f9_bug)
+            status = PASS
 
-            if options.virt == "LXC":
-                return XFAIL_RC(bug)
-            return FAIL 
+    except Exception, details:
+        logger.error(details)
+        status = FAIL
 
     cleanup_env(options.ip, cxml)
 
-    return PASS 
+    curr_cim_rev, changeset = get_provider_version(options.virt, options.ip)
+    if curr_cim_rev <= libvirt_f9_revision and options.virt == "KVM":
+        return XFAIL_RC(f9_bug)
+
+    if options.virt == "LXC":
+        return XFAIL_RC(bug)
+
+    return status 
 
 if __name__ == "__main__":
     sys.exit(main())




More information about the Libvirt-cim mailing list