summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolas Hermanns <nikolas.hermanns@ericsson.com>2017-05-03 17:49:53 +0200
committerNikolas Hermanns <nikolas.hermanns@ericsson.com>2017-05-03 17:58:08 +0200
commit88331de3fb9375d316acba7b160ddf2a9beab5b2 (patch)
tree8d9e112d8850dae794710125b0b237f39c5c1364
parent9e47ddb9739bb3e6b2ca91615c71bcd94c954172 (diff)
Clean always and change order
Change-Id: Ic9e0d374a4fe5278888b28fe2694c546840d55b4 Signed-off-by: Nikolas Hermanns <nikolas.hermanns@ericsson.com>
-rw-r--r--sdnvpn/lib/utils.py16
-rw-r--r--sdnvpn/test/functest/testcase_3.py37
2 files changed, 27 insertions, 26 deletions
diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py
index 5eeb667..59f641b 100644
--- a/sdnvpn/lib/utils.py
+++ b/sdnvpn/lib/utils.py
@@ -509,6 +509,14 @@ def attach_instance_to_ext_br(instance, compute_node):
def detach_instance_from_ext_br(instance, compute_node):
libvirt_instance_name = getattr(instance, "OS-EXT-SRV-ATTR:instance_name")
+ 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))
+
installer_type = str(os.environ['INSTALLER_TYPE'].lower())
if installer_type == "fuel":
bridge = "br-ex"
@@ -528,11 +536,3 @@ def detach_instance_from_ext_br(instance, compute_node):
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 3b7be0c..3a63147 100644
--- a/sdnvpn/test/functest/testcase_3.py
+++ b/sdnvpn/test/functest/testcase_3.py
@@ -236,24 +236,25 @@ def main():
results.add_failure(msg)
test_utils.attach_instance_to_ext_br(quagga_vm, compute)
- testcase = "Bootstrap quagga inside an OpenStack instance"
- cloud_init_success = test_utils.wait_for_cloud_init(quagga_vm)
- if cloud_init_success:
- results.add_success(testcase)
- else:
- results.add_failure(testcase)
- results.add_to_summary(0, "=")
-
- results.add_to_summary(0, '-')
- results.add_to_summary(1, "Peer Quagga with OpenDaylight")
- results.add_to_summary(0, '-')
-
- neighbor = quagga.odl_add_neighbor(fake_fip['fip_addr'],
- controller_ext_ip,
- controller)
- peer = quagga.check_for_peering(controller)
-
- test_utils.detach_instance_from_ext_br(quagga_vm, compute)
+ try:
+ testcase = "Bootstrap quagga inside an OpenStack instance"
+ cloud_init_success = test_utils.wait_for_cloud_init(quagga_vm)
+ if cloud_init_success:
+ results.add_success(testcase)
+ else:
+ results.add_failure(testcase)
+ results.add_to_summary(0, "=")
+
+ results.add_to_summary(0, '-')
+ results.add_to_summary(1, "Peer Quagga with OpenDaylight")
+ results.add_to_summary(0, '-')
+
+ neighbor = quagga.odl_add_neighbor(fake_fip['fip_addr'],
+ controller_ext_ip,
+ controller)
+ peer = quagga.check_for_peering(controller)
+ finally:
+ test_utils.detach_instance_from_ext_br(quagga_vm, compute)
if neighbor and peer:
results.add_success("Peering with quagga")