[PATCH 0 of 3] [Test] Patches to test bridge interface

Hello everyone, I like to submit a set of patches to enable and test bridge interface uisng cimtest. The first patch,'patch1', enables to create domain with bridge interface. The seocnd patch,'patch2', is a testcase to test the above feature. The third parthc,'patch3', is a testcase to verify various error conditions with both 'network' and 'bridge' network type. Thanks and Regards Yogi

# HG changeset patch # User anantyog@linux.vnet.ibm.com # Date 1247490357 25200 # Node ID 624d673032ea550914dc569d993081d510321e6c # Parent f8a983f28ce47c137c4ecf14bbd8c81d936abc3f [Test] Patch to enable bridge type network in cimtest This patch enables creating a bridge type network pool and also defining a domain with bridge interface in cimtest. Signed-off-by: Yogananth Subramanian <anantyog@linux.vnet.ibm.com> diff -r f8a983f28ce4 -r 624d673032ea suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Fri Jul 10 00:47:59 2009 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Jul 13 06:05:57 2009 -0700 @@ -40,7 +40,8 @@ domain_list, virt2uri, net_destroy from XenKvmLib.vxml import PoolXML, NetXML from VirtLib import utils -from XenKvmLib.const import default_pool_name, default_network_name +from XenKvmLib.const import default_pool_name, default_network_name,\ + default_bridge_name disk_file = '/etc/libvirt/diskpool.conf' exports_file = '/etc/exports' @@ -381,7 +382,8 @@ return PASS def create_netpool_conf(server, virt, use_existing=False, - net_name=default_network_name): + net_name=default_network_name, + bridge_name=default_bridge_name): status = PASS test_network = None try: @@ -400,7 +402,8 @@ net_name) return FAIL, "Unknown" - netxml = NetXML(server, virt=virt, networkname=net_name) + netxml = NetXML(server, virt=virt, networkname=net_name, + bridgename=bridge_name) ret = netxml.create_vnet() if not ret: logger.error("Failed to create Virtual Network '%s'", diff -r f8a983f28ce4 -r 624d673032ea suites/libvirt-cim/lib/XenKvmLib/vsms.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Fri Jul 10 00:47:59 2009 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Mon Jul 13 06:05:57 2009 -0700 @@ -164,7 +164,10 @@ self.ResourceType = RASD_TYPE_NET_ETHER if virt_net != None : - self.PoolID = "NetworkPool/%s" % virt_net + if type == 'network': + self.PoolID = "NetworkPool/%s" % virt_net + elif type == 'bridge': + self.NetworkName = virt_net if mac != None: self.InstanceID = '%s/%s' % (name, mac)

# HG changeset patch # User anantyog@linux.vnet.ibm.com # Date 1247490372 25200 # Node ID 0c06e9ac259999a35d3b08d1735822a5dc579fa7 # Parent 624d673032ea550914dc569d993081d510321e6c [Test] Start domain with bridge interface This test verifies definig and starting domain with bridge interface. Signed-off-by: Yogananth Subramanian <anantyog@linux.vnet.ibm.com> diff -r 624d673032ea -r 0c06e9ac2599 suites/libvirt-cim/cimtest/VirtualSystemManagementService/18_define_sys_bridge.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/18_define_sys_bridge.py Mon Jul 13 06:06:12 2009 -0700 @@ -0,0 +1,76 @@ +#!/usr/bin/python +# +# Copyright 2009 IBM Corp. +# +# Authors: +# Yogananth subramanian <anantyog@linux.vnet.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 testcase verifies defining and starting domain with bridge interface +# + +import sys +import random +from XenKvmLib import vxml +from CimTest.Globals import logger +from CimTest.ReturnCodes import FAIL, PASS +from XenKvmLib.const import default_network_name, do_main +from XenKvmLib.common_util import create_netpool_conf, destroy_netpool + +sup_types = ['Xen', 'KVM', 'XenFV'] +default_dom = 'brgtest_domain' +nmac = '99:aa:bb:cc:ee:ff' +npool_name = default_network_name + str(random.randint(1, 100)) +brg_name = "br" + str(random.randint(1, 100)) + +@do_main(sup_types) +def main(): + options = main.options + + status, net_name = create_netpool_conf(options.ip, options.virt, + use_existing=False, + net_name=npool_name, + bridge_name=brg_name) + if status != PASS: + logger.error('Unable to create network pool') + return FAIL + cxml = vxml.get_class(options.virt)(default_dom, mac=nmac, + ntype="bridge", + net_name=brg_name) + + try: + ret = cxml.cim_define(options.ip) + if not ret: + raise Exception("Failed to define the dom: %s" % default_dom) + ret = cxml.cim_start(options.ip) + if ret: + cxml.undefine(options.ip) + raise Exception("Failed to start the dom: %s" % default_dom) + + cxml.cim_destroy(options.ip) + cxml.undefine(options.ip) + + except Exception, details: + logger.error(details) + status = FAIL + + destroy_netpool(options.ip, options.virt, net_name) + + return status + +if __name__ == "__main__": + sys.exit(main()) +

