<br><font size=2 face="sans-serif">+1 =)</font>
<br>
<br><tt><font size=2>libvirt-cim-bounces@redhat.com wrote on 2008-07-02
04:46:16:<br>
<br>
> # HG changeset patch<br>
> # User Kaitlin Rupert <karupert@us.ibm.com><br>
> # Date 1214945125 25200<br>
> # Node ID ea52dde5ac3e1b10d5aa59b101d91b8ffc5b127e<br>
> # Parent cb09fbc0900ca656f629057742f19f1771fed4f8<br>
> [TEST] #2 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>
> Updated from 1 to 2:<br>
> -Fix error message - if we are unable to start the guest, error
<br>
> message should say "Failed to start the dom: %s"<br>
> <br>
> Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com><br>
> <br>
> diff -r cb09fbc0900c -r ea52dde5ac3e suites/libvirt-<br>
> cim/cimtest/VirtualSystemManagementService/02_destroysystem.py<br>
> --- a/suites/libvirt-<br>
> cim/cimtest/VirtualSystemManagementService/02_destroysystem.py
Tue<br>
> Jul 01 13:42:52 2008 -0700<br>
> +++ b/suites/libvirt-<br>
> cim/cimtest/VirtualSystemManagementService/02_destroysystem.py
Tue<br>
> Jul 01 13:45:25 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 start the
dom: %s", default_dom)<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>