[PATCH 0 of 2] Add a new test for checking the output of ModifyResourceSettings

This test corresponds to patch "Fix AddResourceSettings() so it returns ResultingResourceSettings[ ] result". You'll need that patch applied in order to run this test.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1259172739 28800 # Node ID 41148148bd523c1866676b7a8d94e6c5292a5628 # Parent 3809e6608c1f9a9a56cfcf94ac39d37b867b1efa [TEST] Update vsms_util functions for add and modify so they get the output Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 3809e6608c1f -r 41148148bd52 suites/libvirt-cim/lib/XenKvmLib/vsms_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py Mon Nov 23 17:34:35 2009 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py Wed Nov 25 10:12:19 2009 -0800 @@ -31,9 +31,28 @@ logger.error('Error invoking ModifyRS: %s', func_str) logger.error(details) +def call_modify_res(service, rasd): + try: + output = service.ModifyResourceSettings(ResourceSettings = [str(rasd)]) + if len(output) == 0: + raise Exception("ModifyResourceSettings failed to return output") + + out_param = "ResultingResourceSettings" + if output[1][out_param] is None: + raise Exception("ModifyResourceSettings failed to return %s" % \ + out_param) + except Exception, details: + logger.error(details) + return FAIL, None + + return PASS, output[1][out_param] + def mod_disk_res(server, service, cxml, dasd, ndpath): try: - service.ModifyResourceSettings(ResourceSettings = [str(dasd)]) + status, output = call_modify_res(service, dasd) + if status != PASS: + raise Exception("ModifyResourceSettings call failed") + cxml.dumpxml(server) dpath = cxml.xml_get_disk_source() if dpath != ndpath: @@ -48,7 +67,10 @@ def mod_net_res(server, service, virt, cxml, nasd, ntype, net_name): try: - service.ModifyResourceSettings(ResourceSettings = [str(nasd)]) + status, output = call_modify_res(service, nasd) + if status != PASS: + raise Exception("ModifyResourceSettings call failed") + cxml.dumpxml(server) type = cxml.xml_get_net_type() @@ -73,7 +95,10 @@ def mod_mem_res(server, service, cxml, masd, nmem): try: - service.ModifyResourceSettings(ResourceSettings=[str(masd)]) + status, output = call_modify_res(service, masd) + if status != PASS: + raise Exception("ModifyResourceSettings call failed") + cxml.dumpxml(server) mem = cxml.xml_get_mem() if int(mem) != int(nmem) * 1024: @@ -88,7 +113,10 @@ def mod_vcpu_res(server, service, cxml, pasd, ncpu, virt): try: - service.ModifyResourceSettings(ResourceSettings = [str(pasd)]) + status, output = call_modify_res(service, pasd) + if status != PASS: + raise Exception("ModifyResourceSettings call failed") + cxml.dumpxml(server) dom = cxml.xml_get_dom_name() cpu = virsh_vcpuinfo(server, dom, virt) @@ -109,10 +137,29 @@ logger.error('Error invoking AddRS: %s', func_str) logger.error(details) +def call_add_res(service, rasd, vssd_ref): + try: + output = service.AddResourceSettings(AffectedConfiguration=vssd_ref, + ResourceSettings=[str(rasd)]) + if len(output) == 0: + raise Exception("AddResourceSettings failed to return output") + + out_param = "ResultingResourceSettings" + if output[1][out_param] is None: + raise Exception("AddResourceSettings failed to return %s" % \ + out_param) + except Exception, details: + logger.error(details) + return FAIL + + return PASS + def add_disk_res(server, service, cxml, vssd_ref, dasd, attr): try: - service.AddResourceSettings(AffectedConfiguration=vssd_ref, - ResourceSettings=[str(dasd)]) + status = call_add_res(service, dasd, vssd_ref) + if status != PASS: + raise Exception("AddResourceSettings call failed") + cxml.dumpxml(server) disk_dev = cxml.get_value_xpath( '/domain/devices/disk/target/@dev[. = "%s"]' % attr['nddev']) @@ -131,8 +178,10 @@ def add_net_res(server, service, virt, cxml, vssd_ref, nasd, attr): try: - service.AddResourceSettings(AffectedConfiguration=vssd_ref, - ResourceSettings=[str(nasd)]) + status = call_add_res(service, nasd, vssd_ref) + if status != PASS: + raise Exception("AddResourceSettings call failed") + cxml.dumpxml(server) mac = cxml.get_value_xpath(

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1259172739 28800 # Node ID 7db32fc81594a4de815fb08aa3de56862f4db9d1 # Parent 41148148bd523c1866676b7a8d94e6c5292a5628 [TEST] Add a new test to verify the output of ModifyResourceSettings Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 41148148bd52 -r 7db32fc81594 suites/libvirt-cim/cimtest/VirtualSystemManagementService/24_verify_modifyres_output.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/24_verify_modifyres_output.py Wed Nov 25 10:12:19 2009 -0800 @@ -0,0 +1,86 @@ +#!/usr/bin/python +# +# Copyright 2009 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 +# +# This test verifies the output of the ModifyResourceSettings() call. +# ModifyResourceSettings() returns an array of RASS references. This reference +# should match the reference of the instance RASD we pass to the +# ModifyResourceSettings() call. + +import sys +from pywbem import CIMInstanceName +from XenKvmLib.vsms import get_vsms_class, get_dasd_class +from XenKvmLib import vxml +from CimTest.Globals import logger, CIM_NS +from XenKvmLib.const import do_main +from CimTest.ReturnCodes import PASS, FAIL +from XenKvmLib.vsms_util import call_modify_res + +sup_types = ['Xen', 'KVM', 'XenFV'] +default_dom = 'rstest_domain' + +@do_main(sup_types) +def main(): + options = main.options + + cn = "KVM_DiskResourceAllocationSettingData" + + service = get_vsms_class(options.virt)(options.ip) + cxml = vxml.get_class(options.virt)(default_dom) + + ndpath = cxml.secondary_disk_path + dasd = get_dasd_class(options.virt)(dev=cxml.xml_get_disk_dev(), + source=ndpath, + name=default_dom) + status = FAIL + + try: + ret = cxml.cim_define(options.ip) + if not ret: + raise Exception("Failed to define the dom: %s" % default_dom) + + status, out = call_modify_res(service, dasd) + if status != PASS: + raise Exception("Failed to modify %s's disk" % default_dom) + + keys = {"InstanceID" : dasd.InstanceID} + ref = CIMInstanceName(cn, keybindings=keys, namespace=CIM_NS) + + if len(out) != 1: + raise Exception("Expected 1 resulting RASD, got %d" % len(out)) + + if out[0] != ref: + raise Exception("Expected %s to be created, %s was instead" % \ + (ref, out[0])) + + status = PASS + + except Exception, details: + logger.error(details) + status = FAIL + + cxml.destroy(options.ip) + cxml.undefine(options.ip) + + return status + +if __name__ == "__main__": + sys.exit(main()) +

+1 On 11/25/2009 04:25 PM, Kaitlin Rupert wrote:
This test corresponds to patch "Fix AddResourceSettings() so it returns ResultingResourceSettings[ ] result". You'll need that patch applied in order to run this test.
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Richard Maciel, MSc IBM Linux Technology Center rmaciel@linux.vnet.ibm.com
participants (2)
-
Kaitlin Rupert
-
Richard Maciel