diff options
author | Corentin LABBE <clabbe@baylibre.com> | 2019-07-02 11:22:51 +0200 |
---|---|---|
committer | Corentin LABBE <clabbe@baylibre.com> | 2019-08-26 14:36:50 +0200 |
commit | 12aa09489580123698d1f791b01daf8371fa0228 (patch) | |
tree | 08299f38b21654b6c3ae6f30089b6e12f8b5fac5 | |
parent | 63da4cb3d258222ff1b11052951c7e5d7ca8e02c (diff) |
Add support for device-type alias
This patch adds support for the device-type aliases.
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | lava-slave/Dockerfile | 1 | ||||
-rw-r--r-- | lava-slave/aliases/.empty | 0 | ||||
-rwxr-xr-x | lava-slave/scripts/setup.sh | 16 | ||||
-rwxr-xr-x | lavalab-gen.py | 6 |
5 files changed, 26 insertions, 0 deletions
@@ -299,6 +299,9 @@ boards: tags: (optional) List of tag to set on this device - tag1 - tag2 + aliases: (optional) List of aliases to set on the DEVICE TYPE. + - alias1 + - alias2 user: (optional) Name of user owning the board (LAVA default is admin) user is exclusive with group group: (optional) Name of group owning the board (no LAVA default) group is exclusive with user # One of uart or connection_command must be choosen diff --git a/lava-slave/Dockerfile b/lava-slave/Dockerfile index 3877404..b93e310 100644 --- a/lava-slave/Dockerfile +++ b/lava-slave/Dockerfile @@ -61,6 +61,7 @@ RUN mkdir -p /root/.config COPY devices/ /root/devices/ COPY tags/ /root/tags/ +COPY aliases/ /root/aliases/ COPY deviceinfo/ /root/deviceinfo/ RUN if [ -x /usr/local/bin/extra_actions ] ; then /usr/local/bin/extra_actions ; fi diff --git a/lava-slave/aliases/.empty b/lava-slave/aliases/.empty new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/lava-slave/aliases/.empty diff --git a/lava-slave/scripts/setup.sh b/lava-slave/scripts/setup.sh index 1fb0bb3..4bf2f67 100755 --- a/lava-slave/scripts/setup.sh +++ b/lava-slave/scripts/setup.sh @@ -143,6 +143,22 @@ do done done +for devicetype in $(ls /root/aliases/) +do + lavacli $LAVACLIOPTS device-types aliases list $devicetype > /tmp/device-types-aliases-$devicetype.list + while read alias + do + grep -q " $alias$" /tmp/device-types-aliases-$devicetype.list + if [ $? -eq 0 ];then + echo "DEBUG: $alias for $devicetype already present" + continue + fi + echo "DEBUG: Add alias $alias to $devicetype" + lavacli $LAVACLIOPTS device-types aliases add $devicetype $alias || exit $? + echo " $alias" >> /tmp/device-types-aliases-$devicetype.list + done < /root/aliases/$devicetype +done + if [ -e /etc/lava-dispatcher/certificates.d/$(hostname).key ];then echo "INFO: Enabling encryption" sed -i 's,.*ENCRYPT=.*,ENCRYPT="--encrypt",' /etc/lava-dispatcher/lava-slave diff --git a/lavalab-gen.py b/lavalab-gen.py index 28a3a22..2346689 100755 --- a/lavalab-gen.py +++ b/lavalab-gen.py @@ -626,6 +626,12 @@ def main(): for tag in board["tags"]: ftag.write("%s\n" % tag) ftag.close() + if "aliases" in board: + aliases_dir = "%s/aliases/" % workerdir + falias = open("%s/%s" % (aliases_dir, board["type"]), 'a') + for alias in board["aliases"]: + falias.write("%s\n" % alias) + falias.close() if "user" in board: deviceinfo = open("%s/deviceinfo/%s" % (workerdir, board_name), 'w') deviceinfo.write("DEVICE_USER=%s\n" % board["user"]) |