[PATCH 0 of 3] Patchset to fix VSMS 08_modifyresource.py

This test is out of date. The network portions needed to be updated to support the network interface type. Also, test only attempted to modify a defined guest, not a running guest.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1211403918 25200 # Node ID 94274683dee5aed5621dc555c8604dc56b378c85 # Parent 93dbca94a762bb2ba443025db96d43977484c40d [TEST] #2 Update create_netpool_conf() to support new pool creation. This includes the following changes: -Updated create_netpool_conf() so that caller can specify whether to use an existing pool or create a new pool. -Added destroy_netpool() / destroy_vnet() -Updated CIM_NetResourceAllocationSettingData to set the PoolID -Added xml_get_net_network(). Updates: -Removed if statement for setting the value of self.ResourceType. This value should always be for network devices. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 93dbca94a762 -r 94274683dee5 suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Thu Jun 19 01:42:12 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Wed May 21 14:05:18 2008 -0700 @@ -22,6 +22,7 @@ # import os import pywbem +import random from distutils.file_util import move_file from XenKvmLib.test_xml import * from XenKvmLib.test_doms import * @@ -331,19 +332,22 @@ return status, diskid -def create_netpool_conf(server, virt): +def create_netpool_conf(server, virt, use_existing=True): status = PASS test_network = None try: - vir_network = net_list(server, virt) - if len(vir_network) > 0: - test_network = vir_network[0] - else: - netxml = NetXML(server, virt=virt) + if use_existing == True: + vir_network = net_list(server, virt) + if len(vir_network) > 0: + test_network = vir_network[0] + + if test_network == None: + net_name = "default-net" + str(random.randint(1, 100)) + netxml = NetXML(server, virt=virt, networkname=net_name) ret = netxml.create_vnet() if not ret: logger.error("Failed to create Virtual Network '%s'", - test_network) + net_name) status = FAIL else: test_network = netxml.xml_get_netpool_name() @@ -351,3 +355,17 @@ logger.error("Exception: In fn create_netpool_conf(): %s", detail) status=FAIL return status, test_network + +def destroy_netpool(server, virt, net_name): + if net_name == None: + return FAIL + + netxml = NetXML(server, virt=virt, networkname=net_name) + ret = netxml.destroy_vnet() + if not ret: + logger.error("Failed to destroy Virtual Network '%s'", + net_name) + return FAIL + + return PASS + diff -r 93dbca94a762 -r 94274683dee5 suites/libvirt-cim/lib/XenKvmLib/vsms.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Thu Jun 19 01:42:12 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed May 21 14:05:18 2008 -0700 @@ -151,13 +151,13 @@ pass class CIM_NetResourceAllocationSettingData(CIMClassMOF): - def __init__(self, type, mac, name): + def __init__(self, type, mac, name, virt_net=None): self.Address = mac self.NetworkType = type - if type == 'ethernet' or type == 'bridge' : - self.ResourceType = RASD_TYPE_NET_ETHER - else: - self.ResourceType = RASD_TYPE_NET_OTHER + self.ResourceType = RASD_TYPE_NET_ETHER + + if virt_net != None : + self.PoolID = "NetworkPool/%s" % virt_net if mac != None: self.InstanceID = '%s/%s' % (name, mac) diff -r 93dbca94a762 -r 94274683dee5 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Thu Jun 19 01:42:12 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed May 21 14:05:18 2008 -0700 @@ -214,6 +214,9 @@ def create_vnet(self): return self.run(self.server, 'net-create', self.xml_string) + + def destroy_vnet(self): + return self.run(self.server, 'net-destroy', self.net_name) def xml_get_netpool_name(self): npoolname = self.get_value_xpath('/network/name')

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1213147576 25200 # Node ID 1ea2eaa7349fb3c16281c4071b252104c7fde5c2 # Parent 94274683dee5aed5621dc555c8604dc56b378c85 [TEST] #2 Add vsms_util.py This module is for vsms related utility functions (for AddResource, ModifyResource, etc). Add the mod_<> functions. These are identical the code paths in VSMS 08_modifyresource.py except for mod_net_res(). mod_net_res() - In the case of Xen, the bridge name needs to be verified. This is because the network interface type is converted to a bridge interface by libvirt. Updates: -Add generic print function Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 94274683dee5 -r 1ea2eaa7349f lib/VirtLib/live.py --- a/lib/VirtLib/live.py Wed May 21 14:05:18 2008 -0700 +++ b/lib/VirtLib/live.py Tue Jun 10 18:26:16 2008 -0700 @@ -338,3 +338,12 @@ names.append(disk_pool[0]) return names + +def virsh_vcpuinfo(server, dom, virt="Xen"): + cmd = "virsh -c %s vcpuinfo %s | grep VCPU | wc -l" % (utils.virt2uri(virt), + dom) + ret, out = utils.run_remote(server, cmd) + if out.isdigit(): + return out + return None + diff -r 94274683dee5 -r 1ea2eaa7349f 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 Tue Jun 10 18:26:16 2008 -0700 @@ -0,0 +1,106 @@ +#!/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 +from VirtLib.live import network_by_bridge, virsh_vcpuinfo + +def print_mod_err_msg(func_str, details): + logger.error('Error invoking ModifyRS: %s' % func_str) + logger.error(details) + +def mod_disk_res(server, service, cxml, dasd, ndpath): + try: + service.ModifyResourceSettings(ResourceSettings = [str(dasd)]) + cxml.dumpxml(server) + dpath = cxml.xml_get_disk_source() + if dpath != ndpath: + logger.error("Got %s, exp %s." % (dpath, ndpath)) + raise Exception('Error changing rs for disk path') + logger.info('good status for disk path') + except Exception, details: + print_mod_err_msg("mod_disk_res", details) + return FAIL + + return PASS + +def mod_net_res(server, service, virt, cxml, nasd, ntype, net_name): + try: + service.ModifyResourceSettings(ResourceSettings = [str(nasd)]) + cxml.dumpxml(server) + type = cxml.xml_get_net_type() + + if virt == "KVM": + name = cxml.xml_get_net_network() + else: + if type == "bridge": + type = "network" + br_name = cxml.xml_get_net_bridge() + name = network_by_bridge(br_name, server, virt) + + if type != ntype or name != net_name: + logger.error('Got %s, exp %s. Got %s, exp %s' % + (type, ntype, name, net_name)) + raise Exception('Error changing rs for net mac') + logger.info('good status for net mac') + except Exception, details: + print_mod_err_msg("mod_net_res", details) + return FAIL + + return PASS + +def mod_mem_res(server, service, cxml, masd, nmem): + try: + service.ModifyResourceSettings(ResourceSettings=[str(masd)]) + cxml.dumpxml(server) + mem = cxml.xml_get_mem() + if int(mem) != int(nmem) * 1024: + logger.error("Got %d, exp %d." % (int(mem), (int(nmem) * 1024))) + raise Exception('Error changing rs for mem') + logger.info('good status for mem') + except Exception, details: + print_mod_err_msg("mod_mem_res", details) + return FAIL + + return PASS + +def mod_vcpu_res(server, service, cxml, pasd, ncpu, virt): + try: + service.ModifyResourceSettings(ResourceSettings = [str(pasd)]) + cxml.dumpxml(server) + dom = cxml.xml_get_dom_name() + cpu = virsh_vcpuinfo(server, dom, virt) + if cpu is None: + logger.info("Unable to get vcpuinfo from virsh, using XML values") + cpu = cxml.xml_get_vcpu() + if int(cpu) != int(ncpu): + logger.error("Got %d, exp %d." % (int(cpu), int(ncpu))) + raise Exception('Error changing rs for vcpu') + logger.info('good status for vcpu') + except Exception, details: + print_mod_err_msg("mod_vcpu_res", details) + return FAIL + + return PASS +

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1213907999 25200 # Node ID 6bbf46ffb58f0de81ff2606c5c27284d3b997ed2 # Parent 1ea2eaa7349fb3c16281c4071b252104c7fde5c2 [TEST] #2 Fix VSMS 08_modifyresource.py on Xen and KVM. This still fails on XenFV because of a provider bug. It looks like the ModifyResource call strips the <emulator> tag from a XenFV guest. So the test is unable to start the guest. Updates to this test: -Call create_netpool_conf() to create a new network pool to use in modify calls. -Create network RASD instead of bridge -Replaced modify calls with functions from vsms_util -Added support for modifying a running guest (mem and vcpu only) -Remove XFAIL Updates from patch 1 to patch 2: -After undefining the guests in the loop, get a new XML object so the guest is defined using a default XML (not a modified one). -Instead of changing vcpus from 1 to 3, start out with a 2 vcpu guest and change down to 1. This ensures that the guest is a SMP guest starting out. -Instad of changing memory from 128 to 78, use 128 to 256 instead. 78 isn't much memory for a guest to run. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 1ea2eaa7349f -r 6bbf46ffb58f suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py Tue Jun 10 18:26:16 2008 -0700 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py Thu Jun 19 13:39:59 2008 -0700 @@ -26,78 +26,97 @@ import pywbem from pywbem.cim_obj import CIMInstanceName from VirtLib import utils +from VirtLib.live import network_by_bridge from XenKvmLib import vsms from XenKvmLib import vxml from CimTest.Globals import logger from CimTest.Globals import do_main -from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC +from CimTest.ReturnCodes import PASS, FAIL +from XenKvmLib.common_util import create_netpool_conf, destroy_netpool +from XenKvmLib import vsms_util sup_types = ['Xen', 'KVM', 'XenFV'] default_dom = 'rstest_domain' -ntype = 'bridge' -ncpu = 3 -nmem = 78 +ntype = 'network' +cpu = 2 +ncpu = 1 +nmem = 256 -bug_cpu = '90079' +def cleanup_env(ip, virt, cxml, net_name): + destroy_netpool(ip, virt, net_name) + cxml.destroy(ip) + cxml.undefine(ip) @do_main(sup_types) def main(): options = main.options service = vsms.get_vsms_class(options.virt)(options.ip) - cxml = vxml.get_class(options.virt)(default_dom) + cxml = vxml.get_class(options.virt)(default_dom, vcpus=cpu) ndpath = cxml.secondary_disk_path dasd = vsms.get_dasd_class(options.virt)(dev=cxml.xml_get_disk_dev(), source=ndpath, name=default_dom) + + status, net_name = create_netpool_conf(options.ip, options.virt, + use_existing=False) + if status != PASS: + logger.error('Unable to find a network pool') + return FAIL + nasd = vsms.get_nasd_class(options.virt)(type=ntype, mac=cxml.xml_get_net_mac(), - name=default_dom) + name=default_dom, + virt_net=net_name) masd = vsms.get_masd_class(options.virt)(megabytes=nmem, name=default_dom) pasd = vsms.get_pasd_class(options.virt)(vcpu=ncpu, name=default_dom) status = FAIL - rc = 0 - try: - cxml.define(options.ip) - # Modify disk setting - service.ModifyResourceSettings(ResourceSettings = [str(dasd)]) - cxml.dumpxml(options.ip) - dpath = cxml.xml_get_disk_source() - if dpath != ndpath: - raise Exception('Error changing rs for disk path') - logger.info('good status for disk path') - # Modify net setting - service.ModifyResourceSettings(ResourceSettings = [str(nasd)]) - cxml.dumpxml(options.ip) - type = cxml.xml_get_net_type() - if type != ntype: - raise Exception('Error changing rs for net mac') - logger.info('good status for net mac') - # Modify memory resource setting - service.ModifyResourceSettings(ResourceSettings=[str(masd)]) - cxml.dumpxml(options.ip) - mem = cxml.xml_get_mem() - if mem != '%i' % (nmem * 1024): - raise Exception('Error changing rs for mem') - logger.info('good status for mem') - # Modify cpu setting - service.ModifyResourceSettings(ResourceSettings = [str(pasd)]) - cxml.dumpxml(options.ip) - cpu = cxml.xml_get_vcpu() - if cpu != '%i' % ncpu: - rc = -1 - raise Exception('Error changing rs for vcpu') - logger.info('good status for vcpu') - status = PASS - except Exception, details: - logger.error('Error invoking ModifyRS') - logger.error(details) - return FAIL + + if options.virt == "KVM": + test_cases = ["define"] + else: + test_cases = ["define", "start"] - cxml.undefine(options.ip) - if rc == -1: - return XFAIL_RC(bug_cpu) + 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.define(options.ip) + if not ret: + logger.error("Failed to define the dom: %s", default_dom) + cleanup_env(options.ip, options.virt, cxml, net_name) + return FAIL + if case == "start": + ret = cxml.start(options.ip) + if not ret: + logger.error("Failed to start the dom: %s", default_dom) + cleanup_env(options.ip, options.virt, cxml, net_name) + return FAIL + + status = vsms_util.mod_vcpu_res(options.ip, service, cxml, pasd, ncpu, + options.virt) + if status != PASS: + break + + status = vsms_util.mod_mem_res(options.ip, service, cxml, masd, nmem) + if status != PASS: + break + + #Unable to modify net and disk devices while guest is running + if case == "start": + break + + status = vsms_util.mod_disk_res(options.ip, service, cxml, dasd, ndpath) + if status != PASS: + break + + status = vsms_util.mod_net_res(options.ip, service, options.virt, cxml, + nasd, ntype, net_name) + if status != PASS: + break + + cleanup_env(options.ip, options.virt, cxml, net_name) return status

