[PATCH 0 of 2] [TEST] Update VSMS 06_addresource.py to support running guests.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1212424933 25200 # Node ID 76b7fc25cf2ed76481c002c8d3fef1e2e4c6effa # Parent af001ec333a331b7ac10895ebcadaff9383303f3 [TEST] Add vsms_util.py This module is for vsms related utility functions (for AddResource, ModifyResource, etc). Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r af001ec333a3 -r 76b7fc25cf2e suites/libvirt-cim/lib/XenKvmLib/vsms_util.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py Mon Jun 02 09:42:13 2008 -0700 @@ -0,0 +1,96 @@ +#!/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 pywbem +from CimTest import Globals +from CimTest.ReturnCodes import FAIL, PASS +from CimTest.Globals import logger + +def add_disk_res(server, service, cxml, vssd_ref, dasd, nddev): + try: + service.AddResourceSettings(AffectedConfiguration=vssd_ref, + ResourceSettings=[str(dasd)]) + cxml.dumpxml(server) + disk_dev = cxml.get_value_xpath( + '/domain/devices/disk/target/@dev[. = "%s"]' % nddev) + if disk_dev != nddev: + raise Exception('Error adding rs for disk_dev') + logger.info('good status for disk_dev') + except Exception, details: + logger.error('Error invoking AddRS') + logger.error(details) + return FAIL + + return PASS + +def add_net_res(server, service, cxml, vssd_ref, nasd, nnmac): + try: + service.AddResourceSettings(AffectedConfiguration=vssd_ref, + ResourceSettings=[str(nasd)]) + cxml.dumpxml(server) + net_mac = cxml.get_value_xpath( + '/domain/devices/interface/mac/@address[. = "%s"]' % nnmac) + if net_mac.lower() != nnmac: + raise Exception('Error adding rs for net_mac') + logger.info('good status for net_mac') + except Exception, details: + logger.error('Error invoking AddRS') + logger.error(details) + return FAIL + + return PASS + +def add_proc_res(server, service, cxml, vssd_ref, pasd, npvcpu): + try: + service.AddResourceSettings(AffectedConfiguration=vssd_ref, + ResourceSettings=[str(pasd)]) + cxml.dumpxml(server) + proc_vcpu = cxml.xml_get_vcpu() + if int(proc_vcpu) != int(npvcpu): + raise Exception('Error adding rs for proc_vcpu') + logger.info('good status for proc_vcpu') + status = PASS + except Exception, details: + logger.error('Error invoking AddRS') + logger.error(details) + return FAIL + + return PASS + +def add_mem_res(server, service, cxml, vssd_ref, masd, nmem): + try: + service.AddResourceSettings(AffectedConfiguration=vssd_ref, + ResourceSettings=[str(masd)]) + cxml.dumpxml(server) + mem = cxml.xml_get_mem() + if int(mem)/1024 != int(nmem): + raise Exception('Error adding rs for mem') + logger.info('good status for mem') + status = PASS + except Exception, details: + logger.error('Error invoking AddRS') + logger.error(details) + return FAIL + + return PASS + +

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1212425305 25200 # Node ID c43fd555c6f3d6e1ce67004aa6a5fc297631c94d # Parent 76b7fc25cf2ed76481c002c8d3fef1e2e4c6effa [TEST] Modify VSMS 06 to support both a defined and running guest. These changes also include: -Move the AddResource() calls to vsms_util. -Add support for adding memory resources. -Add logic so that test only adds mem/proc resources to a defined guest. -Add logic so the test doesn't add a disk ro a running KVM guest (KVM only supports attaching CD type devices, another test case is needed for this). This test currently fails on KVM due to an issue adding network - will follow up on this. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 76b7fc25cf2e -r c43fd555c6f3 suites/libvirt-cim/cimtest/VirtualSystemManagementService/06_addresource.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/06_addresource.py Mon Jun 02 09:42:13 2008 -0700 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/06_addresource.py Mon Jun 02 09:48:25 2008 -0700 @@ -31,11 +31,13 @@ from CimTest.Globals import logger from CimTest.Globals import do_main from CimTest.ReturnCodes import FAIL, PASS +from XenKvmLib import vsms_util sup_types = ['Xen', 'KVM'] default_dom = 'rstest_domain' nnmac = '99:aa:bb:cc:ee:ff' npvcpu = 2 +nmem = 256 @do_main(sup_types) def main(): @@ -49,8 +51,9 @@ service = vsms.get_vsms_class(options.virt)(options.ip) cxml = vxml.get_class(options.virt)(default_dom) classname = get_typed_class(options.virt, 'VirtualSystemSettingData') + inst_id = '%s:%s' % (options.virt, default_dom) vssd_ref = CIMInstanceName(classname, keybindings = { - 'InstanceID' : '%s:%s' % (options.virt, default_dom), + 'InstanceID' : inst_id, 'CreationClassName' : classname}) dasd = vsms.get_dasd_class(options.virt)(dev=nddev, source=cxml.secondary_disk_path, @@ -58,41 +61,48 @@ nasd = vsms.get_nasd_class(options.virt)(type='ethernet', mac=nnmac, name=default_dom) pasd = vsms.get_pasd_class(options.virt)(vcpu=npvcpu, name=default_dom) + masd = vsms.get_masd_class(options.virt)(megabytes=nmem, name=default_dom) status = FAIL - try: - cxml.define(options.ip) - # Add disk resource setting - service.AddResourceSettings(AffectedConfiguration=vssd_ref, - ResourceSettings=[str(dasd)]) - cxml.dumpxml(options.ip) - disk_dev = cxml.get_value_xpath( - '/domain/devices/disk/target/@dev[. = "%s"]' % nddev) - if disk_dev != nddev: - raise Exception('Error adding rs for disk_dev') - logger.info('good status for disk_dev') - # Add net resource setting - service.AddResourceSettings(AffectedConfiguration=vssd_ref, - ResourceSettings=[str(nasd)]) - cxml.dumpxml(options.ip) - net_mac = cxml.get_value_xpath( - '/domain/devices/interface/mac/@address[. = "%s"]' % nnmac) - if net_mac.lower() != nnmac: - raise Exception('Error adding rs for net_mac') - logger.info('good status for net_mac') - # Add processor resource setting - service.AddResourceSettings(AffectedConfiguration=vssd_ref, - ResourceSettings=[str(pasd)]) - cxml.dumpxml(options.ip) - proc_vcpu = cxml.xml_get_vcpu() - if int(proc_vcpu) != int(npvcpu): - raise Exception('Error adding rs for proc_vcpu') - logger.info('good status for proc_vcpu') - status = PASS - except Exception, details: - logger.error('Error invoking AddRS') - logger.error(details) + test_cases = ["define", "start"] + + for case in test_cases: + if case == "define": + ret = cxml.define(options.ip) + if not ret: + logger.error("Failed to define the dom: %s", default_dom) + return FAIL + else: + ret = cxml.start(options.ip) + if not ret: + cxml.undefine(options.ip) + logger.error("Failed to start the dom: %s", default_dom) + return FAIL + + if case == "define" or options.virt == "Xen" or options.virt == "XenFV": + status = vsms_util.add_disk_res(options.ip, service, cxml, vssd_ref, + dasd, nddev) + if status != PASS: + break + + status = vsms_util.add_net_res(options.ip, service, cxml, vssd_ref, + nasd, nnmac) + if status != PASS: + break + + if case == "define": + status = vsms_util.add_proc_res(options.ip, service, cxml, vssd_ref, + pasd, npvcpu) + if status != PASS: + break + + status = vsms_util.add_mem_res(options.ip, service, cxml, vssd_ref, + masd, nmem) + if status != PASS: + break + + cxml.destroy(options.ip) cxml.undefine(options.ip) return status

KR> -Add logic so that test only adds mem/proc resources to a defined guest. This is a valid thing to do in Xen, and changing memory will probably be supported in KVM pretty soon. It will also, of course, be something easily supported by LXC. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Kaitlin Rupert wrote:
Also support memory for defined guests.
_______________________________________________
Please ignore this set. This was dependent on the "Fix VSMS resource_add so that and additional tag is not added for processor" patch, which has been re-written. The changes in provider will impact the changes in this test. Will update and resend once the patch is in the tree. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Dan Smith
-
Kaitlin Rupert