[PATCH 0 of 2] [TEST] Remove try_getinstance()

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1229978071 28800 # Node ID d105e486f092f065749f77f44c7f522eae8f7aab # Parent a1eb0390e4bb3bb1a468411a33e5c666fe998bee [TEST] Remove try_getinstance() from RS - 03_RedirectionSAP_errs.py try_getinstance() is no longer needed - this function can be implemented using functions from enumclass.py. Plus, a conn needs to be passed to the function, which is poor function design. This also fixes the failure seeing on sfcb Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r a1eb0390e4bb -r d105e486f092 suites/libvirt-cim/cimtest/RedirectionService/03_RedirectionSAP_errs.py --- a/suites/libvirt-cim/cimtest/RedirectionService/03_RedirectionSAP_errs.py Mon Dec 22 02:56:58 2008 -0800 +++ b/suites/libvirt-cim/cimtest/RedirectionService/03_RedirectionSAP_errs.py Mon Dec 22 12:34:31 2008 -0800 @@ -32,19 +32,36 @@ ################################################################################ import sys -import pywbem -from XenKvmLib import assoc -from XenKvmLib.common_util import try_getinstance +from pywbem import CIM_ERR_NOT_FOUND, CIMError, CIM_ERR_FAILED +from pywbem.cim_obj import CIMInstanceName +from CimTest.ReturnCodes import PASS, FAIL, SKIP +from CimTest.Globals import logger from XenKvmLib.classes import get_typed_class from XenKvmLib import vxml -from CimTest.ReturnCodes import PASS, FAIL, SKIP -from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS from XenKvmLib.const import do_main, get_provider_version +from XenKvmLib.enumclass import EnumInstances, CIM_CimtestClass test_dom = "demo" test_vcpus = 1 sup_types = ['Xen', 'XenFV', 'KVM', 'LXC'] +def get_sap_inst(virt, ip, cn, guest_name): + try: + enum_list = EnumInstances(ip, cn) + + if enum_list < 1: + logger.error("No %s instances returned", cn) + return None, FAIL + + for item in enum_list: + if item.SystemName == guest_name: + return item, PASS + + except Exception, details: + logger.error(details) + + return None, FAIL + @do_main(sup_types) def main(): options = main.options @@ -59,8 +76,6 @@ "hence skipping the test ....") return SKIP - name = "%s:%s" % ("1", "1") - # Getting the VS list and deleting the test_dom if it already exists. cxml = vxml.get_class(options.virt)(test_dom, vcpus=test_vcpus) ret = cxml.cim_define(options.ip) @@ -69,27 +84,28 @@ logger.error("ERROR: VS '%s' is not defined", test_dom) return status - conn = assoc.myWBEMConnection( 'http://%s' % options.ip, - (CIM_USER, CIM_PASS), CIM_NS) + classname = get_typed_class(options.virt, 'KVMRedirectionSAP') - classname = get_typed_class(options.virt, 'KVMRedirectionSAP') + sap, status = get_sap_inst(options.virt, options.ip, classname, test_dom) + if status != PASS: + cxml.undefine(options.ip) + return status key_vals = { - 'SystemName': test_dom, - 'CreationClassName': classname, - 'SystemCreationClassName': get_typed_class(options.virt, - 'ComputerSystem'), - 'Name': name + 'SystemName' : sap.SystemName, + 'CreationClassName' : sap.CreationClassName, + 'SystemCreationClassName': sap.SystemCreationClassName, + 'Name' : sap.Name } expr_values = { - "invalid_ccname" : {'rc' : pywbem.CIM_ERR_NOT_FOUND, + "invalid_ccname" : {'rc' : CIM_ERR_NOT_FOUND, 'desc' : "No such instance (CreationClassName)" }, - "invalid_sccname" : {'rc' : pywbem.CIM_ERR_NOT_FOUND, + "invalid_sccname" : {'rc' : CIM_ERR_NOT_FOUND, 'desc' : "No such instance (SystemCreationClassName)" }, - "invalid_nameport" : {'rc' : pywbem.CIM_ERR_FAILED, + "invalid_nameport" : {'rc' : CIM_ERR_FAILED, 'desc' : "Unable to determine console port for guest" }, - "invalid_sysval" : {'rc' : pywbem.CIM_ERR_NOT_FOUND, + "invalid_sysval" : {'rc' : CIM_ERR_NOT_FOUND, 'desc' : "No such instance" } } @@ -101,15 +117,30 @@ } # Looping by passing invalid key values - for field, test_val in tc_scen.items(): + for test_val, field in tc_scen.items(): newkey_vals = key_vals.copy() - newkey_vals[test_val] = field - status = try_getinstance(conn, classname, newkey_vals, - field_name=test_val, - expr_values = expr_values[field], - bug_no = "") + newkey_vals[field] = test_val + exp_values = expr_values[test_val] + + ref = CIMInstanceName(classname, keybindings=newkey_vals) + + try: + inst = CIM_CimtestClass(options.ip, ref) + + except CIMError, (err_no, err_desc): + exp_rc = exp_values['rc'] + exp_desc = exp_values['desc'] + + if err_no == exp_rc and err_desc.find(exp_desc) >= 0: + logger.info("Got expected exception: %s %s", exp_desc, exp_rc) + status = PASS + else: + logger.error("Unexpected errno %s, desc %s", err_no, err_desc) + logger.error("Expected %s %s", exp_desc, exp_rc) + + if status != PASS: - logger.error(" -------------- FAILED %s ----------- : " % field) + logger.error(" -------------- FAILED %s ----------- : " % test_val) break cxml.cim_destroy(options.ip)

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1229978073 28800 # Node ID 3c36bba0147a505e769e9bb330e661859a723b82 # Parent d105e486f092f065749f77f44c7f522eae8f7aab [TEST] Remove try_getinstance() try_getinstance() is no longer needed Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r d105e486f092 -r 3c36bba0147a suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Dec 22 12:34:31 2008 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Dec 22 12:34:33 2008 -0800 @@ -239,20 +239,6 @@ " '%s' passed.", assoc_classname, field_name) return XFAIL_RC(bug_no) -def try_getinstance(conn, classname, keys, field_name, expr_values, bug_no): - inst = None - try: - instanceref = CIMInstanceName(classname, keybindings=keys) - logger.info ("Instanceref is '%s'", instanceref) - inst = conn.GetInstance(instanceref) - except pywbem.CIMError, (err_no, err_desc): - exp_rc = expr_values['rc'] - exp_desc = expr_values['desc'] - return verify_err_desc(exp_rc, exp_desc, err_no, err_desc) - logger.error("'%s' GetInstance failed to generate an exception and" - " '%s' passed.", classname, field_name) - return XFAIL_RC(bug_no) - def profile_init_list(): sys_prof_info = { "InstanceID" : "CIM:DSP1042-SystemVirtualization-1.0.0",

+1 for this patch set. Best, Regards Daisy (运国莲) VSM Team, China Systems & Technology Labs (CSTL) E-mail: yunguol@cn.ibm.com TEL: (86)-21-60922403 Building 10, 399 Ke Yuan Rd, Pudong Shanghai, 201203 Kaitlin Rupert <kaitlin@linux.vnet.ibm.com> Sent by: libvirt-cim-bounces@redhat.com 2008-12-23 04:35 Please respond to List for discussion and development of libvirt CIM <libvirt-cim@redhat.com> To libvirt-cim@redhat.com cc Subject [Libvirt-cim] [PATCH 0 of 2] [TEST] Remove try_getinstance() _______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
participants (2)
-
Guo Lian Yun
-
Kaitlin Rupert