# HG changeset patch # User anantyog@linux.vnet.ibm.com # Date 1247490378 25200 # Node ID 44aa65341aeafc675430fe33be2665ae103b2e9b # Parent 0c06e9ac259999a35d3b08d1735822a5dc579fa7 [Test] Verify error conditions with different network types The test verifies if the expected error message are recived when invalid params are used to define a bridge or a network interace. If a network is defined with a None, the 'default' network pool is used, so no exception is raised for tht condition in tht test. Signed-off-by: Yogananth Subramanian <anantyog@linux.vnet.ibm.com> diff -r 0c06e9ac2599 -r 44aa65341aea suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py Mon Jul 13 06:06:18 2009 -0700 @@ -0,0 +1,125 @@ +#!/usr/bin/python +# +# Copyright 2009 IBM Corp. +# +# Authors: +# Yogananth subramanian <anantyog@linux.vnet.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 +# +# The testcase verifies if the expected error messages are received when +# invalid params are used to define a bridge or a network interface. +# If a network is defined with a None, the 'default' network pool is used +# so no exception is raised for tht condition in the test. +# + +import sys +import random +from pywbem import CIM_ERR_FAILED +from XenKvmLib import vxml +from CimTest.Globals import logger +from CimTest.ReturnCodes import FAIL, PASS +from XenKvmLib.const import default_network_name, do_main +from XenKvmLib.common_util import create_netpool_conf, destroy_netpool + +sup_types = ['Xen', 'KVM', 'XenFV'] +default_dom = 'brgtest_domain' +nmac = '99:aa:bb:cc:ee:ff' +npool_name = default_network_name + str(random.randint(1, 100)) +brg_name = "br" + str(random.randint(1, 100)) + +exp_rc = CIM_ERR_FAILED + +def verify_error(exp_rc, exp_desc,cxml): + status = cxml.verify_error_msg(exp_rc, exp_desc) + return status + +@do_main(sup_types) +def main(): + options = main.options + + nettypes = ['bridge','network'] + + expected_values = { + "invalid" : {'bridge' : 'internal error Failed to add tap interface', + 'network' : "internal error Network 'invalid'" }, + "empty" : {'bridge' : 'Bridge name is empty', + 'network' : "internal error Network '' not found"}, + "none" : {'bridge' : 'No Network bridge name specified', + 'network' : "Valid param "} + } + + tc_scen = { + 'invalid' : 'invalid', + 'empty' : '', + 'none' : None + } + + + status, net_name = create_netpool_conf(options.ip, options.virt, + use_existing=False, + net_name=npool_name, + bridge_name=brg_name) + if status != PASS: + logger.error('Unable to create network pool') + return FAIL + + status = PASS + for nettype in nettypes: + for tc, field in tc_scen.iteritems(): + cxml = vxml.get_class(options.virt)(default_dom, mac=nmac, + ntype=nettype, + net_name=field) + exp_desc = expected_values[tc][nettype] + try: + ret = cxml.cim_define(options.ip) + + if not ret: + status = verify_error(exp_rc, exp_desc, cxml) + if status != PASS: + raise Exception('Defing domain with invalid %s name %s' + ' gave unexpected rc code %s and ' + 'description:\n %s'% (nettype, field, + cxml.err_rc, cxml.err_desc)) + continue + ret = cxml.cim_start(options.ip) + if ret: + status = verify_error(exp_rc, exp_desc, cxml) + cxml.undefine(options.ip) + if status != PASS: + raise Exception('Starting domain with invalid %s name' + ' %s gave unexpected rc code %s and ' + 'description:\n %s'% (nettype, field, + cxml.err_rc, cxml.err_desc)) + continue + + cxml.cim_destroy(options.ip) + cxml.undefine(options.ip) + if nettype != 'network' and field != None: + raise Exception('Was able to define a domain with invalid' + ' %s name %s' % (nettype, field)) + + except Exception,details: + logger.error(details) + destroy_netpool(options.ip, options.virt, net_name) + return FAIL + + destroy_netpool(options.ip, options.virt, net_name) + + return status + +if __name__ == "__main__": + sys.exit(main()) +
participants (1)
-
Yogananth Subramanian