[Libvirt-cim] [PATCH 2 of 2] [TEST] Created reverse test (KVMRedirectionSAP -> HostSystem) test

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Fri Feb 6 20:40:24 UTC 2009


> +
> +def setup_env(server, virt):
> +    if virt == 'Xen':
> +        test_disk = 'xvda'
> +    else:
> +        test_disk = 'hda'
> +        virt_xml = get_class(virt)


> +        if virt == 'LXC':
> +            cxml = virt_xml(test_dom)
> +        else:
> +            cxml = virt_xml(test_dom, disk = test_disk)

These 4 lines need to be moved out from under the else.

> +
> +def get_kvmrsap_inst(virt, ip, guest_name):
> +    kvmrsap_inst = None 
> +
> +    try:
> +        kvmrsap_cn = get_typed_class(virt, 'KVMRedirectionSAP')
> +        enum_list = EnumInstances(ip, kvmrsap_cn)
> +
> +        for kvmrsap in enum_list:
> +            if kvmrsap.SystemName == guest_name:
> +                if kvmrsap_inst is not None:
> +                    print "More than one KVMRedirectionSAP found \
> +                           the same guest"
> +                    return kvmrsap_inst, FAIL

Remove the return here and change the print to a "raise Exception()" call.


> +                kvmrsap_inst = kvmrsap
> +
> +    except Exception, details:
> +        logger.error(details)
> +        return kvmrsap_inst, FAIL
> +
> +    return kvmrsap_inst, PASS
> +
> +def verify_host(enum_list, host_inst): 
> +    status = FAIL
> +
> +    for item in enum_list:

Remove the for loop.  Verify enum_list is just one element.

> +        if item.classname != host_inst.Classname:
> +            print "Returned class name (%s) is not correct", item.classname

This should be a logger.error() call.

> +            return status
> +
> +        if compare_all_prop(item, host_inst) == PASS:
> +            if status == PASS:
> +                print "More than one instance found"

This should be a logger.error() call.


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




More information about the Libvirt-cim mailing list