[PATCH] [TEST] #2 Fix HostedResourcePool/03_forward_errs.py to work with sblim cmpi base provider installed

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1223519114 25200 # Node ID d9fd2890416a6f6c591431fb8e966df949d9c4d7 # Parent 285bc0174fb36512228e1cfcaba2186a0aa112c5 [TEST] #2 Fix HostedResourcePool/03_forward_errs.py to work with sblim cmpi base provider installed Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r 285bc0174fb3 -r d9fd2890416a suites/libvirt-cim/cimtest/HostedResourcePool/03_forward_errs.py --- a/suites/libvirt-cim/cimtest/HostedResourcePool/03_forward_errs.py Wed Oct 08 03:03:37 2008 -0700 +++ b/suites/libvirt-cim/cimtest/HostedResourcePool/03_forward_errs.py Wed Oct 08 19:25:14 2008 -0700 @@ -25,48 +25,57 @@ import pywbem import pywbem from XenKvmLib import assoc from XenKvmLib import enumclass +from XenKvmLib.common_util import get_host_info from XenKvmLib.common_util import try_assoc from CimTest import Globals from CimTest.Globals import logger -from CimTest.ReturnCodes import PASS, FAIL +from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC from XenKvmLib.const import do_main from XenKvmLib.classes import get_typed_class -expr_values = { "rc" : pywbem.CIM_ERR_NOT_FOUND, \ - "desc" : "No such instance" - } +bug = "00007" +expr_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)"} + } sup_types=['Xen', 'KVM', 'XenFV', 'LXC'] @do_main(sup_types) def main(): options = main.options - status = PASS keys = ['Name', 'CreationClassName'] - try: - host_sys = enumclass.enumerate(options.ip, 'HostSystem', keys, options.virt)[0] - except Exception: - host_cn = get_typed_class(options.virt, "HostSystem") - logger.error(Globals.CIM_ERROR_ENUMERATE % host_cn) + status, host_sys, host_cn = 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, (Globals.CIM_USER, Globals.CIM_PASS), Globals.CIM_NS) - classname = host_sys.CreationClassName + classname = host_cn assoc_classname = get_typed_class(options.virt, "HostedResourcePool") + keys = {"Name" : host_sys, "CreationClassName" : "wrong"} + ret = try_assoc(conn, classname, assoc_classname, keys, \ + "Name", expr_values['invalid_ccname'], bug_no="") + if ret != PASS: + if host_cn == 'Linux_ComputerSystem': + return XFAIL_RC(bug) + else: + logger.error("------ FAILED: Invalid CreationClassName Key Value.------") + return FAIL - keys = {"Name" : "wrong", "CreationClassName" : host_sys.CreationClassName} - ret = try_assoc(conn, classname, assoc_classname, keys, "Name", expr_values, bug_no="") + keys = {"Name" : "wrong", "CreationClassName" : host_cn} + ret = try_assoc(conn, classname, assoc_classname, keys, \ + "CreationClassName", expr_values['invalid_name'], bug_no="") if ret != PASS: - logger.error("------ FAILED: Invalid Name Key Name.------") - status = ret + if host_cn == 'Linux_ComputerSystem': + return XFAIL_RC(bug) + else: + logger.error("------ FAILED: Invalid Name Key Value.------") + return FAIL - keys = {"Wrong" : host_sys.Name, "CreationClassName" : host_sys.CreationClassName} - ret = try_assoc(conn, classname, assoc_classname, keys, "Name", expr_values, bug_no="") - if ret != PASS: - logger.error("------ FAILED: Invalid Name Key Value.------") - status = ret - - return status + return PASS if __name__ == "__main__": sys.exit(main())

