diff options
author | Kevin Hilman <khilman@baylibre.com> | 2021-01-04 08:36:41 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-04 08:36:41 -0800 |
commit | 9b1f44982e0091d5e620d225b59ad5a4c0fc5aeb (patch) | |
tree | 075621a294fd16b0e177529af3073427aedd3c64 | |
parent | 7151f9ebc95495b0eb3beb6ee556737a5c6ed163 (diff) | |
parent | 7739038c60331b71add3d5183412e50a38bfa2f3 (diff) |
Merge pull request #130 from montjoie/support-2020.09plus
Support 2020.09plus
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | lava-slave/Dockerfile | 5 | ||||
-rw-r--r-- | lava-slave/lava-screen.conf | 0 | ||||
-rw-r--r-- | lava-slave/scripts/getworkertoken.py | 15 | ||||
-rwxr-xr-x | lava-slave/scripts/setup.sh | 18 | ||||
-rwxr-xr-x | lava-slave/scripts/start.sh | 13 | ||||
-rwxr-xr-x | lavalab-gen.py | 31 |
7 files changed, 46 insertions, 38 deletions
@@ -344,7 +344,6 @@ boards: ser2net_options: (optional) A list of ser2net options to add - option1 - option2 - use_screen: True/False (Use screen via ssh instead of ser2net) connection_command: A command to be ran for getting a serial console pdu_generic: hard_reset_command: commandline to reset the board @@ -353,7 +352,6 @@ boards: ``` Notes on UART: * Only one of devpath/serial is necessary. -* screen usage is discouraged and should not be used, it was added as a workaround for some boards, but ser2net now can handle them. * For finding the right devpath, you could use ``` udevadm info -a -n /dev/ttyUSBx |grep devpath | head -n1 diff --git a/lava-slave/Dockerfile b/lava-slave/Dockerfile index b37f7a6..bb59174 100644 --- a/lava-slave/Dockerfile +++ b/lava-slave/Dockerfile @@ -68,11 +68,6 @@ RUN chmod +x /root/entrypoint.d/* RUN if [ -x /usr/local/bin/extra_actions ] ; then /usr/local/bin/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/ - COPY zmq_auth/ /etc/lava-dispatcher/certificates.d/ EXPOSE 69/udp 80 diff --git a/lava-slave/lava-screen.conf b/lava-slave/lava-screen.conf deleted file mode 100644 index e69de29..0000000 --- a/lava-slave/lava-screen.conf +++ /dev/null diff --git a/lava-slave/scripts/getworkertoken.py b/lava-slave/scripts/getworkertoken.py new file mode 100644 index 0000000..f538960 --- /dev/null +++ b/lava-slave/scripts/getworkertoken.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 + +import xmlrpc.client +import sys + +if len(sys.argv) < 3: + print("ERROR: Usage: %s URI workername" % sys.argv[0]) + sys.exit(1) + +server = xmlrpc.client.ServerProxy("%s" % sys.argv[1]) +wdet = server.scheduler.workers.show("%s" % sys.argv[2]) +if "token" in wdet: + print(wdet["token"]) + sys.exit(0) +sys.exit(1) diff --git a/lava-slave/scripts/setup.sh b/lava-slave/scripts/setup.sh index 58672c3..9873a91 100755 --- a/lava-slave/scripts/setup.sh +++ b/lava-slave/scripts/setup.sh @@ -68,6 +68,24 @@ do else echo "Adding worker $worker" lavacli $LAVACLIOPTS workers add --description "LAVA dispatcher on $(cat /root/phyhostname)" $worker || exit $? + # does we ran 2020.09+ and worker need a token + fi + grep -q "TOKEN" /root/entrypoint.sh + if [ $? -eq 0 ];then + echo "DEBUG: Worker need a TOKEN" + # TODO use token from env + WTOKEN=$(getworkertoken.py $LAVA_MASTER_URI $worker) + if [ $? -eq 0 ];then + sed -i "s,.*TOKEN.*,TOKEN=\"--token $WTOKEN\"," /etc/lava-dispatcher/lava-worker || exit $? + else + echo "ERROR: cannot get WORKER TOKEN" + exit 1 + fi + echo "DEBUG: set master URL to $LAVA_MASTER_URL" + sed -i "s,^# URL.*,URL=\"$LAVA_MASTER_URL\"," /etc/lava-dispatcher/lava-worker || exit $? + cat /etc/lava-dispatcher/lava-worker + else + echo "DEBUG: Worker does not need a TOKEN" fi if [ ! -z "$LAVA_DISPATCHER_IP" ];then echo "Add dispatcher_ip $LAVA_DISPATCHER_IP to $worker" diff --git a/lava-slave/scripts/start.sh b/lava-slave/scripts/start.sh index 334f52e..8d7882f 100755 --- a/lava-slave/scripts/start.sh +++ b/lava-slave/scripts/start.sh @@ -25,19 +25,6 @@ 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; python3 -m http.server 80) & diff --git a/lavalab-gen.py b/lavalab-gen.py index 66bc193..e4b3487 100755 --- a/lavalab-gen.py +++ b/lavalab-gen.py @@ -44,10 +44,6 @@ 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_settings_conf = string.Template(""" { "DEBUG": false, @@ -97,6 +93,11 @@ def dockcomp_add_device(dockcomp, worker_name, devicemap): return dc_devices.append(devicemap) +def dockcomp_add_cap(dockcomp, worker_name, cap): + if "cap_add" not in dockcomp["services"][worker_name]: + dockcomp["services"][worker_name]["cap_add"] = [] + dockcomp["services"][worker_name]["cap_add"].append(cap) + def usage(): print("%s [boardsfile.yaml]" % sys.argv[0]) @@ -373,7 +374,8 @@ def main(): for slaveenv in worker["slaveenv"]: slavename = slaveenv["name"] envdir = "%s/env/%s" % (workerdir, slavename) - os.mkdir(envdir) + if not os.path.isdir(envdir): + os.mkdir(envdir) fenv = open("%s/env.yaml" % envdir, 'w') fenv.write("overrides:\n") for line in slaveenv["env"]: @@ -523,7 +525,7 @@ def main(): else: zmq_auth_genlist.write("%s/%s %s/%s\n" % (host, name, fm["host"], fm["name"])) need_zmq_auth_gen = True - if remote_token is "BAD": + if remote_token == "BAD": print("Cannot find %s on %s" % (remote_user, remote_master)) sys.exit(1) if "env" in slave: @@ -549,7 +551,9 @@ def main(): else: remote_proto = worker["remote_proto"] remote_uri = "%s://%s:%s@%s:%s/RPC2" % (remote_proto, remote_user, remote_token, remote_address, remote_rpc_port) + remote_master_url = "%s://%s:%s" % (remote_proto, remote_address, remote_rpc_port) dockcomp["services"][worker_name]["environment"]["LAVA_MASTER_URI"] = remote_uri + dockcomp["services"][worker_name]["environment"]["LAVA_MASTER_URL"] = remote_master_url dockcomp["services"][worker_name]["environment"]["LAVA_MASTER_USER"] = remote_user dockcomp["services"][worker_name]["environment"]["LAVA_MASTER_BASEURI"] = "%s://%s:%s/RPC2" % (remote_proto, remote_address, remote_rpc_port) dockcomp["services"][worker_name]["environment"]["LAVA_MASTER_TOKEN"] = remote_token @@ -568,8 +572,7 @@ def main(): dockcomp["services"][worker_name]["privileged"] = True if "use_tap" in worker and worker["use_tap"]: dockcomp_add_device(dockcomp, worker_name, "/dev/net/tun:/dev/net/tun") - dockcomp["services"][worker_name]["cap_add"] = [] - dockcomp["services"][worker_name]["cap_add"].append("NET_ADMIN") + dockcomp_add_cap(dockcomp, worker_name, "NET_ADMIN") if "host_healthcheck" in worker and worker["host_healthcheck"]: dockcomp["services"]["healthcheck"] = {} dockcomp["services"]["healthcheck"]["ports"] = ["8080:8080"] @@ -728,17 +731,14 @@ def main(): dockcomp_add_device(dockcomp, worker_name, "/dev/%s:/dev/%s" % (board_name, board_name)) use_conmux = False use_ser2net = False - use_screen = False - if "use_screen" in uart: - use_screen = uart["use_screen"] if "use_conmux" in uart: use_conmux = uart["use_conmux"] if "use_ser2net" in uart: use_ser2net = uart["use_ser2net"] - if (use_conmux and use_ser2net) or (use_conmux and use_screen) or (use_screen and use_ser2net): + if (use_conmux and use_ser2net): print("ERROR: Only one uart handler must be configured") sys.exit(1) - if not use_conmux and not use_screen and not use_ser2net and not "connection_command" in board: + if not use_conmux and not use_ser2net and not "connection_command" in board: use_ser2net = True if use_conmux: conmuxline = template_conmux.substitute(board=board_name, baud=baud) @@ -761,11 +761,6 @@ def main(): fp = open("%s/ser2net.conf" % workerdir, "a") fp.write(ser2net_line + " banner\n") 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() if "connection_command" in board: connection_command = board["connection_command"] device_line += template_device_connection_command.substitute(connection_command=connection_command) |