yunguol(a)cn.ibm.com wrote:
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1223349190 25200
# Node ID 4650104669be81d74b92db23176fbc3ea36a8829
# Parent 311bf6eda3786eb8e47ede06c4da6dc1570aff61
[TEST] #5 Fix HostedService - 04_reverse_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(a)cn.ibm.com>
diff -r 311bf6eda378 -r 4650104669be
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 Mon Oct 06 20:13:10
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)"},
Wrap it to 80 columns.
+ "invalid_name" : {"rc" :
pywbem.CIM_ERR_NOT_FOUND, \
+ "desc" : "No such instance
(Name)"}
+ }
@do_main(sup_types)
def main():
@@ -41,45 +46,38 @@ 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, \
you can remove the slash here.
+ "SystemCreationClassName": host_ccn,
"SystemName" : host_name}
+ ret = try_assoc(conn, k, assoc_classname, keys, "Name",
exp_values['invalid_name'], bug_no="")
Wrap to 80 columns
+ if ret != PASS:
+ logger.error("------ FAILED: Invalid Name Key Name.------")
+ status = ret
return FAIL directly dont have to assign ret to status.
- 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="")
Wrap to 80 columns
+ if ret != PASS:
+ logger.error("------ FAILED: Invalid Name Key Name.------")
+ status = ret
return FAIL directly dont have to assign ret to status.
return status
This return statement should be outside the for loop otherwise the vsms,
vsmigrations wont get excetued.
_______________________________________________
Libvirt-cim mailing list
Libvirt-cim(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim