libvirt-cim-bounces@redhat.com wrote on 2008-10-07 20:02:13:

>
>
> yunguol@cn.ibm.com wrote:
> > # HG changeset patch
> > # User Guolian Yun <yunguol@cn.ibm.com>
> > # Date 1223361281 25200
> > # Node ID 628b846c366a0c97fa97c18a5a7e2185c265188f
> > # Parent  311bf6eda3786eb8e47ede06c4da6dc1570aff61
> > [TEST] 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 311bf6eda378 -r 628b846c366a suites/libvirt-
> cim/cimtest/HostedResourcePool/03_forward_errs.py
> > --- a/suites/libvirt-
> cim/cimtest/HostedResourcePool/03_forward_errs.py   Sun Oct 05 23:
> 56:40 2008 -0700
> > +++ b/suites/libvirt-
> cim/cimtest/HostedResourcePool/03_forward_errs.py   Mon Oct 06 23:
> 34:41 2008 -0700
> > @@ -25,16 +25,21 @@ 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)"},
> >  
> Wrap it to 80 columns
> > +              "invalid_name"   : {"rc" : pywbem.CIM_ERR_NOT_FOUND, \
> > +                                  "desc" : "No such instance (Name)"}
> > +             }
> >
> >  sup_types=['Xen', 'KVM', 'XenFV', 'LXC']
> >  @do_main(sup_types)
> > @@ -42,30 +47,36 @@ def main():
> >      options = main.options
> >      status = PASS
> >  
> You can remove the status = PASS statement since the first access to
> status by get_host_sys() function will assign value to it.
>
> >      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" : "wrong", "CreationClassName" : host_sys.
> CreationClassName}
> > -    ret =  try_assoc(conn, classname, assoc_classname, keys,
> "Name", expr_values, bug_no="")
> > +    keys = {"Name" : host_sys, "CreationClassName" : "wrong"}
> > +    ret =  try_assoc(conn, classname, assoc_classname, keys, \
> > +                     "Name", expr_values['invalid_ccname'], 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
> CreationClassName Key Value.------")
> > +            status = ret
> >  
> No need to assign the ret to status, you can directly call return FAIL.
> > -    keys = {"Wrong" : host_sys.Name, "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 Value.------")
> > -        status = ret
> > +        if host_cn == 'Linux_ComputerSystem':
> > +            return XFAIL_RC(bug)
> > +        else:
> > +            logger.error("------ FAILED: Invalid Name Key Value.------")
> > +            status = ret
> >
> >  
> No need to assign the ret to status, you can directly call return FAIL.
> >      return status
> >  
> Can call return PASS here.
> >  if __name__ == "__main__":


  Thanks! #2 patch on the way.

> >
> > _______________________________________________
> > 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