+bug = "00007" +expr_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)"} + }
Can you align the lines so that the colons line up. Like: "invalid_ccname" : {"rc" : pywbem.CIM_ERR_NOT_FOUND, \ "desc" : "No such instance (CreationClassName)"}, Also, remove the \ at the end of these lines above.
+ ret = try_assoc(conn, classname, assoc_classname, keys, \
Remove \ at the end of the line.
+ ret = try_assoc(conn, classname, assoc_classname, keys, \
Same here - remove the \ at the end of the line. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

libvirt-cim-bounces@redhat.com wrote on 2008-10-09 23:15:10:
+bug = "00007" +expr_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)"} + }
Can you align the lines so that the colons line up. Like:
Sure. I will rewrite it.
"invalid_ccname" : {"rc" : pywbem.CIM_ERR_NOT_FOUND, \ "desc" : "No such instance (CreationClassName)"},
Also, remove the \ at the end of these lines above.
+ ret = try_assoc(conn, classname, assoc_classname, keys, \
Remove \ at the end of the line.
+ ret = try_assoc(conn, classname, assoc_classname, keys, \
Same here - remove the \ at the end of the line.
Would you please tell me when I have to add \ at the end of line? And when it doesn't need. Thanks!
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim


libvirt-cim-bounces@redhat.com wrote on 2008-10-10 14:11:37:
Guo Lian Yun wrote:
libvirt-cim-bounces@redhat.com wrote on 2008-10-09 23:15:10:
+bug = "00007" +expr_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)"} + }
Can you align the lines so that the colons line up. Like:
Sure. I will rewrite it.
"invalid_ccname" : {"rc" : pywbem.CIM_ERR_NOT_FOUND, \ "desc" : "No such instance (CreationClassName)"},
Also, remove the \ at the end of these lines above.
+ ret = try_assoc(conn, classname, assoc_classname, keys, \
Remove \ at the end of the line.
+ ret = try_assoc(conn, classname, assoc_classname, keys, \
Same here - remove the \ at the end of the line.
Would you please tell me when I have to add \ at the end of line? And when it doesn't need.
It would be easy to tell you where we need not have to add a \ than where to add it :). We dont have to add a \ after a comma in case of functions or in case of lists or dictionary above. for ex in case of the above try_assoc() we do not need a \ after the keys param. We need to add a \ at the end of the line only in case we cannot complete the statement within 80 columns.
For ex: logger.error("HostedService associator should NOT return excepted result with a wrong key name and value of %s input" % k)
The above log stmt would not fit in the 80 columns in a single line and hence we would require the stmt to be continued on the next line, we can do it using the \ as below:
logger.error("HostedService associator should NOT return excepted result with \ a wrong key name and value of %s input" % k)
But in case you do not want to use the \ you can write the above in the following way
logger.error("HostedService associator should NOT return excepted result with " "a wrong key name and value of %s input" % k)
The same thing applies if the element of the list does not accommodate in a single line within 80 columns.
For ex:
expr_values = { "invalid_ccname" : {"rc" : pywbem.CIM_ERR_NOT_FOUND, "desc": "No such instance "\ (CreationClassName)"}}
For ex above we do not need a \ after the value pywbem. CIM_ERR_NOT_FOUND of rc key in the list. But we would require a \ to complete the value "No such instance (CreationClassName)" of the key desc above. Again, as in the logger stmt we can write the above without the \ as follows:
expr_values = { "invalid_ccname" : { "rc" : pywbem.CIM_ERR_NOT_FOUND, "desc" : "No such instance " "(CreationClassName)"}}
The rule of using \ applies almost like in the C language, for ex in the pre processor stmts we make use of the \ if we are not able to complete the stmt in a single line. But we dont use it in case of function parameters distributed over 2 different lines.
Hope this helps.
Deepti, I'm much grateful of your explanation. It's really helpful to me. Thanks!
Thanks and Regards, Deepti.
Thanks!
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim _______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
participants (4)
-
Deepti B Kalakeri
-
Guo Lian Yun
-
Kaitlin Rupert
-
yunguol@cn.ibm.com