From 296bc5fbc5d08ed91771a39f47f02ae90164aa6b Mon Sep 17 00:00:00 2001 From: Corentin LABBE Date: Thu, 11 Oct 2018 09:50:49 +0200 Subject: Permit to give board to user By default LAVA give owning of boards to admin, this patch permit to give board to a specific user. --- README.md | 1 + lava-slave/Dockerfile | 1 + lava-slave/deviceinfo/.empty | 0 lava-slave/scripts/setup.sh | 13 +++++++++++-- lavalab-gen.py | 4 ++++ 5 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 lava-slave/deviceinfo/.empty diff --git a/README.md b/README.md index 902b517..df92777 100644 --- a/README.md +++ b/README.md @@ -263,6 +263,7 @@ boards: tags: (optional) List of tag to set on this device - tag1 - tag2 + user: (optional) Name of user owning the board (LAVA default is admin) # One of uart or connection_command must be choosen uart: idvendor: The VID of the UART (Formated as 0xXXXX) diff --git a/lava-slave/Dockerfile b/lava-slave/Dockerfile index c029e47..7b811bf 100644 --- a/lava-slave/Dockerfile +++ b/lava-slave/Dockerfile @@ -39,6 +39,7 @@ COPY scripts/setup.sh . COPY devices/ /root/devices/ COPY tags/ /root/tags/ +COPY deviceinfo/ /root/deviceinfo/ RUN if [ -x /root/extra_actions ] ; then /root/extra_actions ; fi diff --git a/lava-slave/deviceinfo/.empty b/lava-slave/deviceinfo/.empty new file mode 100644 index 0000000..e69de29 diff --git a/lava-slave/scripts/setup.sh b/lava-slave/scripts/setup.sh index f281f6b..ef20790 100755 --- a/lava-slave/scripts/setup.sh +++ b/lava-slave/scripts/setup.sh @@ -80,6 +80,15 @@ do fi touch /root/.lavadocker/devicetype-$devicetype fi + DEVICE_OPTS="" + if [ -e /root/deviceinfo/$devicename ];then + echo "Found customization for $devicename" + . /root/deviceinfo/$devicename + if [ ! -z "$DEVICE_USER" ];then + echo "DEBUG: give $devicename to $DEVICE_USER" + DEVICE_OPTS="$DEVICE_OPTS --user $DEVICE_USER" + fi + fi echo "Add device $devicename on $worker" grep -q "$devicename[[:space:]]" /tmp/devices.list if [ $? -eq 0 ];then @@ -106,11 +115,11 @@ do DEVICE_HEALTH='UNKNOWN' ;; esac - lavacli $LAVACLIOPTS devices update --worker $worker --health $DEVICE_HEALTH $devicename || exit $? + lavacli $LAVACLIOPTS devices update --worker $worker --health $DEVICE_HEALTH $DEVICE_OPTS $devicename || exit $? # always reset the device dict in case of update of it lavacli $LAVACLIOPTS devices dict set $devicename /root/devices/$worker/$device || exit $? else - lavacli $LAVACLIOPTS devices add --type $devicetype --worker $worker $devicename || exit $? + lavacli $LAVACLIOPTS devices add --type $devicetype --worker $worker $DEVICE_OPTS $devicename || exit $? lavacli $LAVACLIOPTS devices dict set $devicename /root/devices/$worker/$device || exit $? fi if [ -e /root/tags/$devicename ];then diff --git a/lavalab-gen.py b/lavalab-gen.py index ce24e2d..12b4807 100755 --- a/lavalab-gen.py +++ b/lavalab-gen.py @@ -465,6 +465,10 @@ def main(): for tag in board["tags"]: ftag.write("%s\n" % tag) ftag.close() + if "user" in board: + deviceinfo = open("%s/deviceinfo/%s" % (workerdir, board_name), 'w') + deviceinfo.write("DEVICE_USER=%s\n" % board["user"]) + deviceinfo.close() if "custom_option" in board: for coption in board["custom_option"]: device_line += "{%% %s %%}\n" % coption -- cgit 1.2.3-korg