summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkhilman <khilman@users.noreply.github.com>2018-09-11 11:19:40 -0700
committerGitHub <noreply@github.com>2018-09-11 11:19:40 -0700
commit0d143406d41fcd7a4b03a3941cc3a66c294b21b2 (patch)
tree7593e9f148930f39479a2a5b6ea9bf49fcfd2732
parent37566b908c442e1e27e1da5b24c384a78c20ca87 (diff)
parente010e54db9afbf8c7b1315ec6e998649f12a2558 (diff)
Merge pull request #44 from montjoie/ser2net_multiconnections
Ser2net multiconnections
-rw-r--r--README.md1
-rw-r--r--lava-slave/Dockerfile7
-rwxr-xr-xlavalab-gen.py40
3 files changed, 43 insertions, 5 deletions
diff --git a/README.md b/README.md
index 99e3bf1..deccb54 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/lava-slave/Dockerfile b/lava-slave/Dockerfile
index e07c01e..cbaafdc 100644
--- a/lava-slave/Dockerfile
+++ b/lava-slave/Dockerfile
@@ -22,6 +22,13 @@ RUN rm /etc/apt/sources.list.d/testing.list
RUN apt-get -y install ser2net
COPY ser2net.conf /etc
+# ser2net > 3.2 is only availlable from sid
+RUN echo "deb http://deb.debian.org/debian/ sid main" >> /etc/apt/sources.list.d/sid.list
+RUN apt-get update
+RUN DEBIAN_FRONTEND=noninteractive apt-get -y install ser2net
+RUN rm /etc/apt/sources.list.d/sid.list
+RUN apt-get update
+
# lava-cli dependencies
RUN apt-get -y install python3-setuptools python3-dev python3-zmq
RUN git clone https://git.linaro.org/lava/lavacli.git /root/lavacli && cd /root/lavacli && git checkout v0.7 && python3 setup.py install
diff --git a/lavalab-gen.py b/lavalab-gen.py
index b327813..010839f 100755
--- a/lavalab-gen.py
+++ b/lavalab-gen.py
@@ -12,6 +12,8 @@ import shutil
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}
@@ -219,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)
@@ -326,7 +328,6 @@ def main():
if "boards" not in workers:
print("Missing boards")
sys.exit(1)
- ser2net_port = 60000
boards = workers["boards"]
for board in boards:
board_name = board["name"]
@@ -418,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()
@@ -453,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")