[PATCH 0 of 3] [TEST] 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 1a4f0bc12b84af40d1ebef71ea3d6d30b300af05 # Parent 00ed91b75fd62cdcdcfb51c403646118edb91c54 [TEST] 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(). Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 00ed91b75fd6 -r 1a4f0bc12b84 suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Tue Jun 10 20:04:06 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 00ed91b75fd6 -r 1a4f0bc12b84 suites/libvirt-cim/lib/XenKvmLib/vsms.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Tue Jun 10 20:04:06 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed May 21 14:05:18 2008 -0700 @@ -151,13 +151,16 @@ 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 + + if virt_net != None : + self.PoolID = "NetworkPool/%s" % virt_net if mac != None: self.InstanceID = '%s/%s' % (name, mac) diff -r 00ed91b75fd6 -r 1a4f0bc12b84 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue Jun 10 20:04:06 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed May 21 14:05:18 2008 -0700 @@ -215,6 +215,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') return npoolname @@ -403,7 +406,12 @@ bridgeStr = self.get_value_xpath( '/domain/devices/interface/source/@bridge') return bridgeStr - + + def xml_get_net_network(self): + networkStr = self.get_value_xpath( + '/domain/devices/interface/source/@network') + return networkStr + def dumpxml(self, ip): cmd = 'virsh -c %s dumpxml %s' % (self.vuri, self.dname) s, o = utils.run_remote(ip, cmd)

Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1211403918 25200 # Node ID 1a4f0bc12b84af40d1ebef71ea3d6d30b300af05 # Parent 00ed91b75fd62cdcdcfb51c403646118edb91c54 [TEST] 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().
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r 00ed91b75fd6 -r 1a4f0bc12b84 suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Tue Jun 10 20:04:06 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
This is a good addition.
+ +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 00ed91b75fd6 -r 1a4f0bc12b84 suites/libvirt-cim/lib/XenKvmLib/vsms.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Tue Jun 10 20:04:06 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed May 21 14:05:18 2008 -0700 @@ -151,13 +151,16 @@ 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
I think the "network" type interface should also be considered as RASD_TYPE_NET_EHTER ?
+ + if virt_net != None : + self.PoolID = "NetworkPool/%s" % virt_net
if mac != None: self.InstanceID = '%s/%s' % (name, mac) diff -r 00ed91b75fd6 -r 1a4f0bc12b84 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue Jun 10 20:04:06 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed May 21 14:05:18 2008 -0700 @@ -215,6 +215,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') return npoolname @@ -403,7 +406,12 @@ bridgeStr = self.get_value_xpath( '/domain/devices/interface/source/@bridge') return bridgeStr - + + def xml_get_net_network(self): + networkStr = self.get_value_xpath( + '/domain/devices/interface/source/@network') + return networkStr + def dumpxml(self, ip): cmd = 'virsh -c %s dumpxml %s' % (self.vuri, self.dname) s, o = utils.run_remote(ip, cmd)
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

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
I think the "network" type interface should also be considered as RASD_TYPE_NET_EHTER ?
Yep, RASD_TYPE_NET_ETHER is device type 10, which corresponds to the save value in the CIM provider. Good call =) -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1213147576 25200 # Node ID c6fdcb5088bbe504097625265a0d8fc0c4ed73c9 # Parent 1a4f0bc12b84af40d1ebef71ea3d6d30b300af05 [TEST] 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. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 1a4f0bc12b84 -r c6fdcb5088bb 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,102 @@ +#!/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 + +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: + logger.error('Error invoking ModifyRS') + logger.error(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: + logger.error('Error invoking ModifyRS') + logger.error(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: + logger.error('Error invoking ModifyRS') + logger.error(details) + return FAIL + + return PASS + +def mod_vcpu_res(server, service, cxml, pasd, ncpu): + try: + service.ModifyResourceSettings(ResourceSettings = [str(pasd)]) + cxml.dumpxml(server) + 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: + logger.error('Error invoking ModifyRS') + logger.error(details) + return FAIL + + return PASS +

Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1213147576 25200 # Node ID c6fdcb5088bbe504097625265a0d8fc0c4ed73c9 # Parent 1a4f0bc12b84af40d1ebef71ea3d6d30b300af05 [TEST] 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.
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r 1a4f0bc12b84 -r c6fdcb5088bb 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,102 @@ +#!/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 + +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: + logger.error('Error invoking ModifyRS') + logger.error(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: + logger.error('Error invoking ModifyRS') + logger.error(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: + logger.error('Error invoking ModifyRS') + logger.error(details) + return FAIL + + return PASS + +def mod_vcpu_res(server, service, cxml, pasd, ncpu): + try: + service.ModifyResourceSettings(ResourceSettings = [str(pasd)]) + cxml.dumpxml(server) + 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: + logger.error('Error invoking ModifyRS') + logger.error(details) + return FAIL + + return PASS
1) Since the Exception handling is same in all of the above, We can move it to a function. 2) Also, We can make it more meaningful if we print the fn in which the exception is occurs.
+
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1213154736 25200 # Node ID 9f168dca6251330adcb158f6b64fea51ee72d45e # Parent c6fdcb5088bbe504097625265a0d8fc0c4ed73c9 [TEST] 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 Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r c6fdcb5088bb -r 9f168dca6251 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 Tue Jun 10 20:25:36 2008 -0700 @@ -26,19 +26,25 @@ 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 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' +ntype = 'network' ncpu = 3 nmem = 78 -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(): @@ -50,54 +56,65 @@ 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 create 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: + cxml.undefine(options.ip) + 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) + 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) + destroy_netpool(options.ip, options.virt, net_name) return status

Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1213154736 25200 # Node ID 9f168dca6251330adcb158f6b64fea51ee72d45e # Parent c6fdcb5088bbe504097625265a0d8fc0c4ed73c9 [TEST] 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.
The tc failed on KVM and Xen machine with latest sources [ REV: 611 ] with the following error: VirtualSystemManagementService - 08_modifyresource.py: FAIL ERROR - Error invoking ModifyRS ERROR - (1, u"CIM_ERR_FAILED: Device `0' not found") ERROR - Failed to destroy Virtual Network 'default-net17' InvokeMethod(ModifyResourceSettings): CIM_ERR_FAILED: Device `0' not found The debug o/p shows that the tc is failing with : device_parsing.c(257): Disk node: disk Virt_VirtualSystemManagementService.c(1192): Resource transform function failed
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
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r c6fdcb5088bb -r 9f168dca6251 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 Tue Jun 10 20:25:36 2008 -0700 @@ -26,19 +26,25 @@ 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
XFAIL_RC can also be removed.
+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' +ntype = 'network' ncpu = 3 nmem = 78
-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(): @@ -50,54 +56,65 @@ 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 create network pool')
logger.error('Unable to find a network pool') would be more appropriate ?
+ 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
We can remove rc since it is never used.
- 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: + cxml.undefine(options.ip) + 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
Can we do like this ? if case == "start": ret = cxml.start(options.ip) else: ret = cxml.define(options.ip) if not ret: logger.error("Failed to '%s' the dom: %s", case, 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) + 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) + destroy_netpool(options.ip, options.virt, net_name)
return status
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

Deepti B Kalakeri wrote:
Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1213154736 25200 # Node ID 9f168dca6251330adcb158f6b64fea51ee72d45e # Parent c6fdcb5088bbe504097625265a0d8fc0c4ed73c9 [TEST] 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.
The tc failed on KVM and Xen machine with latest sources [ REV: 611 ] with the following error: VirtualSystemManagementService - 08_modifyresource.py: FAIL ERROR - Error invoking ModifyRS ERROR - (1, u"CIM_ERR_FAILED: Device `0' not found") ERROR - Failed to destroy Virtual Network 'default-net17' InvokeMethod(ModifyResourceSettings): CIM_ERR_FAILED: Device `0' not found
The debug o/p shows that the tc is failing with :
device_parsing.c(257): Disk node: disk Virt_VirtualSystemManagementService.c(1192): Resource transform function failed
Sorry, This error does not occur when the Patch " Fix proc InstanceID in vsms.py" is applied.
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
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r c6fdcb5088bb -r 9f168dca6251 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 Tue Jun 10 20:25:36 2008 -0700 @@ -26,19 +26,25 @@ 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
XFAIL_RC can also be removed.
+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' +ntype = 'network' ncpu = 3 nmem = 78
-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(): @@ -50,54 +56,65 @@ 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 create network pool')
logger.error('Unable to find a network pool') would be more appropriate ?
+ 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
We can remove rc since it is never used.
- 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: + cxml.undefine(options.ip) + 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
Can we do like this ? if case == "start": ret = cxml.start(options.ip) else: ret = cxml.define(options.ip) if not ret: logger.error("Failed to '%s' the dom: %s", case, 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) + 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) + destroy_netpool(options.ip, options.virt, net_name)
return status
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

