summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitri Mazmanov <dimitri.mazmanov@ericsson.com>2017-01-30 12:40:55 +0100
committerDimitri Mazmanov <dimitri.mazmanov@ericsson.com>2017-01-30 13:32:13 +0100
commit324e79bac3985fc3e2599c5d0567fec59a217418 (patch)
tree430d33a8f4f2c71ed67b20ad7b4b3432469588a0
parent9f9356251d1e5d1812ac16859f8b6b6f20eeb8dd (diff)
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 <dimitri.mazmanov@ericsson.com> JIRA: MULTISITE-34
-rwxr-xr-xtools/keystone/endpoint.sh5
-rwxr-xr-xtools/keystone/fetchpass.sh7
-rwxr-xr-xtools/keystone/region.sh5
-rwxr-xr-xtools/keystone/run.sh20
-rwxr-xr-xtools/keystone/writepass.sh6
5 files changed, 26 insertions, 17 deletions
diff --git a/tools/keystone/endpoint.sh b/tools/keystone/endpoint.sh
index b79638f..1bb6c9b 100755
--- a/tools/keystone/endpoint.sh
+++ b/tools/keystone/endpoint.sh
@@ -16,9 +16,8 @@ set -o pipefail
# Ensure that openrc containing OpenStack environment variables is present.
source openrc
-# if running as part of Jenkins job, create the file in WORKSPACE
-WORKSPACE=${WORKSPACE:-/root}
-ENDPOINT_FILE="${WORKSPACE}/endpoints.ini"
+# Always executed on controller
+ENDPOINT_FILE="/root/endpoints.ini"
# Endpoints. Dynamically get IP addresses from another service (keystone)
ENDPOINT_PUBLIC_URL=$(openstack endpoint list | grep keystone | grep public | cut -d '|' -f 8 | cut -d '/' -f 3 | cut -d ':' -f 1)
diff --git a/tools/keystone/fetchpass.sh b/tools/keystone/fetchpass.sh
index 50fdb5c..5d50aa6 100755
--- a/tools/keystone/fetchpass.sh
+++ b/tools/keystone/fetchpass.sh
@@ -24,10 +24,9 @@ AODH_CONF='/etc/aodh/aodh.conf'
source openrc
-# if running as part of Jenkins job, create the files in WORKSPACE
-WORKSPACE=${WORKSPACE:-/root}
-PASSWORD_FILE_ENC="${WORKSPACE}/servicepass.ini"
-PASSWORD_FILE="${WORKSPACE}/passwords.ini"
+# Always executed on controller
+PASSWORD_FILE_ENC="/root/servicepass.ini"
+PASSWORD_FILE="/root/passwords.ini"
# Get an option from an INI file
# iniget config-file section option
diff --git a/tools/keystone/region.sh b/tools/keystone/region.sh
index c42401d..25ee026 100755
--- a/tools/keystone/region.sh
+++ b/tools/keystone/region.sh
@@ -27,9 +27,8 @@ source openrc
#
# openstack endpoint create --publicurl "" --adminurl "" --internalurl "" --region ${region} <service>
-# if running as part of Jenkins job, read the file from WORKSPACE
-WORKSPACE=${WORKSPACE:-/root}
-ENDPOINT_FILE="${WORKSPACE}/endpoints.ini"
+# Always executed on controller
+ENDPOINT_FILE="/root/endpoints.ini"
# Get an option from an INI file
# iniget config-file section option
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) <runnable_script.sh>
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 <installer_ip> -t (controller|compute) -r <runnable_script.sh> -d <data_file>" >&2
+ echo "usage: $0 -a <installer_ip> -t (controller|compute) -r <runnable_script.sh> -d <data_file> -o <output_file>" >&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} \
diff --git a/tools/keystone/writepass.sh b/tools/keystone/writepass.sh
index d125854..466cd48 100755
--- a/tools/keystone/writepass.sh
+++ b/tools/keystone/writepass.sh
@@ -13,10 +13,8 @@ set -o errexit
set -o nounset
set -o pipefail
-# if running as part of Jenkins job, read and create the files from/in WORKSPACE
-WORKSPACE=${WORKSPACE:-/root}
-PASSWORD_FILE_ENC="${WORKSPACE}/servicepass.ini"
-PASSWORD_FILE="${WORKSPACE}/passwords.ini"
+PASSWORD_FILE_ENC="/root/servicepass.ini"
+PASSWORD_FILE="/root/passwords.ini"
function ini_has_option {
local file=$1