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

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1225079524 25200 # Node ID 312f2fd41802726987313f7dbb366aa91923e3e9 # Parent 0f340004e1cd48f5ede60a68283a850ae60c9ebe [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 0f340004e1cd -r 312f2fd41802 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Fri Oct 24 01:04:38 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Sun Oct 26 20:52:04 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)]

KR> LXC guests only support Memory and Disk RASDS currently. I just added ProcRASD support for LXC a week or so ago. It doesn't support a VirtualQuantity, so perhaps it's not appropriate here, but it does exist :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
KR> LXC guests only support Memory and Disk RASDS currently.
I just added ProcRASD support for LXC a week or so ago. It doesn't support a VirtualQuantity, so perhaps it's not appropriate here, but it does exist :)
Yep, this is an old patch. Instead of removing the ProcRASD, I need to modify it so that we build the proper RASD for container's guests. Thanks! -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1223669037 25200 # Node ID b0fbd29f2f05c24229efc8dbc0053effe196e688 # Parent 312f2fd41802726987313f7dbb366aa91923e3e9 [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 312f2fd41802 -r b0fbd29f2f05 suites/libvirt-cim/lib/XenKvmLib/classes.py --- a/suites/libvirt-cim/lib/XenKvmLib/classes.py Sun Oct 26 20:52:04 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 312f2fd41802 -r b0fbd29f2f05 suites/libvirt-cim/lib/XenKvmLib/enumclass.py --- a/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Sun Oct 26 20:52:04 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Fri Oct 10 13:03:57 2008 -0700 @@ -429,7 +429,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.''' @@ -438,6 +438,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 b9d6b1978d21b530717cea02d50823531cb51371 # Parent b0fbd29f2f05c24229efc8dbc0053effe196e688 [TEST] #2 Add VSMS 15_mod_system_settings.py This test verifies the ModifySystemSettings() call. Updates: -Remove virt param from cleanup_env() -For LXC guests, return a XFAIL because the containers XML isn't updated by libvirt properly Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r b0fbd29f2f05 -r b9d6b1978d21 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,136 @@ +#!/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, XFAIL_RC +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 +bug = "00008" + +def cleanup_env(ip, 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) + if options.virt == "LXC": + return XFAIL_RC(bug) + return FAIL + + cleanup_env(options.ip, options.virt, cxml) + + return PASS + +if __name__ == "__main__": + sys.exit(main()) +
participants (2)
-
Dan Smith
-
Kaitlin Rupert