[PATCH] [TEST] #2 Update VSMS 04_definesystem_ers.py to use cim_define()

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1231458233 28800 # Node ID 4fe54bc4c934de944f1aa4c47d4ed2ee27d2caa6 # Parent 860a4f93be18ad6d84b5ea8724be123b2980b479 [TEST] #2 Update VSMS 04_definesystem_ers.py to use cim_define() Add a err_rc and err_desc elements to the VirtCIM class. This will allow us to check the error code and error description in case of failed CIM method calls. Add two functions: set_sys_settings() and set_res_settings(). These allow the caller to set the VSSD and RASDs after the initial init() of the VirtCIM class. Some of the logic in cim_define() was changed to allow the passing of just a single RASD to DefineSystem() (instead of passing all the RASDs). Updates: -Create function to verify return code and error description if define fails Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 860a4f93be18 -r 4fe54bc4c934 suites/libvirt-cim/cimtest/VirtualSystemManagementService/04_definesystem_ers.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/04_definesystem_ers.py Thu Jan 08 15:30:13 2009 -0800 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/04_definesystem_ers.py Thu Jan 08 15:43:53 2009 -0800 @@ -23,17 +23,14 @@ # import sys -import pywbem -from VirtLib import utils -from XenKvmLib import vsms -from XenKvmLib.test_doms import undefine_test_domain -from XenKvmLib.common_util import create_using_definesystem +from pywbem import CIM_ERR_FAILED from CimTest.Globals import logger from XenKvmLib.const import do_main from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC +from XenKvmLib.vxml import get_class sup_types = ['Xen', 'KVM', 'XenFV', 'LXC'] -exp_rc = 1 #CMPI_RC_ERR_FAILED +exp_rc = CIM_ERR_FAILED exp_desc = 'Unable to parse embedded object' @do_main(sup_types) @@ -41,26 +38,28 @@ options = main.options dname = 'test_domain' - vssd, rasd = vsms.default_vssd_rasd_str(dom_name=dname, virt=options.virt) - params = {'vssd' : vssd, - 'rasd' : ['wrong'] - } + cxml = get_class(options.virt)(dname) - exp_err = {'exp_rc' : exp_rc, - 'exp_desc' : exp_desc - } + rasd_list = { "MemResourceAllocationSettingData" : "wrong" } + cxml.set_res_settings(rasd_list) + try: + ret = cxml.cim_define(options.ip) + if ret: + raise Exception('DefineSystem returned OK with invalid params') - rc = create_using_definesystem(dname, options.ip, params, ref_config=' ', - exp_err=exp_err, virt=options.virt) + status = cxml.verify_error_msg(exp_rc, exp_desc) + if status != PASS: + raise Exception('DefineSystem failed for an unexpected reason') - if rc != PASS: - logger.error('DefineSystem should NOT return OK with a wrong ss input') + except Exception, details: + logger.error(details) + status = FAIL - undefine_test_domain(dname, options.ip, virt=options.virt) + cxml.undefine(options.ip) - return rc + return status if __name__ == "__main__": sys.exit(main()) diff -r 860a4f93be18 -r 4fe54bc4c934 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Thu Jan 08 15:30:13 2009 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Thu Jan 08 15:43:53 2009 -0800 @@ -469,6 +469,8 @@ net_type, net_name, net_mac, vcpus, mem, mem_allocunits): self.virt = virt self.domain_name = dom_name + self.err_rc = None + self.err_desc = None self.vssd = vsms.get_vssd_mof(virt, dom_name) self.dasd = vsms.get_dasd_class(virt)(disk_dev, disk_source, dom_name) self.nasd = vsms.get_nasd_class(virt)(type=net_type, @@ -487,11 +489,17 @@ def cim_define(self, ip, ref_conf=None): service = vsms.get_vsms_class(self.virt)(ip) sys_settings = str(self.vssd) - if self.virt == 'LXC' and const.LXC_netns_support is False: - res_settings = [str(self.dasd), str(self.pasd), str(self.masd)] - else: - res_settings = [str(self.dasd), str(self.nasd), - str(self.pasd), str(self.masd)] + + res_settings = [] + if self.dasd is not None: + res_settings.append(str(self.dasd)) + if self.pasd is not None: + res_settings.append(str(self.pasd)) + if self.masd is not None: + res_settings.append(str(self.masd)) + if self.nasd is not None or \ + (self.virt == 'LXC' and const.LXC_netns_support is False): + res_settings.append(str(self.nasd)) if ref_conf is None: ref_conf = ' ' @@ -502,6 +510,8 @@ ReferenceConfiguration=ref_conf) except pywbem.CIMError, (rc, desc): logger.error('Got CIM error %s with return code %s' % (desc, rc)) + self.err_rc = rc + self.err_desc = desc return False except Exception, details: @@ -519,6 +529,12 @@ target = pywbem.cim_obj.CIMInstanceName(cs_cn, keybindings = keys) try: ret = service.DestroySystem(AffectedSystem=target) + except pywbem.CIMError, (rc, desc): + logger.error('Got CIM error %s with return code %s' % (desc, rc)) + self.err_rc = rc + self.err_desc = desc + return False + except Exception, details: logger.error('Error invoking DestroySystem') logger.error('Got error %s with exception %s' \ @@ -570,6 +586,12 @@ cs.RequestStateChange(RequestedState=req_state_change, TimeoutPeriod=time_period) + except pywbem.CIMError, (rc, desc): + logger.error('Got CIM error %s with return code %s' % (desc, rc)) + self.err_rc = rc + self.err_desc = desc + return FAIL + except Exception, detail: logger.error("In fn cim_state_change()") logger.error("Failed to change state of the domain '%s'", cs.Name) @@ -615,6 +637,36 @@ return self.cim_state_change(server, const.CIM_RESET, req_time, poll_time, const.CIM_ENABLE) + def set_sys_settings(self, vssd): + self.vssd = vssd + + def set_res_settings(self, rasd_list): + for cn, rasd in rasd_list.iteritems(): + if cn.find("MemResourceAllocationSettingData") >= 0: + self.masd = rasd + elif cn.find("ProcResourceAllocationSettingData") >= 0: + self.pasd = rasd + elif cn.find("DiskResourceAllocationSettingData") >= 0: + self.dasd = rasd + elif cn.find("NetResourceAllocationSettingData") >= 0: + self.nasd = rasd + + def verify_error_msg(self, exp_rc, exp_desc): + try: + rc = int(self.err_rc) + + if rc != exp_rc: + raise Exception("Got rc: %d, exp %d." % (rc, exp_rc)) + + if self.err_desc.find(exp_desc) < 0: + raise Exception("Got desc: '%s', exp '%s'" % (self.err_desc, + exp_desc)) + + except Exception, details: + logger.error(details) + return FAIL + + return PASS class XenXML(VirtXML, VirtCIM):

