From 27e94e4057b0ee7f9bf12c16bdc7d047718791f6 Mon Sep 17 00:00:00 2001 From: Jon Hall Date: Tue, 8 Jan 2019 16:17:24 -0800 Subject: [PATCH] Allow use of rsync when fetching logs Change-Id: I561ae3c9ebe7765d76a0835c712d17e86b731df3 (cherry picked from commit 359f4d84608c44541c43bfc564893ac76c326063) --- tools/test/bin/atomix-fetch-logs | 18 +++++++++++++++++- tools/test/bin/onos-fetch-logs | 18 +++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/tools/test/bin/atomix-fetch-logs b/tools/test/bin/atomix-fetch-logs index 0860193ce3..53129bcf7e 100755 --- a/tools/test/bin/atomix-fetch-logs +++ b/tools/test/bin/atomix-fetch-logs @@ -38,6 +38,22 @@ fi # Execute the remote commands for node in $nodes; do echo "fetching from ${node}..." + USE_RSYNC=${USE_RSYNC:-'false'} + # Check if RSYNC is installed + if [ "$USE_RSYNC" = "true" ]; then + if ssh $ONOS_USER@${node} $SSH_OPTIONS which rsync >&2 > /dev/null; then + echo "Using rsync" + else + echo "Installing rsync" + # TODO check remote OS and use proper method to install rsync + ssh $ONOS_USER@${node} sudo apt-get install -y rsync || USE_RSYNC='false' + fi + fi + mkdir -p ${node} - scp -p $ONOS_USER@[${node}]:$ATOMIX_INSTALL_DIR/log/atomix.log* ./${node}/ + if [ "$USE_RSYNC" = "true" ]; then + rsync -avhz --progress [$ONOS_USER@${node}]:$ATOMIX_INSTALL_DIR/log/atomix.log* ./${node}/ + else + scp -p $ONOS_USER@[${node}]:$ATOMIX_INSTALL_DIR/log/atomix.log* ./${node}/ + fi done diff --git a/tools/test/bin/onos-fetch-logs b/tools/test/bin/onos-fetch-logs index bfcbd5a439..5b8ccca30e 100755 --- a/tools/test/bin/onos-fetch-logs +++ b/tools/test/bin/onos-fetch-logs @@ -38,6 +38,22 @@ fi # Execute the remote commands for node in $nodes; do echo "fetching from ${node}..." + USE_RSYNC=${USE_RSYNC:-'false'} + # Check if RSYNC is installed + if [ "$USE_RSYNC" = "true" ]; then + if ssh $ONOS_USER@${node} $SSH_OPTIONS which rsync >&2 > /dev/null; then + echo "Using rsync" + else + echo "Installing rsync" + # TODO check remote OS and use proper method to install rsync + ssh $ONOS_USER@${node} sudo apt-get install -y rsync || USE_RSYNC='false' + fi + fi + mkdir -p ${node} - scp -p $ONOS_USER@[${node}]:$ONOS_INSTALL_DIR/log/karaf.log* ./${node}/ + if [ "$USE_RSYNC" = "true" ]; then + rsync -avhz --progress [$ONOS_USER@${node}]:$ONOS_INSTALL_DIR/log/karaf.log* ./${node}/ + else + scp -p $ONOS_USER@[${node}]:$ONOS_INSTALL_DIR/log/karaf.log* ./${node}/ + fi done