summaryrefslogtreecommitdiffstats
path: root/lava-slave/scripts/retire.sh
diff options
context:
space:
mode:
authorkhilman <khilman@users.noreply.github.com>2018-06-05 11:47:07 -0700
committerGitHub <noreply@github.com>2018-06-05 11:47:07 -0700
commitc1071d0f9b57958b22546abe8eadf670b3926b98 (patch)
tree6ac6947fc9196283ecba0c17a9033d3af3aaaa99 /lava-slave/scripts/retire.sh
parent2d79d03f5818c096535c9784b12df5ea99c0dbff (diff)
parenta22e4a89a06bda681ba329bf73e05a7d9196efe3 (diff)
Merge pull request #27 from montjoie/multi_slave_2018_x
Multi slave 2018 x
Diffstat (limited to 'lava-slave/scripts/retire.sh')
-rwxr-xr-xlava-slave/scripts/retire.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/lava-slave/scripts/retire.sh b/lava-slave/scripts/retire.sh
new file mode 100755
index 0000000..def6c8e
--- /dev/null
+++ b/lava-slave/scripts/retire.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+LAVA_MASTER_URI=$1
+
+if [ -z "$LAVA_MASTER_URI" ];then
+ echo "retire.sh: remove an offline worker"
+ echo "Usage: $0 LAVA_MASTER_URI"
+ echo "ERROR: Missing LAVA_MASTER_URI"
+ exit 11
+fi
+
+LAVACLIOPTS="--uri $LAVA_MASTER_URI"
+
+retire_worker() {
+ worker=$1
+ lavacli $LAVACLIOPTS workers list |grep -q $worker
+ if [ $? -eq 0 ];then
+ echo "Removing $worker"
+ lavacli $LAVACLIOPTS workers update $worker || exit $?
+ else
+ echo "SKIP: worker $worker does not exists"
+ return 0
+ fi
+ lavacli $LAVACLIOPTS devices list -a | grep '^\*' | cut -d' ' -f2 |
+ while read devicename
+ do
+ lavacli $LAVACLIOPTS devices show $devicename |grep -q "^worker.*$worker$"
+ if [ $? -eq 0 ];then
+ echo "Retire $devicename"
+ lavacli $LAVACLIOPTS devices update --health RETIRED --worker $worker $devicename || exit $?
+ fi
+ done
+ return 0
+}
+
+if [ -z "$2" ];then
+ for ww in $(ls devices/)
+ do
+ retire_worker $ww
+ done
+else
+ retire_worker $2
+fi