[Libvirt-cim] [PATCH] [TEST] Update CSI 01 to use cim_() functions
Deepti B Kalakeri
deeptik at linux.vnet.ibm.com
Wed Jan 7 11:30:43 UTC 2009
Kaitlin Rupert wrote:
> # HG changeset patch
> # User Kaitlin Rupert <karupert at us.ibm.com>
> # Date 1231271658 28800
> # Node ID d0b13b624d8c54bb8c625f3d0855ac7f80cdcdbd
> # Parent 270c97141e74456e051361572b2ba77af8f0fd94
> [TEST] Update CSI 01 to use cim_() functions.
>
> Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>
>
> diff -r 270c97141e74 -r d0b13b624d8c suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py
> --- a/suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py Tue Jan 06 11:09:46 2009 -0800
> +++ b/suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py Tue Jan 06 11:54:18 2009 -0800
> @@ -24,23 +24,17 @@
> import os
> import signal
> import time
>
Better way is to import time as below:
from time import sleep
> -from pywbem.cim_obj import CIMInstanceName
> from CimTest.Globals import logger
> from XenKvmLib.const import do_main
> from CimTest.ReturnCodes import PASS, FAIL
> -from XenKvmLib.common_util import create_using_definesystem, \
> - call_request_state_change
> -from XenKvmLib.test_doms import destroy_and_undefine_domain
> from XenKvmLib.classes import get_typed_class
> from XenKvmLib.indication_tester import CIMIndicationSubscription
> from XenKvmLib.vxml import set_default
> -from XenKvmLib.vsms import get_vsms_class
> +from XenKvmLib.vxml import get_class
>
> SUPPORTED_TYPES = ['Xen', 'XenFV', 'KVM']
>
> test_dom = "domU"
> -REQ_STATE = 2
> -TIME = "00000000000000.000000:000"
>
> def sub_ind(ip, virt):
> dict = set_default(ip)
> @@ -70,28 +64,24 @@
>
> return sub_list, ind_names, dict
>
> -def gen_ind(test_dom, ip, vtype, ind):
> +def gen_ind(test_dom, ip, vtype, ind, cxml):
> if ind == "define":
> - return create_using_definesystem(test_dom, ip, virt=vtype)
> + ret = cxml.cim_define(ip)
> + if not ret:
> + return FAIL
> + return PASS
>
>
You can remove the blank line from here.
> elif ind == "start":
> - rc = call_request_state_change(test_dom, ip, REQ_STATE, TIME, vtype)
> - if rc != 0:
> - logger.error("Failed to start domain: %s" % test_dom)
> + status = cxml.cim_start(ip)
> + if status != PASS:
> + logger.error("Failed to start domain: %s", test_dom)
> return FAIL
> return PASS
>
You can remove the blank line from here.
> elif ind == "destroy":
> - service = get_vsms_class(vtype)(ip)
> - try:
> - classname = get_typed_class(vtype, 'ComputerSystem')
> - cs_ref = CIMInstanceName(classname, keybindings = {
> - 'Name':test_dom,
> - 'CreationClassName':classname})
> - service.DestroySystem(AffectedSystem=cs_ref)
> - except Exception, details:
> - logger.error('Unknow exception happened')
> - logger.error(details)
> + ret = cxml.cim_destroy(ip)
> + if not ret:
> + logger.error("Unable to destroy %s", test_dom)
> return FAIL
> return PASS
>
> @@ -151,12 +141,16 @@
> @do_main(SUPPORTED_TYPES)
> def main():
> options = main.options
> + ip = options.ip
> + virt = options.virt
> status = FAIL
>
> - sub_list, ind_names, dict = sub_ind(options.ip, options.virt)
> + sub_list, ind_names, dict = sub_ind(ip, virt)
>
> ind_list = ["define", "start", "destroy"]
>
> + cxml = get_class(virt)(test_dom)
> +
> for ind in ind_list:
> sub = sub_list[ind]
> ind_name = ind_names[ind]
> @@ -171,7 +165,7 @@
> os._exit(0)
> else:
> try:
> - status = gen_ind(test_dom, options.ip, options.virt, ind)
> + status = gen_ind(test_dom, ip, virt, ind, cxml)
> if status != PASS:
> os.kill(pid, signal.SIGKILL)
> raise Exception("Unable to generate indication")
> @@ -190,7 +184,8 @@
> sub.unsubscribe(dict['default_auth'])
> logger.info("Cancelling subscription for %s" % ind_names[ind])
>
> - destroy_and_undefine_domain(test_dom, options.ip, options.virt)
> + cxml.cim_destroy(ip)
>
Calling the cim_destroy leaves the following error message in the log,
since the domain would have already been destroyed:
Wed, 07 Jan 2009 03:49:43:TEST LOG:ERROR - Error invoking DestroySystem
Wed, 07 Jan 2009 03:49:43:TEST LOG:ERROR - Got error (1,
u'CIM_ERR_FAILED: Failed to find domain') with exception CIMError
> + cxml.undefine(ip)
>
> return status
>
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim
>
--
Thanks and Regards,
Deepti B. Kalakeri
IBM Linux Technology Center
deeptik at linux.vnet.ibm.com
More information about the Libvirt-cim
mailing list