diff options
author | Corentin LABBE <clabbe@baylibre.com> | 2020-11-23 09:38:48 +0000 |
---|---|---|
committer | Corentin LABBE <clabbe@baylibre.com> | 2020-11-23 10:01:35 +0000 |
commit | 3825e16f0833072d2b3bed0c4aaea2c4d5c22b0c (patch) | |
tree | 658a08a96e25a16d80a8512228aad029371e63c6 | |
parent | a9c41d2882d4b63f201e43fde959f375bdc3c2ad (diff) |
Add dockcomp_add_cap helper
Add an helper to add caps
-rwxr-xr-x | lavalab-gen.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lavalab-gen.py b/lavalab-gen.py index e2e0607..64bb1f1 100755 --- a/lavalab-gen.py +++ b/lavalab-gen.py @@ -93,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]) @@ -567,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"] |