summaryrefslogtreecommitdiffstats
path: root/tools/kingbird/deploy.sh
diff options
context:
space:
mode:
authorDimitri Mazmanov <dimitri.mazmanov@ericsson.com>2016-07-11 14:52:59 +0200
committerDimitri Mazmanov <dimitri.mazmanov@ericsson.com>2016-07-13 15:55:16 +0200
commit42eb52df3b46289ac6c76d9d5faa0473f8ca67c5 (patch)
tree0b7ca483117953936bfd8a7f9c0a29df3407ae74 /tools/kingbird/deploy.sh
parente122da864915dfe70927eecdb1a39df24031da37 (diff)
Add kingbird deployment scripts
The scripts will be triggered by the CI and install kingbird on a controller. Change-Id: I3110aeb5dd20e53ca5816691ee2c7da24720630b Signed-off-by: Dimitri Mazmanov <dimitri.mazmanov@ericsson.com>
Diffstat (limited to 'tools/kingbird/deploy.sh')
-rwxr-xr-xtools/kingbird/deploy.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/tools/kingbird/deploy.sh b/tools/kingbird/deploy.sh
new file mode 100755
index 0000000..5a8c6a8
--- /dev/null
+++ b/tools/kingbird/deploy.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+INSTALLER_IP=10.20.0.2
+
+usage() {
+ echo "usage: $0 -a <installer_ip>" >&2
+
+}
+
+error () {
+ logger -s -t "deploy.error" "$*"
+ exit 1
+}
+
+#Get options
+while getopts ":a:" optchar; do
+ case "${optchar}" in
+ a) installer_ip=${OPTARG} ;;
+ *) echo "Non-option argument: '-${OPTARG}'" >&2
+ usage
+ exit 2
+ ;;
+ esac
+done
+
+installer_ip=${installer_ip:-$INSTALLER_IP}
+
+ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
+
+controller_ip=$(sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} \
+'fuel node --env 1| grep controller | grep "True\| 1" | awk -F\| "{print \$5}" | tail -1' | \
+sed 's/ //g') &> /dev/null
+
+if [ -z $controller_ip ]; then
+ error "The controller $controller_ip is not up. Please check that the POD is correctly deployed."
+fi
+
+# Copy install_kingbird.sh script to the controller
+sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} \
+"ssh $ssh_options ${controller_ip} \"cd /root/ && cat > install_kingbird.sh\"" < install_kingbird.sh &> /dev/null
+# Set the rights and execute
+sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} \
+"ssh $ssh_options ${controller_ip} \"cd /root/ && chmod +x install_kingbird.sh\"" &> /dev/null
+sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} \
+"ssh $ssh_options ${controller_ip} \"cd /root/ && nohup /root/install_kingbird.sh \"" &> /dev/null
+
+engine_pid=$(sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} "ssh $ssh_options ${controller_ip} \"pgrep kingbird-engine || echo dead\"") &> /dev/null
+api_pid=$(sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} "ssh $ssh_options ${controller_ip} \"pgrep kingbird-api || echo dead\"") &> /dev/null
+
+if [ "$engine_pid" == "dead" ]; then
+ error "Kingbird engine is not running."
+fi
+
+if [ "$api_pid" == "dead" ]; then
+ error "Kingbird API is not running."
+fi \ No newline at end of file