diff options
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | lava-master/Dockerfile | 10 | ||||
-rw-r--r-- | lava-master/lava-patch/.empty | 0 | ||||
-rwxr-xr-x | lava-master/scripts/setup.sh | 24 | ||||
-rwxr-xr-x | lava-master/scripts/start.sh | 3 | ||||
-rw-r--r-- | lava-slave/Dockerfile | 8 | ||||
-rw-r--r-- | lava-slave/lava-screen.conf | 0 | ||||
-rwxr-xr-x | lava-slave/scripts/start.sh | 16 | ||||
-rw-r--r-- | lava-slave/ser2net.conf | 0 | ||||
-rwxr-xr-x | lavalab-gen.py | 60 |
10 files changed, 108 insertions, 18 deletions
@@ -251,6 +251,8 @@ boards: idproduct: the PID of the UART (Formated as 0xXXXX) serial: The serial number in case of FTDI uart devpath: the UDEV devpath to this uart for UART without serial number + use_ser2net: True/false (Use ser2net instead of conmux-console) + use_screen: True/false (Use screen via ssh instead of conmux-console) connection_command: A command to be ran for getting a serial console pdu_generic: hard_reset_command: commandline to reset the board @@ -316,6 +318,9 @@ A squid docker is provided for caching all LAVA downloads (image, dtb, rootfs, e You have to uncomment a line in lava-master/Dockerfile to enable it.<br/> For the moment, it is unsupported and unbuilded. +## Backporting LAVA patches +All upstream LAVA patches could be backported by placing them in lava-master/lava-patch/ + ## Security Note that this container provides defaults which are unsecure. If you plan on deploying this in a production enviroment please consider the following items: diff --git a/lava-master/Dockerfile b/lava-master/Dockerfile index 137a59a..7d61103 100644 --- a/lava-master/Dockerfile +++ b/lava-master/Dockerfile @@ -4,10 +4,6 @@ RUN echo "deb http://ftp.fr.debian.org/debian/ stretch-backports main" >> /etc/a RUN apt-get update -# Add services helper utilities to start and stop LAVA -COPY scripts/stop.sh . -COPY scripts/start.sh . - # Install debian packages used by the container # Configure apache to run the lava server # Log the hostname used during install for the slave name @@ -81,7 +77,6 @@ COPY device-types/ /root/device-types/ COPY users/ /root/lava-users/ COPY tokens/ /root/lava-callback-tokens/ COPY scripts/setup.sh / -RUN /start.sh && /setup.sh && /stop.sh #uncomment if you want to use squid # warning the address used must be network accessible by all slave @@ -91,7 +86,10 @@ RUN /start.sh && /setup.sh && /stop.sh COPY settings.conf /etc/lava-server/ COPY device-types-patch/ /root/device-types-patch/ -RUN cd /etc/lava-server/dispatcher-config/device-types/ && for patch in $(ls /root/device-types-patch/*patch) ; do sed -i 's,lava_scheduler_app/tests/device-types/,,' $patch && patch < $patch ; done +RUN cd /etc/lava-server/dispatcher-config/device-types/ && for patch in $(ls /root/device-types-patch/*patch) ; do sed -i 's,lava_scheduler_app/tests/device-types/,,' $patch && patch < $patch || exit $?; done + +COPY lava-patch/ /root/lava-patch +RUN cd /usr/lib/python3/dist-packages && for patch in $(ls /root/lava-patch/*patch) ; do patch -p1 < $patch || exit $?;done EXPOSE 69/udp 80 3079 5555 5556 diff --git a/lava-master/lava-patch/.empty b/lava-master/lava-patch/.empty new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/lava-master/lava-patch/.empty diff --git a/lava-master/scripts/setup.sh b/lava-master/scripts/setup.sh index 3ab2abd..585499e 100755 --- a/lava-master/scripts/setup.sh +++ b/lava-master/scripts/setup.sh @@ -20,10 +20,15 @@ if [ -e /root/lava-users ];then if [ $SUPERUSER -eq 1 ];then USER_OPTION="$USER_OPTION --superuser" fi - echo "Adding username $USER DEBUG(with $TOKEN / $PASSWORD / $USER_OPTION)" - lava-server manage users add --passwd $PASSWORD $USER_OPTION $USER || exit 1 - if [ ! -z "$TOKEN" ];then - lava-server manage tokens add --user $USER --secret $TOKEN || exit 1 + lava-server manage users list | grep -q "[[:space:]]$USER$" + if [ $? -eq 0 ];then + echo "Skip already existing $USER DEBUG(with $TOKEN / $PASSWORD / $USER_OPTION)" + else + echo "Adding username $USER DEBUG(with $TOKEN / $PASSWORD / $USER_OPTION)" + lava-server manage users add --passwd $PASSWORD $USER_OPTION $USER || exit 1 + if [ ! -z "$TOKEN" ];then + lava-server manage tokens add --user $USER --secret $TOKEN || exit 1 + fi fi done fi @@ -56,9 +61,14 @@ if [ -e /root/device-types ];then do cp $i /etc/lava-server/dispatcher-config/device-types/ devicetype=$(basename $i |sed 's,.jinja2,,') - echo "Adding custom $devicetype" - lava-server manage device-types add $devicetype || exit $? - touch /root/.lavadocker/devicetype-$devicetype + lava-server manage device-types list | grep -q "[[:space:]]$devicetype[[:space:]]" + if [ $? -eq 0 ];then + echo "Skip already known $devicetype" + else + echo "Adding custom $devicetype" + lava-server manage device-types add $devicetype || exit $? + touch /root/.lavadocker/devicetype-$devicetype + fi done fi diff --git a/lava-master/scripts/start.sh b/lava-master/scripts/start.sh index 0e223b5..c34fe34 100755 --- a/lava-master/scripts/start.sh +++ b/lava-master/scripts/start.sh @@ -25,6 +25,9 @@ start () { rm -f /var/run/lava-*.pid 2> /dev/null /etc/init.d/postgresql start + +/setup.sh || exit $? + start apache2 || exit $? start lava-logs || exit $? start lava-master || exit $? diff --git a/lava-slave/Dockerfile b/lava-slave/Dockerfile index b7252ef..a5b0148 100644 --- a/lava-slave/Dockerfile +++ b/lava-slave/Dockerfile @@ -53,6 +53,9 @@ RUN apt-get update RUN DEBIAN_FRONTEND=noninteractive apt-get -y install cu RUN rm /etc/apt/sources.list.d/testing.list +RUN apt-get -y install ser2net +COPY ser2net.conf /etc + COPY scripts/lava-slave /etc/init.d/ RUN chmod 755 /etc/init.d/lava-slave @@ -78,6 +81,11 @@ COPY devices/ /root/devices/ COPY scripts/extra_actions /root/ RUN if [ -x /root/extra_actions ] ; then /root/extra_actions ; fi +RUN apt-get -y install screen openssh-server +RUN ssh-keygen -q -f /root/.ssh/id_rsa +RUN cat /root/.ssh/id_rsa.pub > /root/.ssh/authorized_keys +COPY lava-screen.conf /root/ + EXPOSE 69/udp 80 CMD /start.sh diff --git a/lava-slave/lava-screen.conf b/lava-slave/lava-screen.conf new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/lava-slave/lava-screen.conf diff --git a/lava-slave/scripts/start.sh b/lava-slave/scripts/start.sh index 35e58a4..21b6903 100755 --- a/lava-slave/scripts/start.sh +++ b/lava-slave/scripts/start.sh @@ -8,6 +8,9 @@ if [[ -n "$LAVA_MASTER" ]]; then fi service tftpd-hpa start || exit 4 +if [ -s /etc/ser2net.conf ];then + service ser2net start || exit 7 +fi touch /var/run/conmux-registry /usr/sbin/conmux-registry 63000 /var/run/conmux-registry& @@ -20,6 +23,19 @@ do /usr/sbin/conmux $item & done +HAVE_SCREEN=0 +while read screenboard +do + echo "Start screen for $screenboard" + TERM=xterm screen -d -m -S $screenboard /dev/$screenboard 115200 -ixoff -ixon || exit 9 + HAVE_SCREEN=1 +done < /root/lava-screen.conf +if [ $HAVE_SCREEN -eq 1 ];then + sed -i 's,UsePAM.*yes,UsePAM no,' /etc/ssh/sshd_config || exit 10 + service ssh start || exit 11 +fi + + # start an http file server for boot/transfer_overlay support (cd /var/lib/lava/dispatcher; python -m SimpleHTTPServer 80) & diff --git a/lava-slave/ser2net.conf b/lava-slave/ser2net.conf new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/lava-slave/ser2net.conf diff --git a/lavalab-gen.py b/lavalab-gen.py index 6df9cf4..f6663a2 100755 --- a/lavalab-gen.py +++ b/lavalab-gen.py @@ -36,6 +36,17 @@ template_device_pdu_generic = string.Template(""" {% set power_on_command = '${power_on_command}' %} """) +template_ser2net = string.Template(""" +${port}:telnet:600:/dev/${board}:${baud} 8DATABITS NONE 1STOPBIT banner +""") +template_device_ser2net = string.Template(""" +{% set connection_command = 'telnet 127.0.0.1 ${port}' %} +""") + +template_device_screen = string.Template(""" +{% set connection_command = 'ssh -o StrictHostKeyChecking=no -t root@127.0.0.1 "TERM=xterm screen -x ${board}"' %} +""") + template_udev_serial = string.Template("""# SUBSYSTEM=="tty", ATTRS{idVendor}=="${idvendor}", ATTRS{idProduct}=="${idproduct}", ATTRS{serial}=="${serial}", MODE="0664", OWNER="uucp", SYMLINK+="${board}" """) @@ -74,6 +85,10 @@ def main(): sys.exit(1) masters = workers["masters"] for master in masters: + keywords_master = [ "name", "type", "host", "users", "tokens", "webadmin_https" ] + for keyword in master: + if not keyword in keywords_master: + print("WARNING: unknown keyword %s" % keyword) name = master["name"] print("Handle %s\n" % name) if not "host" in master: @@ -116,6 +131,10 @@ def main(): fsettings.close() if "users" in worker: for user in worker["users"]: + keywords_users = [ "name", "staff", "superuser", "password", "token" ] + for keyword in user: + if not keyword in keywords_users: + print("WARNING: unknown keyword %s" % keyword) username = user["name"] ftok = open("%s/%s" % (userdir, username), "w") token = user["token"] @@ -139,6 +158,10 @@ def main(): filename_num = {} print("Found tokens") for token in worker["tokens"]: + keywords_tokens = [ "username", "token", "description" ] + for keyword in token: + if not keyword in keywords_tokens: + print("WARNING: unknown keyword %s" % keyword) username = token["username"] description = token["description"] if username in filename_num: @@ -162,6 +185,10 @@ def main(): sys.exit(1) slaves = workers["slaves"] for slave in slaves: + keywords_slaves = [ "name", "host", "dispatcher_ip", "remote_user", "remote_master", "remote_address", "remote_rpc_port", "remote_proto", "extra_actions" ] + for keyword in slave: + if not keyword in keywords_slaves: + print("WARNING: unknown keyword %s" % keyword) name = slave["name"] if len(slaves) == 1: default_slave = name @@ -252,6 +279,7 @@ def main(): if "boards" not in workers: print("Missing boards") sys.exit(1) + ser2net_port = 60000 boards = workers["boards"] for board in boards: board_name = board["name"] @@ -310,7 +338,6 @@ def main(): if type(idvendor) == str: print("Please put hexadecimal IDs for vendor %s (like 0x%s)" % (board_name, idvendor)) sys.exit(1) - line = template_conmux.substitute(board=board_name, baud=baud) if "serial" in uart: serial = board["uart"]["serial"] udev_line = template_udev_serial.substitute(board=board_name, serial=serial, idvendor="%04x" % idvendor, idproduct="%04x" % idproduct) @@ -328,10 +355,33 @@ def main(): dockcomp["services"][worker_name]["devices"] = [] dc_devices = dockcomp["services"][worker_name]["devices"] dc_devices.append("/dev/%s:/dev/%s" % (board_name, board_name)) - fp = open("%s/conmux/%s.cf" % (workerdir, board_name), "w") - fp.write(line) - fp.close() - device_line += template_device_conmux.substitute(board=board_name) + use_conmux = True + use_ser2net = False + use_screen = False + if "use_ser2net" in uart: + use_conmux = False + use_ser2net = True + if "use_screen" in uart: + use_conmux = False + use_screen = True + if use_conmux: + conmuxline = template_conmux.substitute(board=board_name, baud=baud) + device_line += template_device_conmux.substitute(board=board_name) + fp = open("%s/conmux/%s.cf" % (workerdir, board_name), "w") + fp.write(conmuxline) + fp.close() + if use_ser2net: + ser2net_line = template_ser2net.substitute(port=ser2net_port,baud=baud,board=board_name) + device_line += template_device_ser2net.substitute(port=ser2net_port) + ser2net_port += 1 + fp = open("%s/ser2net.conf" % workerdir, "a") + fp.write(ser2net_line) + fp.close() + if use_screen: + device_line += template_device_screen.substitute(board=board_name) + fp = open("%s/lava-screen.conf" % workerdir, "a") + fp.write("%s\n" % board_name) + fp.close() elif "connection_command" in board: connection_command = board["connection_command"] device_line += template_device_connection_command.substitute(connection_command=connection_command) |