[PATCH 0 of 3] [TEST] Add a test to verify ModifySystemSettings()

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1223669821 25200 # Node ID 419ea0c270bf4be5be590e68edc96f0311df7d03 # Parent 1b152e5e9a47ec932b5c18bb26f226d5896b5432 [TEST] Fix cim_define() for LXC LXC guests only support Memory and Disk RASDS currently. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 1b152e5e9a47 -r 419ea0c270bf suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Thu Oct 09 08:54:35 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Fri Oct 10 13:17:01 2008 -0700 @@ -482,7 +482,7 @@ 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)] + res_settings = [str(self.dasd), str(self.masd)] else: res_settings = [str(self.dasd), str(self.nasd), str(self.pasd), str(self.masd)]

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1223669037 25200 # Node ID 3e4bbcff3c709620d9d86860b417be4a9b563842 # Parent 419ea0c270bf4be5be590e68edc96f0311df7d03 [TEST] Update inst_to_mof() to convert CIM_CimtestClass instances to inst Also update GetInstance so it returns both CIMInstance and CIM_CimtestClass objects. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 419ea0c270bf -r 3e4bbcff3c70 suites/libvirt-cim/lib/XenKvmLib/classes.py --- a/suites/libvirt-cim/lib/XenKvmLib/classes.py Fri Oct 10 13:17:01 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/classes.py Fri Oct 10 13:03:57 2008 -0700 @@ -18,6 +18,7 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +import pywbem virt_types = ['Xen', 'KVM', 'XenFV', 'LXC'] @@ -47,6 +48,9 @@ #FIXME This function is only needed for libcmpiutil versions 0.4 and later. #Once version 0.4 is obsolete, this function should be removed. def inst_to_mof(inst): + if not isinstance(inst, pywbem.cim_obj.CIMInstance): + inst = inst.inst + mof_str = inst.tomof() mof_inst = "" diff -r 419ea0c270bf -r 3e4bbcff3c70 suites/libvirt-cim/lib/XenKvmLib/enumclass.py --- a/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Fri Oct 10 13:17:01 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Fri Oct 10 13:03:57 2008 -0700 @@ -495,7 +495,7 @@ return list -def GetInstance(host, cn, keys): +def GetInstance(host, cn, keys, ret_cim_inst=False): '''Resolve the enumeration given the @cn. Return a list of CIMInstance objects.''' @@ -504,6 +504,9 @@ try: inst = CIM_CimtestClass(host, ref) + + if ret_cim_inst: + inst = inst.inst except pywbem.CIMError, arg: print arg[1]

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1223669037 25200 # Node ID caea4cf97fcb3b095761496bc8d76502fd0039af # Parent 3e4bbcff3c709620d9d86860b417be4a9b563842 [TEST] Add VSMS 15_mod_system_settings.py This test verifies the ModifySystemSettings() call. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 3e4bbcff3c70 -r caea4cf97fcb suites/libvirt-cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py Fri Oct 10 13:03:57 2008 -0700 @@ -0,0 +1,133 @@ +#!/usr/bin/python +# +# Copyright 2008 IBM Corp. +# +# Authors: +# Kaitlin Rupert <karupert@us.ibm.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +import sys +import pywbem +from XenKvmLib import vsms +from XenKvmLib import vxml +from CimTest.Globals import logger +from CimTest.ReturnCodes import PASS, FAIL +from XenKvmLib.const import do_main, default_network_name +from XenKvmLib.classes import get_typed_class, inst_to_mof +from XenKvmLib.enumclass import GetInstance +from XenKvmLib.common_util import poll_for_state_change + +sup_types = ['Xen', 'KVM', 'XenFV', 'LXC'] +default_dom = 'rstest_domain' +cpu = 2 +RECOVERY_VAL = 3 +DEFINED_STATE = 3 + +def cleanup_env(ip, virt, cxml): + cxml.cim_destroy(ip) + cxml.undefine(ip) + +def get_vssd(ip, virt, get_cim_inst): + cn = get_typed_class(virt, "VirtualSystemSettingData") + inst = None + + try: + if virt == "XenFV": + virt = "Xen" + + key_list = {"InstanceID" : "%s:%s" % (virt, default_dom) } + inst = GetInstance(ip, cn, key_list, get_cim_inst) + + except Exception, details: + logger.error(details) + return FAIL, inst + + if inst is None: + return FAIL, inst + + return PASS, inst + +@do_main(sup_types) +def main(): + options = main.options + + test_cases = ["define", "start"] + 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, options.virt, cxml) + return FAIL + + if case == "start": + ret = cxml.start(options.ip) + if not ret: + logger.error("Failed to start %s", default_dom) + cleanup_env(options.ip, options.virt, cxml) + return FAIL + + 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, options.virt, cxml) + return FAIL + + inst['AutomaticRecoveryAction'] = pywbem.cim_types.Uint16(RECOVERY_VAL) + vssd = inst_to_mof(inst) + + ret = service.ModifySystemSettings(SystemSettings=vssd) + if ret[0] != 0: + logger.error("Failed to modify dom: %s", default_dom) + cleanup_env(options.ip, options.virt, cxml) + return FAIL + + 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) + if status != PASS: + logger.error("Failed to destroy %s", default_dom) + cleanup_env(options.ip, options.virt, cxml) + return FAIL + + 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, options.virt, cxml) + return FAIL + + 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, options.virt, cxml) + return FAIL + + cleanup_env(options.ip, options.virt, cxml) + + return PASS + +if __name__ == "__main__": + sys.exit(main()) +

