aboutsummaryrefslogtreecommitdiffstats
path: root/jjb/common/include-agl-lava-labs-prepare.sh
diff options
context:
space:
mode:
authorLoys Ollivier <lollivier@baylibre.com>2017-11-08 14:03:21 +0100
committerLoys Ollivier <lollivier@baylibre.com>2017-11-08 14:03:21 +0100
commiteb128da8fdda07d8f8f74ff941961992a9a52adc (patch)
treec1b4ebae021fa113dd76314508ed42e989970d47 /jjb/common/include-agl-lava-labs-prepare.sh
parent41f2a94135443b239d3335949726b4223d8c2f3d (diff)
CIBT improve lava lab searching and coding style
Fix coding style, indentation. Improve the lab search, if a lab has the device do not search in others as it won't be used. Change-Id: I7471511ff7af3d2f6d8708943b42099a450ef770 Signed-off-by: Loys Ollivier <lollivier@baylibre.com>
Diffstat (limited to 'jjb/common/include-agl-lava-labs-prepare.sh')
-rw-r--r--jjb/common/include-agl-lava-labs-prepare.sh38
1 files changed, 22 insertions, 16 deletions
diff --git a/jjb/common/include-agl-lava-labs-prepare.sh b/jjb/common/include-agl-lava-labs-prepare.sh
index bc590600..b54fc223 100644
--- a/jjb/common/include-agl-lava-labs-prepare.sh
+++ b/jjb/common/include-agl-lava-labs-prepare.sh
@@ -6,12 +6,16 @@
#
# Uses user/token pairs from Jenkins secrets
#
+# And macthing LAVA lab names for releng-scripts
+#
+# Strucuture: [JENKINS_LAB_NAME]="LAB_URL;JENKINS_LAB_USER;JENKINS_LAB_TOKEN;RELENG_LAB_NAME"
+#
declare -A labs
labs=(
- [agl]="https://lava.automotivelinux.org/;$LAB_AGL_USER;$LAB_AGL_TOKEN"
- [baylibre]="http://lava.baylibre.com:10080/;$LAB_BAYLIBRE_USER;$LAB_BAYLIBRE_TOKEN"
+ [agl]="https://lava.automotivelinux.org/;$LAB_AGL_USER;$LAB_AGL_TOKEN;lab-agl-core"
+ [baylibre]="http://lava.baylibre.com:10080/;$LAB_BAYLIBRE_USER;$LAB_BAYLIBRE_TOKEN;lab-baylibre-legacy"
# [baylibre_seattle]="http://lava.ished.com/;$LAB_BAYLIBRE_SEATTLE_USER;$LAB_BAYLIBRE_SEATTLE_TOKEN"
- )
+)
echo "## ${MACHINE} ##"
__MACHINE=${MACHINE%-nogfx}
@@ -37,15 +41,16 @@ for lab in "${!labs[@]}"; do
url=${arr[0]}
user=${arr[1]}
token=${arr[2]}
+ lava_lab=${arr[3]}
token_file=$HOME/.local/lab-$lab-token
if [ -z ${user} ]; then
- echo "WARNING: Lab ${lab}: missing user. Ignoring."
- continue
+ echo "WARNING: Lab ${lab}: missing user. Ignoring."
+ continue
fi
if [ -z ${token} ]; then
- echo "WARNING: Lab ${lab}: missing token. Ignoring."
- continue
+ echo "WARNING: Lab ${lab}: missing token. Ignoring."
+ continue
fi
# LAVA URL with username
@@ -56,7 +61,7 @@ for lab in "${!labs[@]}"; do
echo ${token} > $token_file
lava-tool auth-add --token $token_file $full_url
if [ $? != 0 ]; then
- echo "ERROR: Lab ${lab}: lava-tool auth-add failed."
+ echo "ERROR: Lab ${lab}: lava-tool auth-add failed."
fi
rm -f $token_file
@@ -64,8 +69,8 @@ for lab in "${!labs[@]}"; do
echo -n "Checking for $__MACHINE at $full_url... "
line=$(lava-tool devices-list $full_url |grep $__MACHINE | tr -d '[:space:]')
if [ -z "$line" ]; then
- echo "not found."
- continue
+ echo "not found."
+ continue
fi
IFS='|'
arr=($line)
@@ -75,16 +80,17 @@ for lab in "${!labs[@]}"; do
# device is only available if "idle" or "running"
device_available=0
if [ x"$device_status" = x"idle" ]; then
- device_available=1
+ device_available=1
elif [ x"$device_status" = x"running" ]; then
- device_available=1;
+ device_available=1;
fi
if [ $device_available = 0 ]; then
- echo " Not Available. Status: $device_status"
- continue
+ echo " Not Available. Status: $device_status"
+ continue
else
- echo " Found and available. Status: $device_status"
- export LAVA_LAB=$lab
+ echo " Found and available. Status: $device_status"
+ export LAVA_LAB=$lava_lab
+ break
fi
done