The tc fails with the following reason for LXC : -------------------------------------------------------------------- VirtualSystemManagementService - 04_definesystem_ers.py: FAIL ERROR - TypeError : __init__() takes exactly 12 arguments (11 given) Traceback (most recent call last): File "./lib/XenKvmLib/const.py", line 132, in do_try File "04_definesystem_ers.py", line 42, in main cxml = get_class(options.virt)(dname) File "./lib/XenKvmLib/vxml.py", line 855, in __init__ TypeError: __init__() takes exactly 12 arguments (11 given) ERROR - None -------------------------------------------------------------------- -- Thanks and Regards, Deepti B. Kalakeri IBM Linux Technology Center deeptik@linux.vnet.ibm.com

Deepti B Kalakeri wrote:
The tc fails with the following reason for LXC :
-------------------------------------------------------------------- VirtualSystemManagementService - 04_definesystem_ers.py: FAIL ERROR - TypeError : __init__() takes exactly 12 arguments (11 given) Traceback (most recent call last): File "./lib/XenKvmLib/const.py", line 132, in do_try File "04_definesystem_ers.py", line 42, in main cxml = get_class(options.virt)(dname) File "./lib/XenKvmLib/vxml.py", line 855, in __init__ TypeError: __init__() takes exactly 12 arguments (11 given) ERROR - None --------------------------------------------------------------------
This is because the VirtCIM has a new compulsory param emu_type which needs to passed from LXCXML, XenXML and XenFVXML. Daisy, Since you are working on the emulated type test case, can you verify this and correct the vxml.py ?? -- Thanks and Regards, Deepti B. Kalakeri IBM Linux Technology Center deeptik@linux.vnet.ibm.com