The tc failed on KVM and Xen machine with latest sources [ REV: 611 ] with the following error: VirtualSystemManagementService - 08_modifyresource.py: FAIL ERROR - Error invoking ModifyRS ERROR - (1, u"CIM_ERR_FAILED: Device `0' not found") ERROR - Failed to destroy Virtual Network 'default-net17' InvokeMethod(ModifyResourceSettings): CIM_ERR_FAILED: Device `0' not found
The debug o/p shows that the tc is failing with :
device_parsing.c(257): Disk node: disk Virt_VirtualSystemManagementService.c(1192): Resource transform function failed Sorry, This error does not occur when the Patch " Fix proc InstanceID in vsms.py" is applied.
Oops - yes, the proc patch should have been a part of this patchset. Thanks for the excellent feedback! =) -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

- cxml.undefine(options.ip) - if rc == -1: - return XFAIL_RC(bug_cpu) + for case in test_cases: + cxml.undefine(options.ip) + 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
Can we do like this ? if case == "start": ret = cxml.start(options.ip) else: ret = cxml.define(options.ip) if not ret: logger.error("Failed to '%s' the dom: %s", case, default_dom) cleanup_env(options.ip, options.virt, cxml, net_name) return FAIL
I don't think that'll work for what we want. What we want to do is: 1) Define a guest using the a default XML 2) Modify that guest with ModifyResource() calls 3) Undefine the guest 4) Define using a default XML 5) Start the guest 6) Modify the running guest with ModifyResource() calls After you're done modifying the defined guest, you need to undefine the guest and then start with a default XML. If we don't do this step, we start a guest that already has a modified XML. So that said, I realized there's a bug in the code here. The cxml XML object will retain the changes made during the modify call, so we need to overwrite it with the defaults. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Deepti B Kalakeri
-
Kaitlin Rupert