[Libvirt-cim] [PATCH] [TEST] #2 Check that the DefineSystem() result can be passed to GetInstance()

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Wed Jul 30 01:51:58 UTC 2008


> +
> +def define_system(host, virt, name, vssd, rasds):
> +    vsms_class = eval("vsms." + \
> +                          get_typed_class(virt,
> +                                          "VirtualSystemManagementService"))
> +
> +    service = vsms_class(host)
> +
> +    rc, results = service.DefineSystem(SystemSettings=vssd,
> +                                       ResourceSettings=rasds,
> +                                       ReferenceConfiguration=' ')
> +
> +    system = results["ResultingSystem"]

What if the DefineSystem call throws an exception or if results is None?
> +
> +    return rc, system
> +
> +def get_instance_by_ref(host, ref):
> +    conn = pywbem.WBEMConnection('http://%s' % host,
> +                                 (Globals.CIM_USER, Globals.CIM_PASS),
> +                                 ref.namespace)
> +    return conn.GetInstance(ref)
> +

> +
> + at do_main(sup_types)
> +def main():
> +    options = main.options
> +
> +    systemref = define_test_system(options)
> +
> +    if not isinstance(systemref, pywbem.CIMInstanceName):
> +        logger.error("ResultingSystem is not a Reference!")
> +        return FAIL
> +
> +    if systemref.namespace is None:
> +        logger.error("Returned reference had no namespace!")
> +        return FAIL
> +
> +    logger.info("GetInstance(%s)" % systemref)
> +    system = get_instance_by_ref(options.ip, systemref)
> +    
> +    if system["Name"] == default_dom:
> +        logger.info("Validated resulting system instance")
> +        return PASS
> +    else:
> +        logger.error("Result system was: %s instead of %s" % (system["Name"],
> +                                                              default_dom))
> +        return FAIL


You'll need to undefine the guest before the test returns in each if 
condition.


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




More information about the Libvirt-cim mailing list