From 324e79bac3985fc3e2599c5d0567fec59a217418 Mon Sep 17 00:00:00 2001 From: Dimitri Mazmanov Date: Mon, 30 Jan 2017 12:40:55 +0100 Subject: Fix script execution on wrong target All scripts are now triggered via run.sh which is a proxy to controllers and computes. Change-Id: Ifd35d5405d30b9aed002515e55a3b9047098a0d4 Signed-off-by: Dimitri Mazmanov JIRA: MULTISITE-34 --- tools/keystone/run.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'tools/keystone/run.sh') diff --git a/tools/keystone/run.sh b/tools/keystone/run.sh index 6fc02ca..d0a2b06 100755 --- a/tools/keystone/run.sh +++ b/tools/keystone/run.sh @@ -18,9 +18,12 @@ set -o pipefail # Usage: run.sh (controller|compute) INSTALLER_IP=10.20.0.2 +# Runs on the jumphost +# if running as part of Jenkins job, read and create the files from/in WORKSPACE +WORKSPACE=${WORKSPACE:-/root} usage() { - echo "usage: $0 -a -t (controller|compute) -r -d " >&2 + echo "usage: $0 -a -t (controller|compute) -r -d -o " >&2 } error () { @@ -51,6 +54,10 @@ case $1 in data="$2" shift # past argument ;; + -o|--output) + output="$2" + shift # past argument + ;; *) echo "Non-option argument: '-${OPTARG}'" >&2 usage @@ -61,6 +68,7 @@ shift # past argument or value installer_ip=${installer_ip:-$INSTALLER_IP} data=${data:-""} +output=${output:-""} ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" @@ -77,10 +85,16 @@ function run_on_target() { sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} \ "ssh $ssh_options $1 \"cd /root/ && chmod +x ${runnable}\"" &> /dev/null sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} \ - "ssh $ssh_options $1 \"cd /root/ && nohup /root/${runnable} > install.log 2> /dev/null\"" &> /dev/null + "ssh $ssh_options $1 \"cd /root/ && nohup /root/${runnable} > ${runnable}.log 2> /dev/null\"" &> /dev/null # Output here sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} \ - "ssh $ssh_options $1 \"cd /root/ && cat install.log\"" + "ssh $ssh_options $1 \"cd /root/ && cat ${runnable}.log\"" + + if [ -n "${output}" ]; then + #Fetch output file + sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} \ + "ssh $ssh_options $1 \"cd /root/ && cat ${output}\"" > "${WORKSPACE}/${output}" + fi } target_info=$(sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} \ -- cgit 1.2.3-korg