Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use_bridge: add option to create virtual bridge inside worker #128

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ slaves:
use_overlay_server: Does LAVA need an overlay server (default True)
use_nfs: Does the LAVA dispatcher will run NFS jobs
use_tap: Does TAP netdevices could be used
use_bridge: Does bridge netdevices could be used
use_docker: Permit to use docker commands in slave
arch: The arch of the worker (if not x86_64), only accept arm64
host_healthcheck: If true, enable the optional healthcheck container. See hosting healthchecks below
Expand Down
19 changes: 18 additions & 1 deletion lavalab-gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def main():
"name",
"remote_user", "remote_master", "remote_address", "remote_rpc_port", "remote_proto", "remote_user_token",
"tags",
"use_docker", "use_nfs", "use_nbd", "use_overlay_server", "use_tftp", "use_tap",
"use_docker", "use_nfs", "use_nbd", "use_overlay_server", "use_tftp", "use_tap", "use_bridge",
"version",
"zmq_auth_key", "zmq_auth_key_secret",
"zmq_auth_master_key",
Expand Down Expand Up @@ -638,6 +638,23 @@ def main():
fp.write("apt-get -y install nfs-kernel-server\n")
fp.close()
os.chmod("%s/scripts/extra_actions" % workerdir, 0o755)
if "use_bridge" in worker and worker["use_bridge"]:
dockcomp_add_device(dockcomp, worker_name, "/dev/net/tun:/dev/net/tun")
if "cap_add" not in dockcomp["services"][worker_name]:
dockcomp["services"][worker_name]["cap_add"] = ["NET_ADMIN"]
elif "NET_ADMIN" not in dockcomp["services"][worker_name]["cap_add"]:
dockcomp["services"][worker_name]["cap_add"].append("NET_ADMIN")
dockcomp["services"][worker_name]["privileged"] = True
fp = open("%s/scripts/extra_actions" % workerdir, "a")
fp.write("apt-get --no-install-recommends -y install libvirt-clients libvirt-daemon-system dnsmasq\n")
fp.write("mkdir -p /etc/qemu\n")
fp.write("echo 'allow virbr0' > /etc/qemu/bridge.conf\n")
fp.write("echo 'service libvirtd start' > /root/entrypoint.d/virtd_start.sh\n")
fp.write("echo 'virsh net-start default' >> /root/entrypoint.d/virtd_start.sh\n")
fp.write("chmod +x /root/entrypoint.d/virtd_start.sh\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:
Expand Down