[Libvirt-cim] [PATCH] [TEST] #2 Fixing 41_cs_to_settingdefinestate.py CS tc

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Wed Jan 7 17:40:14 UTC 2009


> +def get_cs_sysdev_info(server, virt, qcn, rasd_val):
> +    sd_info={}
> +    try: 
> +        cs_class = get_typed_class(virt, 'ComputerSystem')
> +        keys = { 'Name' : test_dom, 'CreationClassName' : cs_class }
> +        dom_cs = GetInstance(server, cs_class, keys)
> +        if dom_cs.Name != test_dom:
> +            raise Exception("Instance matching %s was not returned" % test_dom)
> +
> +        an = get_typed_class(virt, 'SystemDevice')
> +        sd_assoc = AssociatorNames(server, an, cs_class,
> +                                   CreationClassName=cs_class, 
> +                                   Name=test_dom)
> +        if len(sd_assoc) < 1:
> +            raise Exception ("%s returned %d %s objects"  \
> +                              % (an, len(sd_assoc), qcn))

Remove space between Exception and (.

> +
> +        status, sd_info = build_sd_info(sd_assoc, qcn, an, rasd_val)        
> +        if status != PASS:
> +            raise Exception ("Failed to get SystemDevice info for: %s" \
> +                             % test_dom)

Remove space between Exception and (.

> -                status = FAIL
> +                raise Exception("%s returned %d %s objects, Expected 1" \
> +                                % (an, len(assoc_info), cn))
> +            
> +            assoc_val = assoc_info[0]
> +            CCName = assoc_val.classname
> +            exp_rasd = rasd_values[CCName]
> +            if assoc_val['InstanceID'] != exp_rasd.InstanceID:
> +                raise Exception ("Got %s instead of %s" \
> +                                 % (assoc_val['InstanceID'], 
> +                                    exp_rasd.InstanceID))


Remove space between Exception and (.


> +def get_vssd_info(server, virt, in_vssdc_list, qcn): 
> +    try:
> +        # Get the vssd values which will be used for verifying the 
> +        # VSSD output from the VSSDC results.
> +        if virt == "XenFV":
> +            instIdval = "Xen:%s" % test_dom
> +        else:
> +            instIdval = "%s:%s" % (virt, test_dom)
> +
> +        vssd_class = get_typed_class(virt, 'VirtualSystemSettingData')
> +        keys = { 'InstanceID' : instIdval }
> +        vssd_values = GetInstance(server, vssd_class, keys)
> +        if vssd_values.ElementName != test_dom:
> +            raise Exception ("Instance matching %s was not returned"  % test_dom)

Remove space between Exception and (.

> +
> +        an = get_typed_class(virt, 'VirtualSystemSettingDataComponent')
> +        for cn, instid in sorted((in_vssdc_list.items())):
> +            status, vssd_assoc_info = get_associators_info(server, cn, an, 
> +                                                           vssd_class, 
> +                                                           instid)
>              if status != PASS:
> -                logger.error("Mistmatching RASD values" )
> -                break
> -            vs_name = assoc_info[index]['InstanceID']
> -            if vs_name.find(test_dom) >= 0:
> -                instid =  assoc_info[index]['InstanceID']
> -                in_vssdc[CCName] = instid 
> -    except Exception, detail:
> -        print_err(CIM_ERROR_ASSOCIATORS, detail, an)
> -        status = FAIL
> -    return status, in_vssdc
> +                raise Exception ("Failed to get VSSD info")

Remove space between Exception and (.

> 
> +            status = verify_values(vssd_assoc_info, vssd_values, an, qcn)    
> +            if status != PASS:
> +                raise Exception ("VSSD values verification error")

Remove space between Exception and (.

> 
> -def verify_fields(an, field_name, vssd_cs_assoc_info, vssd_cs_values):
> -    if vssd_cs_assoc_info[field_name] != vssd_cs_values[field_name]:
> -        vssd_sds_err(an, field_name, vssd_cs_assoc_info[field_name], \
> -                                           vssd_cs_values[field_name])
> -        return FAIL 
> -    return PASS 
> +    except Exception, details:
> +        logger.error("Exception details: %s", details)
> +        return FAIL, vssd_assoc_info 
> 
> +    return PASS, vssd_assoc_info 
> 
> -def verify_VSSD_values(assoc_info, vssd_values, an, qcn):
> -    # We expect that VirtualSystemSettingDataComponent returns only one 
> -    # VirtualSystemSettingData object when queried with disk, processor,
> -    # network and memory rasd's and all of them return the same output.
> -    exp_len = 1
> +def verify_vssdc_assoc(server, virt, cs_class, vssd_assoc_info, dom_cs): 
> +    try:
> +        # Since the VirtualSystemSettingDataComponent returns similar 
> +        # output when queried with every RASD, we are taking the output of 
> +        # the last associtaion query as inputs for 
> +        # querying SettingsDefineState.
> +        cn = vssd_assoc_info[0].classname
> +        an = get_typed_class(virt, 'SettingsDefineState')
> +        instid = vssd_assoc_info[0]['InstanceID']
> +        status, cs_assoc_info = get_associators_info(server, cn, an, 
> +                                                     cs_class, instid)
> +        if status != PASS:
> +            raise Exception ("Failed to get assoc info for dom: %s", test_dom)

Remove space between Exception and (.

> +        status, dom_cs, sd_info = get_cs_sysdev_info(server, virt, 
> +                                                      qcn, rasd_val)
> +        if status != PASS:
> +            raise Exception ("Failed to get SystemDevice information")

Remove space between Exception and (.

> +        status, sds_info = get_sds_info(server, virt, cs_class, rasd_val, 
> +                                        sd_info, qcn)
> +        if status != PASS:
> +            raise Exception ("Failed to get SetingDefineState information")

Remove space between Exception and (.

> +        status, vssd_assoc_info = get_vssd_info(server, virt, sds_info, qcn)
>          if status != PASS:
> -            break
> -    if status != PASS:
> -        vsxml.destroy(server)
> -        return status
> +            raise Exception ("Failed to get VSSD information")

Remove space between Exception and (.

> +        status = verify_vssdc_assoc(server, virt, cs_class,
> +                                    vssd_assoc_info, dom_cs)
> 
> -    # verify the results of SettingsDefineState with the cs_values list that was 
> -    # built using the output of the enumeration on ComputerSystem.
> -    status = verify_CS_values(cs_assoc_info, cs_values, an, qcn)
> +    except Exception, details:
> +        logger.error("Exception details is %s", details)
> +        status = FAIL
> +
>      vsxml.destroy(server)

This should be cim_destroy().  Otherwise, I think this looks much easier 
to read.  Thanks for overhauling this test!

-- 
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list