[PATCH 0 of 2] [TEST] RefConf dup ID test

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1219102467 25200 # Node ID 38154e9f4053f0264293470b3346c52301bfed40 # Parent 0ffa5529fe3bc599cba875ac3927efe9e56b8626 [TEST] Add support for passed in parameters and RefConf to cim_define() Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 0ffa5529fe3b -r 38154e9f4053 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Mon Aug 18 14:08:49 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Mon Aug 18 16:34:27 2008 -0700 @@ -513,15 +513,23 @@ mallocunits=mem_allocunits, name=dom_name) - def cim_define(self, ip): + def cim_define(self, ip, params=None, ref_conf=None): service = vsms.get_vsms_class(self.virt)(ip) - sys_settings = str(self.vssd) - res_settings = [str(self.dasd), str(self.nasd), - str(self.pasd), str(self.masd)] + if params is None: + sys_settings = str(self.vssd) + res_settings = [str(self.dasd), str(self.nasd), + str(self.pasd), str(self.masd)] + else: + sys_settings = params['vssd'] + res_settings = params['rasds'] + + if ref_conf is None: + ref_conf = ' ' + try: service.DefineSystem(SystemSettings=sys_settings, ResourceSettings=res_settings, - ReferenceConfiguration=' ') + ReferenceConfiguration=ref_conf) except pywbem.CIMError, (rc, desc): logger.error('Got CIM error %s with return code %s' % (desc, rc)) return False

