summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorentin LABBE <clabbe@baylibre.com>2018-08-29 13:38:56 +0200
committerCorentin LABBE <clabbe@baylibre.com>2018-09-07 10:58:33 +0200
commite010e54db9afbf8c7b1315ec6e998649f12a2558 (patch)
tree0bcea86a0531727a228989c4c8d937336b472f75
parentc4e7d2900d89ec811d44f9eb2a41a5086f3c8b8e (diff)
lavalab-gen.py: add default max-connections for ser2net
This patch add a ser2net max-connections for all boards
-rw-r--r--README.md1
-rwxr-xr-xlavalab-gen.py39
2 files changed, 35 insertions, 5 deletions
diff --git a/README.md b/README.md
index 678fddb..1d43a34 100644
--- a/README.md
+++ b/README.md
@@ -243,6 +243,7 @@ slaves:
remote_user: the user used for connecting to the master
remote_proto: http(default) or https
default_slave: Does this slave is the default slave where to add boards (default: lab-slave-0)
+ export_ser2net: Do ser2net ports need to be available on host
extra_actions: An optional list of action to do at end of the docker build
- "apt-get install package"
diff --git a/lavalab-gen.py b/lavalab-gen.py
index 34c947d..010839f 100755
--- a/lavalab-gen.py
+++ b/lavalab-gen.py
@@ -13,6 +13,7 @@ boards_yaml = "boards.yaml"
tokens_yaml = "tokens.yaml"
baud_default = 115200
ser2net_port_start = 63001
+ser2net_ports = {}
template_conmux = string.Template("""#
# auto-generated by lavalab-gen.py for ${board}
@@ -220,7 +221,7 @@ 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", "zmq_auth_key", "zmq_auth_key_secret", "default_slave" ]
+ 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" ]
for keyword in slave:
if not keyword in keywords_slaves:
print("WARNING: unknown keyword %s" % keyword)
@@ -327,7 +328,6 @@ def main():
if "boards" not in workers:
print("Missing boards")
sys.exit(1)
- ser2net_port = ser2net_port_start
boards = workers["boards"]
for board in boards:
board_name = board["name"]
@@ -419,9 +419,14 @@ def main():
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
+ if not worker_name in ser2net_ports:
+ ser2net_ports[worker_name] = ser2net_port_start
+ fp = open("%s/ser2net.conf" % workerdir, "a")
+ fp.write("DEFAULT:max-connections:10")
+ fp.close()
+ ser2net_line = template_ser2net.substitute(port=ser2net_ports[worker_name],baud=baud,board=board_name)
+ device_line += template_device_ser2net.substitute(port=ser2net_ports[worker_name])
+ ser2net_ports[worker_name] += 1
fp = open("%s/ser2net.conf" % workerdir, "a")
fp.write(ser2net_line)
fp.close()
@@ -454,6 +459,30 @@ def main():
fp.close()
with open(dockcomposeymlpath, 'w') as f:
yaml.dump(dockcomp, f)
+ #end for board
+
+ for slave_name in ser2net_ports:
+ export_ser2net = False
+ for fs in workers["slaves"]:
+ if fs["name"] == slave_name:
+ if not "host" in fs:
+ host = "local"
+ else:
+ host = fs["host"]
+ if "export_ser2net" in fs:
+ export_ser2net = fs["export_ser2net"]
+ if not export_ser2net:
+ continue
+ print("Add ser2net ports for %s (%s) %s-%s" % (slave_name, host, ser2net_port_start, ser2net_ports[slave_name]))
+ dockcomposeymlpath = "output/%s/docker-compose.yml" % host
+ fp = open(dockcomposeymlpath, "r")
+ dockcomp = yaml.load(fp)
+ fp.close()
+ ser2net_port_max = ser2net_ports[slave_name] - 1
+ dockcomp["services"][slave_name]["ports"].append("%s-%s:%s-%s" % (ser2net_port_start, ser2net_port_max, ser2net_port_start, ser2net_port_max))
+ with open(dockcomposeymlpath, 'w') as f:
+ yaml.dump(dockcomp, f)
+
zmq_auth_genlist.close()
if need_zmq_auth_gen:
print("Gen ZMQ auth files")