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>
echo -n "Checking for $device_type at $full_url... "
line=$(lava-tool devices-list $full_url |grep $device_type | tr -d '[:space:]')
if [ -z "$line" ]; then
- echo "not found."
- continue
+ echo "not found."
+ continue
fi
IFS='|'
arr=($line)
# 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"
+ echo " Found and available. Status: $device_status"
fi
# Need to hack the real device-type name in the job file
# after one successful submit, we're done
if [ x"$status" = x"Complete" ]; then
- exit 0
+ exit 0
else
- continue
+ continue
fi
done
#
# 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}
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
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
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)
# 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
set -x
-#
-# LAVA lab names for releng-scripts
-#
-declare -A lava_labs
-lava_labs=(
- [agl]="lab-agl-core"
- [baylibre]="lab-baylibre-legacy"
- )
-
echo "## ${MACHINE} ##"
-echo "# ${lava_labs[$LAVA_LAB]} #"
cd $REPODIR
# WIP: use $RELENG for subset of boards
__MACHINE=${MACHINE%-nogfx} # releng doesn't care
if [ ! -z $RELENG ] && \
[[ x$__MACHINE == x"qemux86-64" || \
- x$__MACHINE == x"raspberrypi3" || \
- x$__MACHINE == x"m3ulcb" ]]; then
+ x$__MACHINE == x"raspberrypi3" || \
+ x$__MACHINE == x"m3ulcb" ]]; then
+ echo "# LAVA lab target: ${LAVA_LAB} #"
# releng-scripts depends on jinja2 >= 2.9
echo "## Check version of python-jinja2: "
pip show jinja2
[[ -e output/repo-manifest-r.txt.sha1 ]] && BUILD_VERSION+="-$(cat output/repo-manifest-r.txt.sha1)"
CREATE_ARGS+="--name AGL-gerrit "
CREATE_ARGS+="--build-version $BUILD_VERSION "
- CREATE_ARGS+="--callback ${lava_labs[$LAVA_LAB]} "
+ CREATE_ARGS+="--callback ${LAVA_LAB} "
CREATE_ARGS+="--test all"
$RELENG/utils/create-jobs.py ${CREATE_ARGS} > testjob.yaml
cat testjob.yaml