KR> - def cim_define(self, ip): KR> + def cim_define(self, ip, params=None, ref_conf=None): This is a class method, right? It seems weird to have a parameter to a class method that overrides the use of any of the class's private variables. AFAICT, this behaves like a class method when params=None and like a regular function when params is not None. Why not make cim_define() a regular function for the case where you need to pass in specific values and have the class method call it with the information from the class? KR> service = vsms.get_vsms_class(self.virt)(ip) KR> - sys_settings = str(self.vssd) KR> - res_settings = [str(self.dasd), str(self.nasd), KR> - str(self.pasd), str(self.masd)] KR> + if params is None: KR> + sys_settings = str(self.vssd) KR> + res_settings = [str(self.dasd), str(self.nasd), KR> + str(self.pasd), str(self.masd)] KR> + else: KR> + sys_settings = params['vssd'] KR> + res_settings = params['rasds'] For the record, I think that the current convention of passing in a dict with two specifically-named items instead of just another parameter to the method is pretty gross. Just in case you were wondering :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1219102467 25200 # Node ID b6fe952171c0dc980779650057df711bf77f9faf # Parent 38154e9f4053f0264293470b3346c52301bfed40 [TEST] Add RefConf test to verify dup IDs are removed This is done before defining the guest. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 38154e9f4053 -r b6fe952171c0 suites/libvirt-cim/cimtest/VirtualSystemManagementService/13_refconfig_additional_devs.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/13_refconfig_additional_devs.py Mon Aug 18 16:34:27 2008 -0700 @@ -0,0 +1,166 @@ +#!/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.common_util import call_request_state_change, \ + poll_for_state_change, get_cs_instance +from XenKvmLib import vsms +from VirtLib import utils +from CimTest.Globals import logger, do_main +from CimTest.ReturnCodes import FAIL, PASS +from XenKvmLib.test_doms import destroy_and_undefine_domain +from XenKvmLib.classes import get_typed_class +from XenKvmLib.assoc import AssociatorNames +from XenKvmLib.vxml import get_class + +sup_types = ['Xen', 'XenFV', 'KVM'] +test_dom = 'rstest_domain' +test_dom2 = 'rstest_domain2' + +REQUESTED_STATE = 2 +TIME = "00000000000000.000000:000" + +def get_vssd_ref(ip, virt): + rc, cs = get_cs_instance(test_dom, ip, virt) + if rc != 0: + return None + + cn = "ComputerSystem" + ccn = get_typed_class(virt, cn) + vssd = AssociatorNames(ip, 'SettingsDefineState', cn, virt=virt, + Name = test_dom, CreationClassName = ccn) + + if len(vssd) != 1: + logger.error("Returned %i vssd insts for '%s'", len(vssd), test_dom) + return None + + return vssd[0] + +def verify_no_dups(ip, virt, cxml, dom): + + if cxml.xml_get_disk_source() != cxml.dasd.Address: + logger.error("%s: Exp disk source %s" % (dom, cxml.dasd.Address)) + return FAIL + + if cxml.xml_get_disk_dev() != cxml.dasd.VirtualDevice: + logger.error("%s: Exp disk dev %s" % (dom, cxml.dasd.VirtualDevice)) + return FAIL + + if cxml.xml_get_net_type() != cxml.nasd.NetworkType: + logger.error("%s: Exp net type %d" % (dom, cxml.nasd.NetworkType)) + return FAIL + + if cxml.xml_get_net_mac() != cxml.nasd.Address: + logger.error("%s: Exp net mac %s" % (dom, cxml.nasd.Address)) + return FAIL + + vcpus = cxml.xml_get_vcpu() + if not vcpus.isdigit(): + logger.error("Unable to get vcpus value for %s" % dom) + return FAIL + + if int(vcpus) != cxml.pasd.VirtualQuantity: + logger.error("%s: Exp vcpus %s" % (dom, cxml.pasd.VirtualQuantity)) + return FAIL + + mem = cxml.xml_get_mem() + if not mem.isdigit(): + logger.error("Unable to get mem value for %s" % dom) + return FAIL + + if cxml.masd.AllocationUnits == "Bytes": + shift = -10 + elif cxml.masd.AllocationUnits == "KiloBytes": + shift = 0 + elif cxml.masd.AllocationUnits == "MegaBytes": + shift = 10 + elif cxml.masd.AllocationUnits == "GigaBytes": + multi_by = 20 + else: + shift = 0 + + exp_mem = cxml.masd.VirtualQuantity + if shift < 0: + exp_mem >>= -shift + else: + exp_mem <<= shift + + print exp_mem + + if int(mem) != exp_mem: + logger.error("%s: Exp mem %s" % (dom, exp_mem)) + return FAIL + + return PASS + +@do_main(sup_types) +def main(): + options = main.options + + virt_xml = get_class(options.virt) + cxml = virt_xml(test_dom) + cxml2 = virt_xml(test_dom2) + + try: + rc = cxml.cim_define(options.ip) + if not rc: + logger.error("Unable define domain %s" % test_dom) + raise Exception("Unable to define domain %s" % test_dom) + + ref = get_vssd_ref(options.ip, options.virt) + if ref is None: + raise Exception("Unable to get %s reference" % test_dom) + + rc = cxml2.cim_define(options.ip, ref_conf=ref) + if not rc: + logger.error("Unable define domain %s" % test_dom2) + raise Exception("Unable to define %s" % test_dom2) + + rc = call_request_state_change(test_dom2, options.ip, + REQUESTED_STATE, TIME, options.virt) + if rc != 0: + raise Exception("Unable to start %s" % test_dom2) + + status, dom_cs = poll_for_state_change(options.ip, options.virt, + test_dom2, REQUESTED_STATE) + if status != PASS: + raise Exception("%s didn't change state as expected" % test_dom2) + + status = verify_no_dups(options.ip, options.virt, cxml2, test_dom2) + if status != PASS: + raise Exception("%s devices not defined as expected" % test_dom2) + + status = PASS + + except Exception, details: + logger.error(details) + status = FAIL + + destroy_and_undefine_domain(test_dom, options.ip, options.virt) + destroy_and_undefine_domain(test_dom2, options.ip, options.virt) + + return status + +if __name__ == "__main__": + sys.exit(main()) +
participants (2)
-
Dan Smith
-
Kaitlin Rupert