libvirt-cim-bounces@redhat.com wrote on 2008-10-11 04:30:14:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1223669037 25200 # Node ID caea4cf97fcb3b095761496bc8d76502fd0039af # Parent 3e4bbcff3c709620d9d86860b417be4a9b563842 [TEST] Add VSMS 15_mod_system_settings.py
This test verifies the ModifySystemSettings() call.
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r 3e4bbcff3c70 -r caea4cf97fcb suites/libvirt- cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt- cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py Fri Oct 10 13:03:57 2008 -0700 @@ -0,0 +1,133 @@ +#!/usr/bin/python +# +# Copyright 2008 IBM Corp. +# +# Authors: +# Kaitlin Rupert <karupert@us.ibm.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +import sys +import pywbem +from XenKvmLib import vsms +from XenKvmLib import vxml +from CimTest.Globals import logger +from CimTest.ReturnCodes import PASS, FAIL +from XenKvmLib.const import do_main, default_network_name +from XenKvmLib.classes import get_typed_class, inst_to_mof +from XenKvmLib.enumclass import GetInstance +from XenKvmLib.common_util import poll_for_state_change + +sup_types = ['Xen', 'KVM', 'XenFV', 'LXC'] +default_dom = 'rstest_domain' +cpu = 2 +RECOVERY_VAL = 3 +DEFINED_STATE = 3 + +def cleanup_env(ip, virt, cxml): + cxml.cim_destroy(ip) + cxml.undefine(ip)
+ +def get_vssd(ip, virt, get_cim_inst): + cn = get_typed_class(virt, "VirtualSystemSettingData") + inst = None + + try: + if virt == "XenFV": + virt = "Xen" + + key_list = {"InstanceID" : "%s:%s" % (virt, default_dom) } + inst = GetInstance(ip, cn, key_list, get_cim_inst) + + except Exception, details: + logger.error(details) + return FAIL, inst + + if inst is None: + return FAIL, inst + + return PASS, inst + +@do_main(sup_types) +def main(): + options = main.options + + test_cases = ["define", "start"] + 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, options.virt, cxml) + return FAIL + + if case == "start": + ret = cxml.start(options.ip) + if not ret: + logger.error("Failed to start %s", default_dom) + cleanup_env(options.ip, options.virt, cxml) + return FAIL + + 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, options.virt, cxml) + return FAIL + + inst['AutomaticRecoveryAction'] = pywbem.cim_types. Uint16(RECOVERY_VAL) + vssd = inst_to_mof(inst) + + ret = service.ModifySystemSettings(SystemSettings=vssd) + if ret[0] != 0: + logger.error("Failed to modify dom: %s", default_dom) + cleanup_env(options.ip, options.virt, cxml) + return FAIL + + 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,
Can you remove 'virt' parameter here? It isn't used in cleanup_env() function. I'm not sure if you have any plans on it. Thanks! options.virt,
+ default_dom, DEFINED_STATE) + if status != PASS: + logger.error("Failed to destroy %s", default_dom) + cleanup_env(options.ip, options.virt, cxml) + return FAIL + + 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, options.virt, cxml) + return FAIL + + 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, options.virt, cxml) + return FAIL + + cleanup_env(options.ip, options.virt, cxml) + + return PASS + +if __name__ == "__main__": + sys.exit(main()) +
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

This test currently fails on LXC - will send a separate patch to fix that issue. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Guo Lian Yun
-
Kaitlin Rupert