From 0d8f3bf930bdd945d34188fb591a6deb03a999c5 Mon Sep 17 00:00:00 2001 From: tomsou Date: Tue, 2 May 2017 12:25:58 +0000 Subject: Cleanup br-ex/br-quagga from testcase_3 After the peering between Quagga and ODL within testcase 3 cleanup br-ex (for fuel) or br-quagga (for apex) interfaces JIRA: SDNVPN-13 Change-Id: I3e7bf91d4e47dfd7fe2a5068ed40ea4b2be48c6d Signed-off-by: tomsou --- sdnvpn/lib/utils.py | 31 +++++++++++++++++++++++++++++++ sdnvpn/test/functest/testcase_3.py | 2 ++ 2 files changed, 33 insertions(+) diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py index 03fea54..788e456 100644 --- a/sdnvpn/lib/utils.py +++ b/sdnvpn/lib/utils.py @@ -502,3 +502,34 @@ def attach_instance_to_ext_br(instance, compute_node): compute_node.run_cmd("sudo virsh attach-interface %s" " bridge %s" % (libvirt_instance_name, bridge)) + + +def detach_instance_from_ext_br(instance, compute_node): + libvirt_instance_name = getattr(instance, "OS-EXT-SRV-ATTR:instance_name") + installer_type = str(os.environ['INSTALLER_TYPE'].lower()) + if installer_type == "fuel": + bridge = "br-ex" + elif installer_type == "apex": + # In Apex, br-ex is an ovs bridge and virsh attach-interface + # won't just work. We work around it by creating a linux + # bridge, attaching that to br-ex with a veth pair + # and virsh-attaching the instance to the linux-bridge + bridge = "br-quagga" + cmd = """ + sudo brctl delif {bridge} quagga-tap && + sudo ovs-vsctl del-port br-ex ovs-quagga-tap && + sudo ip link set dev quagga-tap down && + sudo ip link set dev ovs-quagga-tap down && + sudo ip link del quagga-tap type veth peer name ovs-quagga-tap && + sudo ip link set {bridge} down && + sudo brctl delbr {bridge} + """ + compute_node.run_cmd(cmd.format(bridge=bridge)) + + mac = compute_node.run_cmd("for vm in $(sudo virsh list | " + "grep running | awk '{print $2}'); " + "do echo -n ; sudo virsh dumpxml $vm| " + "grep -oP '52:54:[\da-f:]+' ;done") + compute_node.run_cmd("sudo virsh detach-interface --domain %s" + " --type bridge --mac %s" + % (libvirt_instance_name, mac)) diff --git a/sdnvpn/test/functest/testcase_3.py b/sdnvpn/test/functest/testcase_3.py index 2e6d6b0..1a23c56 100644 --- a/sdnvpn/test/functest/testcase_3.py +++ b/sdnvpn/test/functest/testcase_3.py @@ -254,6 +254,8 @@ def main(): controller) peer = quagga.check_for_peering(controller) + test_utils.detach_instance_from_ext_br(quagga_vm, compute) + if neighbor and peer: results.add_success("Peering with quagga") else: -- cgit 1.2.3-korg