diff options
-rw-r--r-- | README.md | 2 | ||||
-rwxr-xr-x | lavalab-gen.py | 21 |
2 files changed, 11 insertions, 12 deletions
@@ -267,6 +267,7 @@ slaves: default_slave: Does this slave is the default slave where to add boards (default: lab-slave-0) bind_dev: Bind /dev from host to slave. This is needed when using some HID PDU use_nfs: Does the LAVA dispatcher will run NFS jobs + use_tap: Does TAP netdevices could be used arch: The arch of the worker (if not x86_64), only accept arm64 lava-coordinator: Does the slave should ran a lava-coordinator expose_ser2net: Do ser2net ports need to be available on host @@ -289,7 +290,6 @@ boards: type: the LAVA device-type of this device slave: (optional) Name of the slave managing this device. Default to first slave found or default_slave if set. kvm: (For qemu only) Does the qemu could use KVM (default: no) - tap: (For qemu only) Does the qemu could use TAP devices (default: no) uboot_ipaddr: (optional) a static IP to set in uboot uboot_macaddr: (Optional) the MAC address to set in uboot custom_option: (optional) All following strings will be directly append to devicefile diff --git a/lavalab-gen.py b/lavalab-gen.py index e51b891..6332284 100755 --- a/lavalab-gen.py +++ b/lavalab-gen.py @@ -292,7 +292,7 @@ def main(): else: 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", "zmq_auth_key", "zmq_auth_key_secret", "default_slave", "export_ser2net", "expose_ser2net", "remote_user_token", "zmq_auth_master_key", "expose_ports", "env", "bind_dev", "loglevel", "use_nfs", "arch", "devices", "lava-coordinator" ] + keywords_slaves = [ "name", "host", "dispatcher_ip", "remote_user", "remote_master", "remote_address", "remote_rpc_port", "remote_proto", "extra_actions", "zmq_auth_key", "zmq_auth_key_secret", "default_slave", "export_ser2net", "expose_ser2net", "remote_user_token", "zmq_auth_master_key", "expose_ports", "env", "bind_dev", "loglevel", "use_nfs", "arch", "devices", "lava-coordinator", "use_tap" ] for keyword in slave: if not keyword in keywords_slaves: print("WARNING: unknown keyword %s" % keyword) @@ -426,11 +426,13 @@ def main(): if "expose_ports" in worker: for eports in worker["expose_ports"]: dockcomp["services"][name]["ports"].append("%s" % eports) - if "bind_dev" in worker: + if "bind_dev" in worker and worker["bind_dev"]: dockcomp["services"][worker_name]["volumes"].append("/dev:/dev") dockcomp["services"][worker_name]["privileged"] = True - with open(dockcomposeymlpath, 'w') as f: - yaml.dump(dockcomp, f) + 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") if "extra_actions" in worker: fp = open("%s/scripts/extra_actions" % workerdir, "w") for eaction in worker["extra_actions"]: @@ -452,7 +454,7 @@ def main(): fudev = open("output/%s/udev/99-lavaworker-udev.rules" % host, "a") fudev.write(udev_line) fudev.close() - if not "bind_dev" in slave: + if not "bind_dev" in slave or not slave["bind_dev"]: dockcomp_add_device(dockcomp, worker_name, "/dev/%s:/dev/%s" % (udev_dev["name"], udev_dev["name"])) use_nfs = False if "use_nfs" in worker: @@ -463,6 +465,8 @@ def main(): fp.write("apt-get -y install nfs-kernel-server\n") fp.close() os.chmod("%s/scripts/extra_actions" % workerdir, 0o755) + with open(dockcomposeymlpath, 'w') as f: + yaml.dump(dockcomp, f) if "loglevel" in worker: for component in worker["loglevel"]: if component != "lava-slave": @@ -519,11 +523,6 @@ def main(): if use_kvm: dockcomp_add_device(dockcomp, worker_name, "/dev/kvm:/dev/kvm") # board specific hacks - use_tap = False - if "tap" in board: - use_tap = board["tap"] - if use_tap: - dockcomp_add_device(dockcomp, worker_name, "/dev/net/tun:/dev/net/tun") if devicetype == "qemu" and not use_kvm: device_line += "{% set no_kvm = True %}\n" if "uart" in board: @@ -550,7 +549,7 @@ def main(): fp = open("output/%s/udev/99-lavaworker-udev.rules" % host, "a") fp.write(udev_line) fp.close() - if not "bind_dev" in slave: + if not "bind_dev" in slave or not slave["bind_dev"]: dockcomp_add_device(dockcomp, worker_name, "/dev/%s:/dev/%s" % (board_name, board_name)) use_conmux = False use_ser2net = False |