<br><tt><font size=2>libvirt-cim-bounces@redhat.com wrote on 2008-07-01
03:04:41:<br>
<br>
> # HG changeset patch<br>
> # User Kaitlin Rupert <karupert@us.ibm.com><br>
> # Date 1214852675 25200<br>
> # Node ID 7d3d5dcffad210d1da9f208ce1881f391a21ba9e<br>
> # Parent 692121d37b3aefafce0d6856d81468add629514d<br>
> [TEST] Some VirtualSystemManagementService -t 02_destroysystem.py
cleanup.<br>
> <br>
> Add checks to see if the define() / start() calls pass.<br>
> Added cleanup_env() function to destroy()/undefine() guest in case
of error.<br>
> Ensure status is set to PASS only if the guest is not found in the
<br>
> domain list after the DestroySystem() call is made.<br>
> <br>
> Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com><br>
> <br>
> diff -r 692121d37b3a -r 7d3d5dcffad2 suites/libvirt-<br>
> cim/cimtest/VirtualSystemManagementService/02_destroysystem.py<br>
> --- a/suites/libvirt-<br>
> cim/cimtest/VirtualSystemManagementService/02_destroysystem.py
Mon<br>
> Jun 30 09:58:36 2008 -0700<br>
> +++ b/suites/libvirt-<br>
> cim/cimtest/VirtualSystemManagementService/02_destroysystem.py
Mon<br>
> Jun 30 12:04:35 2008 -0700<br>
> @@ -35,47 +35,53 @@<br>
> sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']<br>
> default_dom = 'test_domain'<br>
> <br>
> +def cleanup_env(ip, cxml):<br>
> + cxml.destroy(ip)<br>
> + cxml.undefine(ip)<br>
> +<br>
> @do_main(sup_types)<br>
> def main():<br>
> options = main.options<br>
> <br>
> service = vsms.get_vsms_class(options.virt)(options.ip)<br>
> cxml = vxml.get_class(options.virt)(default_dom)<br>
> - cxml.define(options.ip)<br>
> - cxml.start(options.ip)<br>
> + ret = cxml.define(options.ip)<br>
> + if not ret:<br>
> + logger.error("Failed to define the
dom: %s", default_dom)<br>
> + return FAIL<br>
> + ret = cxml.start(options.ip)<br>
> + if not ret:<br>
> + logger.error("Failed to define the
dom: %s", default_dom)</font></tt>
<br>
<br><tt><font size=2> It's better to log the error as "logger.error("Failed
to create(or start) the dom: %s", default_dom)",</font></tt>
<br><tt><font size=2> which more reflect the actual failure.</font></tt>
<br><tt><font size=2><br>
> + cleanup_env(options.ip, cxml)<br>
> + return FAIL<br>
> <br>
> classname = get_typed_class(options.virt, 'ComputerSystem')<br>
> cs_ref = CIMInstanceName(classname, keybindings
= {<br>
>
'Name':default_dom,<br>
>
'CreationClassName':classname})<br>
> list_before = domain_list(options.ip, options.virt)<br>
> - status = PASS<br>
> - rc = -1<br>
> + if default_dom not in list_before:<br>
> + logger.error("Domain not in domain
list")<br>
> + cleanup_env(options.ip, cxml)<br>
> + return FAIL<br>
> <br>
> try:<br>
> service.DestroySystem(AffectedSystem=cs_ref)<br>
> - rc = 0<br>
> except Exception, details:<br>
> logger.error('Unknow exception happened')<br>
> logger.error(details)<br>
> - status = FAIL<br>
> + cleanup_env(options.ip, cxml)<br>
> + return FAIL<br>
> <br>
> list_after = domain_list(options.ip, options.virt)<br>
> <br>
> - status = PASS<br>
> - if default_dom not in list_before:<br>
> - logger.error("Domain not started,
check config")<br>
> + if default_dom in list_after:<br>
> + logger.error("Domain %s not destroyed:
provider didn't <br>
> return error" % \<br>
> +
default_dom)<br>
> + cleanup_env(options.ip, cxml)<br>
> status = FAIL<br>
> else:<br>
> - destroyed = set(list_before) - set(list_after)<br>
> - if len(destroyed) != 1:<br>
> - logger.error("Destroyed
multiple domains")<br>
> - status = FAIL<br>
> - elif default_dom not in destroyed:<br>
> - logger.error("Wrong
domain destroyed")<br>
> - status = FAIL<br>
> -<br>
> - cxml.undefine(options.ip)<br>
> + status = PASS<br>
> <br>
> return status<br>
> <br>
> <br>
> _______________________________________________<br>
> Libvirt-cim mailing list<br>
> Libvirt-cim@redhat.com<br>
> https://www.redhat.com/mailman/listinfo/libvirt-cim<br>
</font></tt>