[Libvirt-cim] [PATCH] [TEST] #5 Fix HostedService - 03_forward_errs.py to work with sblim base provider installed

yunguol at cn.ibm.com yunguol at cn.ibm.com
Tue Oct 7 02:55:29 UTC 2008


# HG changeset patch
# User Guolian Yun <yunguol at cn.ibm.com>
# Date 1223348123 25200
# Node ID 617b6fb544d62f056f281e75c15d2fcbebe3dac0
# Parent  311bf6eda3786eb8e47ede06c4da6dc1570aff61
[TEST] #5 Fix HostedService - 03_forward_errs.py to work with sblim base provider installed

Updats from 4 to 5:

Using try_assoc() function to verify the exceptions for the associtations

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

diff -r 311bf6eda378 -r 617b6fb544d6 suites/libvirt-cim/cimtest/HostedService/03_forward_errs.py
--- a/suites/libvirt-cim/cimtest/HostedService/03_forward_errs.py	Sun Oct 05 23:56:40 2008 -0700
+++ b/suites/libvirt-cim/cimtest/HostedService/03_forward_errs.py	Mon Oct 06 19:55:23 2008 -0700
@@ -25,6 +25,7 @@ from pywbem.cim_obj import CIMInstanceNa
 from pywbem.cim_obj import CIMInstanceName
 from XenKvmLib import assoc
 from XenKvmLib import enumclass
+from XenKvmLib.common_util import get_host_info, try_assoc
 from XenKvmLib.classes import get_typed_class
 from CimTest.Globals import logger, CIM_ERROR_ENUMERATE, CIM_USER, \
                             CIM_PASS, CIM_NS
@@ -32,8 +33,12 @@ from CimTest.ReturnCodes import PASS, FA
 from CimTest.ReturnCodes import PASS, FAIL, XFAIL
 
 sup_types = ['Xen', 'XenFV', 'KVM', 'LXC']
-exp_rc = 6 #CIM_ERR_NOT_FOUND
-exp_desc = "No such instance"
+exp_values = {
+              "invalid_ccname" : {"rc" : pywbem.CIM_ERR_NOT_FOUND, \
+                                  "desc" : "No such instance (CreationClassName)"},
+              "invalid_name"   : {"rc" : pywbem.CIM_ERR_NOT_FOUND, \
+                                  "desc" : "No such instance (Name)"}
+             }
 
 @do_main(sup_types)
 def main():
@@ -41,38 +46,31 @@ def main():
     rc = -1
     status = FAIL
     keys = ['Name', 'CreationClassName']
-    try:
-        host_sys = enumclass.enumerate(options.ip, 'HostSystem', keys, options.virt)[0]
-    except Exception:
-        logger.error(CIM_ERROR_ENUMERATE % host_sys.name)
+    status, host_name, host_ccn = get_host_info(options.ip, options.virt)
+    if status != PASS:
+        logger.error("Error in calling get_host_info function")
         return FAIL
 
     
     conn = assoc.myWBEMConnection('http://%s' % options.ip,                                        
                                   (CIM_USER, CIM_PASS),
                                    CIM_NS)
-    instanceref = CIMInstanceName(get_typed_class(options.virt, "HostSystem"), 
-                                  keybindings = {"Wrong" : "wrong", "CreationClassName" : host_sys.CreationClassName})
+    assoc_classname = get_typed_class(options.virt, "HostedService")
+    classname = get_typed_class(options.virt, "HostSystem")
+    
+    keys = {"Wrong" : host_name, "CreationClassName": host_ccn}
+    ret =  try_assoc(conn, host_ccn, assoc_classname, keys, "Name", exp_values['invalid_name'], bug_no="00007")
+    if ret != PASS and host_ccn == classname:
+        logger.error("------ FAILED: Invalid Name Key Name.------")
+        status = ret
 
-    names = []
+    keys = {"Name" : host_name, "Wrong" : host_ccn}
+    ret = try_assoc(conn, host_ccn, assoc_classname, keys, "CreationClassName", exp_values['invalid_ccname'], bug_no="00007")
+    if ret != PASS and host_ccn == classname:
+        logger.error("------ FAILED: Invalid CreationClassName Key Name.------")
+        status = ret
 
-    try:
-        names = conn.AssociatorNames(instanceref, AssocClass = get_typed_class(options.virt, "HostedService"))
-        rc = 0
-    except pywbem.CIMError, (rc, desc):
-        if rc == exp_rc and desc.find(exp_desc) >= 0:
-            logger.info("Got excepted rc code and error string")
-            status = PASS
-        else:
-            logger.error("Unexpected rc code %s and description %s\n" %(rc, desc))
-    except Exception, details:
-        logger.error("Unknown exception happened")
-        logger.error(details)
 
-    if rc == 0:
-        logger.error("HostedService associator should NOT return excepted result with a wrong key name and value of HostSystem input")
-        status = FAIL
-    
     return status        
 
 if __name__ == "__main__":




More information about the Libvirt-cim mailing list