[Libvirt-cim] [PATCH] [TEST] Add try / except to VSMS 15
Kaitlin Rupert
kaitlin at linux.vnet.ibm.com
Thu Sep 3 18:15:12 UTC 2009
Ah, oops! Careless errors there. Thanks for catching these Deepti =)
Deepti B Kalakeri wrote:
>
>
> Kaitlin Rupert wrote:
>> # HG changeset patch
>> # User Kaitlin Rupert <karupert at us.ibm.com>
>> # Date 1251828184 25200
>> # Node ID ddb880e221d36151a9f91c3b0ab95f9cca97c2fa
>> # Parent 95fa64bf447e5bc2bab501564e3d9336edef997d
>> [TEST] Add try / except to VSMS 15
>>
>> This will catch any unexpected exceptions. Otherwise, the exception
>> isn't
>> caught and the guest may not be properly undefined
>>
>> Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>
>>
>> diff -r 95fa64bf447e -r ddb880e221d3
>> suites/libvirt-cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py
>>
>> ---
>> a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py
>> Thu Aug 27 16:39:53 2009 -0700
>> +++
>> b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py
>> Tue Sep 01 11:03:04 2009 -0700
>> @@ -74,72 +74,71 @@
>>
> Though it is not part of the changes in this patch, can you remove the
> following import statements from the tc:
>
> remove the import statement for default_network_name
>
>
>> cxml = vxml.get_class(options.virt)(default_dom, vcpus=cpu)
>> service = vsms.get_vsms_class(options.virt)(options.ip)
>>
>> - for case in test_cases:
>> - #Each time through, define guest using a default XML
>> - cxml.undefine(options.ip)
>> - cxml = vxml.get_class(options.virt)(default_dom, vcpus=cpu)
>> - ret = cxml.cim_define(options.ip)
>> - if not ret:
>> - logger.error("Failed to define the dom: %s", default_dom)
>> - cleanup_env(options.ip, cxml)
>> - return FAIL
>> + try:
>>
>> - if case == "start":
>> - ret = cxml.start(options.ip)
>> + for case in test_cases:
>> + #Each time through, define guest using a default XML
>> + cxml.undefine(options.ip)
>> + cxml = vxml.get_class(options.virt)(default_dom, vcpus=cpu)
>> + ret = cxml.cim_define(options.ip)
>> if not ret:
>> - logger.error("Failed to start %s", default_dom)
>> - cleanup_env(options.ip, cxml)
>> - return FAIL
>> + raise Exception("Failed to define the dom: %s",
>> default_dom)
>>
>>
> Remove the comma in the Exception statement and use % default instead,
> otherwise the exception will be printed as follows, the format string
> wont be substituted properly.
> ERROR - ('Failed to define the dom: %s', 'rstest_domain')
>
> Instead the above could be
>
> raise Exception("Failed to define the dom: %s" % default_dom)
>
> which would print the exception as below:
>
> ERROR - Failed to define the dom: rstest_domain
>
>
>
>> - status, inst = get_vssd(options.ip, options.virt, True)
>> - if status != PASS:
>> - logger.error("Failed to get the VSSD instance for %s",
>> default_dom)
>> - cleanup_env(options.ip, cxml)
>> - return FAIL
>> + if case == "start":
>> + ret = cxml.start(options.ip)
>> + if not ret:
>> + raise Exception("Failed to start %s", default_dom)
>>
> Same here Remove the comma in the Exception statement and use % after "
>> - inst['AutomaticRecoveryAction'] =
>> pywbem.cim_types.Uint16(RECOVERY_VAL)
>> - vssd = inst_to_mof(inst)
>> + status, inst = get_vssd(options.ip, options.virt, True)
>> + if status != PASS:
>> + raise Expcetion("Failed to get the VSSD instance for
>> %s", + default_dom)
>>
>>
> Same here Remove the comma in the Exception statement and use % after "
>> - ret = service.ModifySystemSettings(SystemSettings=vssd)
>> - curr_cim_rev, changeset = get_provider_version(options.virt,
>> options.ip)
>> - if curr_cim_rev >= libvirt_modify_setting_changes:
>> - if ret[0] != 0:
>> - logger.error("Failed to modify dom: %s", default_dom)
>> - cleanup_env(options.ip, cxml)
>> - return FAIL
>> + val = pywbem.cim_types.Uint16(RECOVERY_VAL)
>> + inst['AutomaticRecoveryAction'] = val
>> + vssd = inst_to_mof(inst)
>>
>> - if case == "start":
>> - #This should be replaced with a RSC to shutdownt he guest
>> - cxml.destroy(options.ip)
>> - status, cs = poll_for_state_change(options.ip,
>> options.virt, -
>> default_dom, DEFINED_STATE)
>> + ret = service.ModifySystemSettings(SystemSettings=vssd)
>> + curr_cim_rev, changeset =
>> get_provider_version(options.virt,
>> + options.ip)
>> + if curr_cim_rev >= libvirt_modify_setting_changes:
>> + if ret[0] != 0:
>> + raise Exception("Failed to modify dom: %s",
>> default_dom)
>> +
>> + if case == "start":
>> + #This should be replaced with a RSC to shutdownt he
>> guest
>> + cxml.destroy(options.ip)
>> + status, cs = poll_for_state_change(options.ip,
>> options.virt, +
>> default_dom, DEFINED_STATE)
>>
> you can use cim_destroy() instead.
>> + if status != PASS:
>> + raise Exception("Failed to destroy %s", default_dom)
>>
>
> Same here Remove the comma in the Exception statement and use % after "
>> +
>> + status, inst = get_vssd(options.ip, options.virt, False)
>> if status != PASS:
>> - logger.error("Failed to destroy %s", default_dom)
>> - cleanup_env(options.ip, cxml)
>> - return FAIL
>> + raise Exception("Failed to get the VSSD instance for
>> %s", + default_dom)
>>
>>
> Same here Remove the comma in the Exception statement and use % after "
>> - status, inst = get_vssd(options.ip, options.virt, False)
>> - if status != PASS:
>> - logger.error("Failed to get the VSSD instance for %s",
>> default_dom)
>> - cleanup_env(options.ip, cxml)
>> - return FAIL
>> + if inst.AutomaticRecoveryAction != RECOVERY_VAL:
>> + logger.error("Exp AutomaticRecoveryAction=%d, got
>> %d", + RECOVERY_VAL,
>> inst.AutomaticRecoveryAction)
>> + raise Exception("%s not updated properly.", default_dom)
>>
>>
> Same here Remove the comma in the Exception statement and use % after "
>> - if inst.AutomaticRecoveryAction != RECOVERY_VAL:
>> - logger.error("%s not updated properly.", default_dom)
>> - logger.error("Exp AutomaticRecoveryAction=%d, got %d",
>> RECOVERY_VAL,
>> - inst.AutomaticRecoveryAction)
>> - cleanup_env(options.ip, cxml)
>> - curr_cim_rev, changeset =
>> get_provider_version(options.virt, options.ip)
>> - if curr_cim_rev <= libvirt_f9_revision and options.virt
>> == "KVM":
>> - return XFAIL_RC(f9_bug)
>> + status = PASS
>>
>> - if options.virt == "LXC":
>> - return XFAIL_RC(bug)
>> - return FAIL + except Exception, details:
>> + logger.error(details)
>> + status = FAIL
>>
>> cleanup_env(options.ip, cxml)
>>
>> - return PASS + curr_cim_rev, changeset =
>> get_provider_version(options.virt, options.ip)
>> + if curr_cim_rev <= libvirt_f9_revision and options.virt == "KVM":
>> + return XFAIL_RC(f9_bug)
>> +
>> + if options.virt == "LXC":
>> + return XFAIL_RC(bug)
>> +
>> + return status
>> if __name__ == "__main__":
>> sys.exit(main())
>>
>> _______________________________________________
>> Libvirt-cim mailing list
>> Libvirt-cim at redhat.com
>> https://www.redhat.com/mailman/listinfo/libvirt-cim
>>
>
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com
More information about the Libvirt-cim
mailing list