[Libvirt-cim] [PATCH V2 4/4] cimtest - vlan extention - connection

Wenchao Xia xiawenc at linux.vnet.ibm.com
Tue Feb 14 09:00:30 UTC 2012


    This test case trys: define a bridge, create a 802.1.q port, connect
the port to the bridge, bring down the bridge, bring up the bridge. This case
is very similiar to 802.1.q usage, except that bridge have no DHCP set in this
case, for that it need external device support DHCP.

Signed-off-by: Wenchao Xia <xiawenc at linux.vnet.ibm.com>
---
 .../cimtest/HostNetwork/03_VESSMS_EASD_EC.py       |  113 ++++++++++++++++++++
 1 files changed, 113 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..ece07cd
--- /dev/null
+++ b/suites/libvirt-cim/cimtest/HostNetwork/03_VESSMS_EASD_EC.py
@@ -0,0 +1,113 @@
+#!/usr/bin/env python
+
+#
+# Copyright 2012 IBM Corp.
+#
+# Authors:
+#   Wenchao Xia (Wayne) <xiawenc at 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',]
+
+
+ at do_main(supported)
+def main():
+    options = main.options
+    server = options.ip
+    server_url = "http://%s" % server
+    #get 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 XFAIL
+
+    #add the bridge
+    inst_br = {'VirtualSystemIdentifier':host_network.bridge_name, 'Name': host_network.bridge_name, 'STP': host_network.bridge_stp, 'Delay': host_network.bridge_delay, 'DHCP': 0, 'AutoStart': host_network.bridge_autostart}
+
+    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, 'DHCP': 0, 'AutoStart': 0}
+    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
+    
+    #bring down the iface
+    ret = host_network.try_chang_vess_state(cim, inst_br, 3)
+    if ret != 1:
+        logger.error("Failed to bring down these ifaces.")
+        return FAIL
+    
+    #bring up the iface
+    ret = host_network.try_chang_vess_state(cim, inst_br, 2)
+    if ret != 1:
+        logger.error("Failed to bring up these ifaces.")
+        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.1





More information about the Libvirt-cim mailing list