Fix: trap for unreserve before cleanup
[csit.git] / resources / libraries / bash / function / common.sh
index f08d7f2..f07997d 100644 (file)
@@ -303,9 +303,6 @@ function reserve_testbed () {
             if [[ "${result}" == "0" ]]; then
                 WORKING_TOPOLOGY="${topo}"
                 echo "Reserved: ${WORKING_TOPOLOGY}"
-                python "${PYTHON_SCRIPTS_DIR}/topo_cleanup.py" -t "${topo}" || {
-                    die "Testbed cleanup failed."
-                }
                 trap "untrap_and_unreserve_testbed" EXIT || {
                     message="TRAP ATTEMPT AND UNRESERVE FAILED, FIX MANUALLY."
                     untrap_and_unreserve_testbed "${message}" || {
@@ -313,6 +310,9 @@ function reserve_testbed () {
                     }
                     die "Trap attempt failed, unreserve succeeded. Aborting."
                 }
+                python "${PYTHON_SCRIPTS_DIR}/topo_cleanup.py" -t "${topo}" || {
+                    die "Testbed cleanup failed."
+                }
                 break
             fi
         done