summaryrefslogtreecommitdiffstats
path: root/lavalab-gen.py
diff options
context:
space:
mode:
authorkhilman <khilman@users.noreply.github.com>2018-02-05 08:51:00 -0800
committerGitHub <noreply@github.com>2018-02-05 08:51:00 -0800
commit55ab0db7581e910322b165198a461a30ff87c58d (patch)
tree6a3afae164e8e9acde63719a57ef1ca3a60fda18 /lavalab-gen.py
parente3b883de8c99832687aeb5950f2114a992541d75 (diff)
parent302e41d55759affe58d77e14c15d728625a03d19 (diff)
Merge pull request #16 from montjoie/rework-misc
Rework misc
Diffstat (limited to 'lavalab-gen.py')
-rwxr-xr-xlavalab-gen.py49
1 files changed, 30 insertions, 19 deletions
diff --git a/lavalab-gen.py b/lavalab-gen.py
index 379f6b9..6a5ea43 100755
--- a/lavalab-gen.py
+++ b/lavalab-gen.py
@@ -14,7 +14,7 @@ boards_yaml = "boards.yaml"
tokens_yaml = "tokens.yaml"
baud_default = 115200
-template = string.Template("""#
+template_conmux = string.Template("""#
# auto-generated by lavalab-gen.py for ${board}
#
listener ${board}
@@ -27,7 +27,12 @@ command 'on' 'Power on ${board}' 'pduclient --daemon ${daemon} --host ${host} --
#no comment it is volontary
template_device = string.Template("""{% extends '${devicetype}.jinja2' %}
+""")
+
+template_device_conmux = string.Template("""
{% set connection_command = 'conmux-console ${board}' %}
+""")
+template_device_pdu = string.Template("""
{% set hard_reset_command = 'pduclient --daemon localhost --hostname acme-0 --port ${port} --command=reboot' %}
{% set power_off_command = 'pduclient --daemon localhost --hostname acme-0 --port ${port} --command=off' %}
{% set power_on_command = 'pduclient --daemon localhost --hostname acme-0 --port ${port} --command=on' %}
@@ -50,35 +55,45 @@ def main(args):
dockcomp["services"]["lava-slave"]["devices"] = []
dc_devices = dockcomp["services"]["lava-slave"]["devices"]
+ # The slaves directory must exists
+ if not os.path.isdir("lava-master/slaves/"):
+ os.mkdir("lava-master/slaves/")
+ fp = open("lava-master/slaves/.empty", "w")
+ fp.close()
+ if not os.path.isdir("lava-slave/conmux/"):
+ os.mkdir("lava-slave/conmux/")
+ fp = open("lava-slave/conmux/.empty", "w")
+ fp.close()
+
for lab_name in labs:
lab = labs[lab_name]
- for board_name in lab:
- b = lab[board_name]
+ for board_name in lab["boardlist"]:
+ b = lab["boardlist"][board_name]
if b.get("disabled", None):
continue
- if not b.has_key("uart"):
- print("WARNING: %s missing uart property" % board_name)
- continue
-
- baud = b["uart"].get("baud", baud_default)
if b.has_key("pdu"):
daemon = b["pdu"]["daemon"]
host = b["pdu"]["host"]
port = b["pdu"]["port"]
devicetype = b["type"]
delay_opt = ""
- line = template.substitute(board=board_name, baud=baud, daemon=daemon, host=host, port=port, delay=delay_opt)
device_line = template_device.substitute(board=board_name, port=port, devicetype=devicetype)
+ device_line += template_device_pdu.substitute(port=port)
+ if b.has_key("uart"):
+ baud = b["uart"].get("baud", baud_default)
+ line = template_conmux.substitute(board=board_name, baud=baud, daemon=daemon, host=host, port=port, delay=delay_opt)
serial = b["uart"]["serial"]
udev_line += template_udev.substitute(board=board_name, serial=serial)
dc_devices.append("/dev/%s:/dev/%s" % (board_name, board_name))
+ fp = open("lava-slave/conmux/%s.cf" % board_name, "w")
+ fp.write(line)
+ fp.close()
+ device_line += template_device_conmux.substitute(board=board_name)
if b.has_key("fastboot_serial_number"):
fserial = b["fastboot_serial_number"]
device_line += "{%% set fastboot_serial_number = '%s' %%}" % fserial
- if not os.path.isdir("lava-slave/conmux/"):
- os.mkdir("lava-slave/conmux/")
# board specific hacks
if devicetype == "qemu":
device_line += "{% set no_kvm = True %}\n"
@@ -87,9 +102,6 @@ def main(args):
device_path = "lava-master/devices/%s" % lab_name
if not os.path.isdir(device_path):
os.mkdir(device_path)
- fp = open("lava-slave/conmux/%s.cf" % board_name, "w")
- fp.write(line)
- fp.close()
board_device_file = "%s/%s.jinja2" % (device_path, board_name)
fp = open(board_device_file, "w")
fp.write(device_line)
@@ -97,11 +109,10 @@ def main(args):
fp = open("lavalab-udev-%s.rules" % lab_name, "w")
fp.write(udev_line)
fp.close()
- if not os.path.isdir("lava-master/slaves/"):
- os.mkdir("lava-master/slaves/")
- fp = open("lava-master/slaves/%s.yaml" % lab_name, "w")
- fp.write("dispatcher_ip: 192.168.66.1")
- fp.close()
+ if lab.has_key("dispatcher_ip"):
+ fp = open("lava-master/slaves/%s.yaml" % lab_name, "w")
+ fp.write("dispatcher_ip: %s" % lab["dispatcher_ip"])
+ fp.close()
#now proceed with tokens
fp = open(tokens_yaml, "r")