libvirt-cim-bounces@redhat.com wrote on 2009-01-12 13:40:13:
Deepti B Kalakeri wrote:
The tc fails with the following reason for LXC :
-------------------------------------------------------------------- VirtualSystemManagementService - 04_definesystem_ers.py: FAIL ERROR - TypeError : __init__() takes exactly 12 arguments (11 given) Traceback (most recent call last): File "./lib/XenKvmLib/const.py", line 132, in do_try File "04_definesystem_ers.py", line 42, in main cxml = get_class(options.virt)(dname) File "./lib/XenKvmLib/vxml.py", line 855, in __init__ TypeError: __init__() takes exactly 12 arguments (11 given) ERROR - None --------------------------------------------------------------------
This is because the VirtCIM has a new compulsory param emu_type which needs to passed from LXCXML, XenXML and XenFVXML.
Daisy, Since you are working on the emulated type test case, can you verify this and correct the vxml.py ??
I'm working on this, a patch will submit later. Thanks!
-- Thanks and Regards, Deepti B. Kalakeri IBM Linux Technology Center deeptik@linux.vnet.ibm.com
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

Deepti B Kalakeri wrote:
Deepti B Kalakeri wrote:
The tc fails with the following reason for LXC :
-------------------------------------------------------------------- VirtualSystemManagementService - 04_definesystem_ers.py: FAIL ERROR - TypeError : __init__() takes exactly 12 arguments (11 given) Traceback (most recent call last): File "./lib/XenKvmLib/const.py", line 132, in do_try File "04_definesystem_ers.py", line 42, in main cxml = get_class(options.virt)(dname) File "./lib/XenKvmLib/vxml.py", line 855, in __init__ TypeError: __init__() takes exactly 12 arguments (11 given) ERROR - None --------------------------------------------------------------------
This is because the VirtCIM has a new compulsory param emu_type which needs to passed from LXCXML, XenXML and XenFVXML.
Daisy, Since you are working on the emulated type test case, can you verify this and correct the vxml.py ??
Now that this fix is in, can I get another review of this patch? Thanks! -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

libvirt-cim-bounces@redhat.com wrote on 2009-01-16 06:59:20:
Deepti B Kalakeri wrote:
Deepti B Kalakeri wrote:
The tc fails with the following reason for LXC :
-------------------------------------------------------------------- VirtualSystemManagementService - 04_definesystem_ers.py: FAIL ERROR - TypeError : __init__() takes exactly 12 arguments (11 given) Traceback (most recent call last): File "./lib/XenKvmLib/const.py", line 132, in do_try File "04_definesystem_ers.py", line 42, in main cxml = get_class(options.virt)(dname) File "./lib/XenKvmLib/vxml.py", line 855, in __init__ TypeError: __init__() takes exactly 12 arguments (11 given) ERROR - None --------------------------------------------------------------------
This is because the VirtCIM has a new compulsory param emu_type which needs to passed from LXCXML, XenXML and XenFVXML.
Daisy, Since you are working on the emulated type test case, can you verify this and correct the vxml.py ??
Now that this fix is in, can I get another review of this patch?
+1. But you have to rebase and apply it into the tree. Thanks!
Thanks!
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
participants (3)
-
Deepti B Kalakeri
-
Guo Lian Yun
-
Kaitlin Rupert