yunguol(a)cn.ibm.com wrote:
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1223373237 25200
# Node ID bc0dc02df8c3f5ac46d251c2b6534feb8a927011
# Parent 311bf6eda3786eb8e47ede06c4da6dc1570aff61
[TEST]#6 Fix HostedService - 04_reverse_errs.py to work with sblim base provider
installed
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 311bf6eda378 -r bc0dc02df8c3
suites/libvirt-cim/cimtest/HostedService/04_reverse_errs.py
--- a/suites/libvirt-cim/cimtest/HostedService/04_reverse_errs.py Sun Oct 05 23:56:40
2008 -0700
+++ b/suites/libvirt-cim/cimtest/HostedService/04_reverse_errs.py Tue Oct 07 02:53:57
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,45 +46,41 @@ 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
-
- servicelist = {get_typed_class(options.virt,
"ResourcePoolConfigurationService") : "RPCS",
- get_typed_class(options.virt,
"VirtualSystemManagementService") : "Management Service",
- get_typed_class(options.virt,
"VirtualSystemMigrationService") : "MigrationService"}
+ rpcs = get_typed_class(options.virt, "ResourcePoolConfigurationService")
+ vsms = get_typed_class(options.virt, "VirtualSystemManagementService")
+ vsmigrations = get_typed_class(options.virt,
"VirtualSystemMigrationService")
+
+ servicelist = {rpcs : "RPCS",
+ vsms : "Management Service",
+ vsmigrations : "MigrationService"}
conn = assoc.myWBEMConnection('http://%s' % options.ip,
(CIM_USER, CIM_PASS),
CIM_NS)
+ assoc_classname = get_typed_class(options.virt, "HostedService")
for k, v in servicelist.items():
- instanceref = CIMInstanceName(k,
- keybindings = {"Wrong" : v,
- "CreationClassName" :
"wrong",
- "SystemCreationClassName"
: host_sys.CreationClassName,
- "SystemName" :
host_sys.Name})
- names = []
- 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)
+ keys = {"Wrong" : v, "CreationClassName": k,\
+ "SystemCreationClassName": host_ccn, "SystemName" :
host_name}
+ ret = try_assoc(conn, k, assoc_classname, keys, "Name",\
+ exp_values['invalid_name'], bug_no="")
+ if ret != PASS:
+ logger.error("------ FAILED: Invalid Name Key Name.------")
+ return FAIL
- if rc == 0:
- logger.error("HostedService associator should NOT return excepted
result with a wrong key name and value of %s input" % k)
- status = FAIL
+ keys = {"Name" : v, "Wrong": k,
"SystemCreationClassName":\
+ host_ccn, "SystemName" : host_name}
+ ret = try_assoc(conn, k, assoc_classname, keys, "Name",\
+ exp_values['invalid_ccname'], bug_no="")
+ if ret != PASS:
+ logger.error("------ FAILED: Invalid Name Key Name.------")
+ return FAIL
return status
Daisy, I think you missed noticing my comment on the return status part
in the previous 2 patches of yours.
Never mind, Can you please change the last return status value and put
it outside the for loop, otherwise the verification of the remaining
information in the servicelist
vsms : "Management Service" and vsmigrations : "MigrationService" will
not get executed and the loop will exit immediately after verifying for
the RPCS.
Also, You can minimize the use of slash whenever not required.
Thanks and Regards,
Deepti.
_______________________________________________
Libvirt-cim mailing list
Libvirt-cim(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim