Bootstrap verify performance fix 48/748/1
authorpmikus <pmikus@cisco.com>
Tue, 12 Apr 2016 10:21:53 +0000 (12:21 +0200)
committerpmikus <pmikus@cisco.com>
Tue, 12 Apr 2016 10:21:53 +0000 (12:21 +0200)
- fix installation directory create and remove

Change-Id: I0acd47b886e869958a2075889af3bbe166d7808e
Signed-off-by: pmikus <pmikus@cisco.com>
bootstrap-verify-perf.sh
resources/tools/topo_installation.py

index 70b235a..a4d5194 100755 (executable)
@@ -19,6 +19,7 @@ TOPOLOGIES="topologies/available/lf_testbed2-710-520.yaml"
 
 # Reservation dir
 RESERVATION_DIR="/tmp/reservation_dir"
+INSTALLATION_DIR="/tmp/install_dir"
 
 # Jenkins VPP deb paths (convert to full path)
 VPP_DEBS="$( readlink -f $@ | tr '\n' ' ' )"
@@ -59,24 +60,25 @@ while :; do
     sleep ${SLEEP_TIME}
 done
 
+function cancel_all {
+    python ${CUR_DIR}/resources/tools/topo_installation.py -c -t $1
+    python ${CUR_DIR}/resources/tools/topo_reservation.py -c -t $1
+}
+
+# On script exit we cancel the reservation and installation and delete all vpp
+# packages
+trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
+
 python ${CUR_DIR}/resources/tools/topo_installation.py -t ${WORKING_TOPOLOGY} \
-                                                       -d ${RESERVATION_DIR} \
+                                                       -d ${INSTALLATION_DIR} \
                                                        -p ${VPP_DEBS}
 if [ $? -eq 0 ]; then
     echo "VPP Installed on hosts from: ${WORKING_TOPOLOGY}"
 else
     echo "Failed to copy vpp deb files to DUTs"
-    exit $?
+    exit 1
 fi
 
-function cancel_reservation {
-    python ${CUR_DIR}/resources/tools/topo_reservation.py -c -t $1
-}
-
-# On script exit we cancel the reservation and delete all vpp packages
-trap "cancel_reservation ${WORKING_TOPOLOGY}" EXIT
-
-
 if [ ! -z "$TEST_TAG" ]; then
 # run specific performance tests by tag if variable is set
     pybot -L TRACE \
index 8b596e1..1dc818f 100755 (executable)
@@ -30,12 +30,15 @@ def main():
                         help="Topology file")
     parser.add_argument("-d", "--directory", required=True,
                         help="Installation directory")
-    parser.add_argument("-p", "--packages", required=True, nargs='+',
+    parser.add_argument("-p", "--packages", required=True, nargs='*',
                         help="Packages paths to copy")
+    parser.add_argument("-c", "--cancel", help="Cancel installation",
+                        action="store_true")
     args = parser.parse_args()
     topology_file = args.topo
     packages = args.packages
     install_dir = args.directory
+    cancel_installation = args.cancel
 
     work_file = open(topology_file)
     topology = load(work_file.read())['nodes']
@@ -45,16 +48,27 @@ def main():
             ssh = SSH()
             ssh.connect(topology[node])
 
-            # Copy packages from local path to installation dir
-            for deb in packages:
-                ssh.scp(local_path=deb, remote_path=install_dir)
+            if cancel_installation:
+                ret, _, err = ssh.exec_command("rm -r {}".format(install_dir))
+                if ret != 0:
+                    print "Cancel unsuccessful:\n{}".format(err)
+                    return ret
+            else:
+                ret, _, err = ssh.exec_command("mkdir {}".format(install_dir))
+                if ret != 0:
+                    print "Mkdir unsuccessful:\n{}".format(err)
+                    return ret
 
-            # Installation of VPP deb packages
-            ret, _, err = ssh.exec_command_sudo(
-                "dpkg -i {}/*.deb".format(install_dir))
-            if ret != 0:
-                print "Installation unsuccessful:\n{}".format(err)
-                return ret
+                # Copy packages from local path to installation dir
+                for deb in packages:
+                    ssh.scp(local_path=deb, remote_path=install_dir)
+
+                # Installation of VPP deb packages
+                ret, _, err = ssh.exec_command_sudo(
+                    "dpkg -i {}/*.deb".format(install_dir))
+                if ret != 0:
+                    print "Installation unsuccessful:\n{}".format(err)
+                    return ret
 
 if __name__ == "__main__":
     sys.exit(main())