libvirt-cim-bounces@redhat.com wrote on 2008-06-20 04:42:55:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1213907999 25200 # Node ID 6bbf46ffb58f0de81ff2606c5c27284d3b997ed2 # Parent 1ea2eaa7349fb3c16281c4071b252104c7fde5c2 [TEST] #2 Fix VSMS 08_modifyresource.py on Xen and KVM.
This still fails on XenFV because of a provider bug. It looks like the ModifyResource call strips the <emulator> tag from a XenFV guest. So the test is unable to start the guest.
Updates to this test: -Call create_netpool_conf() to create a new network pool to use in modify calls. -Create network RASD instead of bridge -Replaced modify calls with functions from vsms_util -Added support for modifying a running guest (mem and vcpu only) -Remove XFAIL
Updates from patch 1 to patch 2: -After undefining the guests in the loop, get a new XML object so the guest is defined using a default XML (not a modified one). -Instead of changing vcpus from 1 to 3, start out with a 2 vcpu guest and change down to 1. This ensures that the guest is a SMP guest starting out. -Instad of changing memory from 128 to 78, use 128 to 256 instead. 78 isn't much memory for a guest to run.
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r 1ea2eaa7349f -r 6bbf46ffb58f suites/libvirt- cim/cimtest/VirtualSystemManagementService/08_modifyresource.py --- a/suites/libvirt- cim/cimtest/VirtualSystemManagementService/08_modifyresource.py Tue Jun 10 18:26:16 2008 -0700 +++ b/suites/libvirt- cim/cimtest/VirtualSystemManagementService/08_modifyresource.py Thu Jun 19 13:39:59 2008 -0700 @@ -26,78 +26,97 @@ import pywbem from pywbem.cim_obj import CIMInstanceName from VirtLib import utils +from VirtLib.live import network_by_bridge from XenKvmLib import vsms from XenKvmLib import vxml from CimTest.Globals import logger from CimTest.Globals import do_main -from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC +from CimTest.ReturnCodes import PASS, FAIL +from XenKvmLib.common_util import create_netpool_conf, destroy_netpool +from XenKvmLib import vsms_util
sup_types = ['Xen', 'KVM', 'XenFV'] default_dom = 'rstest_domain' -ntype = 'bridge' -ncpu = 3 -nmem = 78 +ntype = 'network' +cpu = 2 +ncpu = 1 +nmem = 256
-bug_cpu = '90079' +def cleanup_env(ip, virt, cxml, net_name): + destroy_netpool(ip, virt, net_name) + cxml.destroy(ip) + cxml.undefine(ip)
@do_main(sup_types) def main(): options = main.options
service = vsms.get_vsms_class(options.virt)(options.ip) - cxml = vxml.get_class(options.virt)(default_dom) + cxml = vxml.get_class(options.virt)(default_dom, vcpus=cpu) ndpath = cxml.secondary_disk_path dasd = vsms.get_dasd_class(options.virt)(dev=cxml.xml_get_disk_dev(), source=ndpath, name=default_dom) + + status, net_name = create_netpool_conf(options.ip, options.virt, + use_existing=False) + if status != PASS: + logger.error('Unable to find a network pool') + return FAIL + nasd = vsms.get_nasd_class(options.virt)(type=ntype, mac=cxml.xml_get_net_mac(), - name=default_dom) + name=default_dom, + virt_net=net_name) masd = vsms.get_masd_class(options.virt)(megabytes=nmem, name=default_dom) pasd = vsms.get_pasd_class(options.virt)(vcpu=ncpu, name=default_dom)
status = FAIL - rc = 0 - try: - cxml.define(options.ip) - # Modify disk setting - service.ModifyResourceSettings(ResourceSettings = [str(dasd)]) - cxml.dumpxml(options.ip) - dpath = cxml.xml_get_disk_source() - if dpath != ndpath: - raise Exception('Error changing rs for disk path') - logger.info('good status for disk path') - # Modify net setting - service.ModifyResourceSettings(ResourceSettings = [str(nasd)]) - cxml.dumpxml(options.ip) - type = cxml.xml_get_net_type() - if type != ntype: - raise Exception('Error changing rs for net mac') - logger.info('good status for net mac') - # Modify memory resource setting - service.ModifyResourceSettings(ResourceSettings=[str(masd)]) - cxml.dumpxml(options.ip) - mem = cxml.xml_get_mem() - if mem != '%i' % (nmem * 1024): - raise Exception('Error changing rs for mem') - logger.info('good status for mem') - # Modify cpu setting - service.ModifyResourceSettings(ResourceSettings = [str(pasd)]) - cxml.dumpxml(options.ip) - cpu = cxml.xml_get_vcpu() - if cpu != '%i' % ncpu: - rc = -1 - raise Exception('Error changing rs for vcpu') - logger.info('good status for vcpu') - status = PASS - except Exception, details: - logger.error('Error invoking ModifyRS') - logger.error(details) - return FAIL + + if options.virt == "KVM": + test_cases = ["define"] + else: + test_cases = ["define", "start"]
- cxml.undefine(options.ip) - if rc == -1: - return XFAIL_RC(bug_cpu) + 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.define(options.ip) + if not ret: + logger.error("Failed to define the dom: %s", default_dom) + cleanup_env(options.ip, options.virt, cxml, net_name) + return FAIL + if case == "start": + ret = cxml.start(options.ip) + if not ret: + logger.error("Failed to start the dom: %s", default_dom) + cleanup_env(options.ip, options.virt, cxml, net_name) + return FAIL + + status = vsms_util.mod_vcpu_res(options.ip, service, cxml, pasd, ncpu, + options.virt) + if status != PASS: + break + + status = vsms_util.mod_mem_res(options.ip, service, cxml, masd, nmem) + if status != PASS: + break + + #Unable to modify net and disk devices while guest is running + if case == "start": + break + + status = vsms_util.mod_disk_res(options.ip, service, cxml, dasd, ndpath) + if status != PASS: + break + + status = vsms_util.mod_net_res(options.ip, service, options.virt, cxml, + nasd, ntype, net_name) + if status != PASS: + break + + cleanup_env(options.ip, options.virt, cxml, net_name)
return status
+1 from me.
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
participants (2)
-
Guo Lian Yun
-
Kaitlin Rupert