summaryrefslogtreecommitdiffstats
path: root/lava-slave/scripts/retire.sh
diff options
context:
space:
mode:
authorCorentin LABBE <clabbe@baylibre.com>2018-04-12 11:59:07 +0200
committerCorentin LABBE <clabbe@baylibre.com>2018-06-05 15:36:31 +0200
commit31555bcb6555d080e7072fba2fc8ccda0fd59eaa (patch)
treee70c096e7714be50f2d7b9f4419f07dbe4452ec7 /lava-slave/scripts/retire.sh
parent287e03c09e34ec77d696fcd7ad55912cc127a859 (diff)
Implement Multipleslave
This patch implement multiple slave support. Instead of having a maximum of one master and one slave in one docker image, it is now possible to have multiple slave accross several docker host. For helping this change, a new boards.yaml format is introduced (See README.md for details) Note that tokens.yaml is also squashed in boards.yaml
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