
test case of attaching one 802.1.q child port to a bridge Signed-off-by: Wayne Xia <xiawenc@linux.vnet.ibm.com> --- .../cimtest/HostNetwork/03_VESSMS_EASD_EC.py | 101 ++++++++++++++++++++ 1 files changed, 101 insertions(+), 0 deletions(-) create mode 100644 suites/libvirt-cim/cimtest/HostNetwork/03_VESSMS_EASD_EC.py diff --git a/suites/libvirt-cim/cimtest/HostNetwork/03_VESSMS_EASD_EC.py b/suites/libvirt-cim/cimtest/HostNetwork/03_VESSMS_EASD_EC.py new file mode 100644 index 0000000..6ece7fa --- /dev/null +++ b/suites/libvirt-cim/cimtest/HostNetwork/03_VESSMS_EASD_EC.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python + +# +# Copyright 2011 IBM Corp. +# +# Authors: +# Wenchao Xia (Wayne) <xiawenc@cn.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 +# + +# +# try connect two CIM switch by attaching one eth to another bridge +# +# + +import sys +import os +import pywbem + +from CimTest.ReturnCodes import PASS, FAIL, XFAIL, SKIP +from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS +from XenKvmLib.const import do_main +from XenKvmLib.classes import get_typed_class +from XenKvmLib.vxml import get_class +from XenKvmLib import host_network + +cim = None +sys_mgmt_service = None +supported = ['KVM',] + + +@do_main(supported) +def main(): + options = main.options + server = options.ip + server_url = "http://%s" % server + #global cim + cim = pywbem.WBEMConnection(server_url, (CIM_USER, CIM_PASS), CIM_NS) + + sys_mgmt_service = host_network.get_vessms(cim) + pNIC = host_network.FoundOnePNIC(cim) + if pNIC == None : + logger.error("Failed to find any pNIC on the host.") + return FAIL + + #add the bridge + inst_br = {'VirtualSystemIdentifier':host_network.bridge_name, 'STP': host_network.bridge_stp, 'Name': host_network.bridge_name} + + ret = host_network.try_create_vs(cim, sys_mgmt_service, inst_br) + if ret != 1: + logger.error("Failed to add cim bridge") + return FAIL + + inst_ea = {'Parent': pNIC, 'VLanID':10, 'ReorderHdr':1, 'Ingress':"1:2 2:3", 'Egress':'2:4'} + ret = host_network.try_add_ea(cim, sys_mgmt_service, inst_ea) + if ret != 1: + logger.error("Failed to add 802.1.q ea") + return FAIL + + EthPort = """%s.%d""" % (inst_ea["Parent"], inst_ea["VLanID"]) + inst_ec = {'ParentBridge': pNIC, 'EthPort':EthPort, 'TargetBridge': host_network.bridge_pNIC} + ret = host_network.try_add_ec(cim, sys_mgmt_service, inst_ec) + if ret != 1: + logger.error("Failed to add connection") + return FAIL + + ret = host_network.try_del_ec(cim, sys_mgmt_service, inst_ec) + if ret != 1: + logger.error("Failed to add connection") + return FAIL + + ret = host_network.try_del_ea(cim, sys_mgmt_service, inst_ea) + if ret != 1: + logger.error("Failed to remove 802.1.q ea") + return FAIL + + ret = host_network.try_delete_vs(cim, sys_mgmt_service, inst_br) + if ret != 1: + logger.error("Failed to delete cim bridge") + return FAIL + + return PASS + +# main() + +if __name__ == "__main__": + ret = main() + sys.exit(ret) -- 1.7.6