diff options
Diffstat (limited to 'lavalab-gen.py')
-rwxr-xr-x | lavalab-gen.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/lavalab-gen.py b/lavalab-gen.py index 7061a72..5191f07 100755 --- a/lavalab-gen.py +++ b/lavalab-gen.py @@ -93,7 +93,7 @@ def main(): else: masters = workers["masters"] for master in masters: - keywords_master = [ "name", "type", "host", "users", "groups", "tokens", "webadmin_https", "persistent_db", "zmq_auth", "zmq_auth_key", "zmq_auth_key_secret", "http_fqdn", "slave_keys" ] + keywords_master = [ "name", "type", "host", "users", "groups", "tokens", "webadmin_https", "persistent_db", "zmq_auth", "zmq_auth_key", "zmq_auth_key_secret", "http_fqdn", "slave_keys", "slaveenv" ] for keyword in master: if not keyword in keywords_master: print("WARNING: unknown keyword %s" % keyword) @@ -243,6 +243,16 @@ def main(): ftok.write("TOKEN=" + vtoken + "\n") ftok.write("DESCRIPTION=\"%s\"" % description) ftok.close() + if "slaveenv" in worker: + for slaveenv in worker["slaveenv"]: + slavename = slaveenv["name"] + envdir = "%s/env/%s" % (workerdir, slavename) + os.mkdir(envdir) + fenv = open("%s/env.yaml" % envdir, 'w') + fenv.write("overrides:") + for line in slaveenv["env"]: + fenv.write(" %s\n" % line) + fenv.close() default_slave = "lab-slave-0" if "slaves" not in workers: @@ -250,7 +260,7 @@ def main(): else: 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", "export_ser2net", "expose_ser2net", "remote_user_token", "zmq_auth_master_key", "expose_ports" ] + 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", "expose_ser2net", "remote_user_token", "zmq_auth_master_key", "expose_ports", "env" ] for keyword in slave: if not keyword in keywords_slaves: print("WARNING: unknown keyword %s" % keyword) @@ -297,6 +307,7 @@ def main(): worker = slave worker_name = name + slave_master = None #NOTE remote_master is on slave if not "remote_master" in worker: remote_master = "lava-master" @@ -326,6 +337,7 @@ def main(): shutil.copy(worker["zmq_auth_master_key"], "%s/zmq_auth/" % workerdir) for fm in masters: if fm["name"] == remote_master: + slave_master = fm for fuser in fm["users"]: if fuser["name"] == remote_user: remote_token = fuser["token"] @@ -345,6 +357,17 @@ def main(): if remote_token is "BAD": print("Cannot find %s on %s" % (remote_user, remote_master)) sys.exit(1) + if "env" in slave: + if not slave_master: + print("Cannot set env without master") + sys.exit(1) + envdir = "output/%s/%s/env/%s" % (slave_master["host"], slave_master["name"], name) + os.mkdir(envdir) + fenv = open("%s/env.yaml" % envdir, 'w') + fenv.write("overrides:") + for line in slave["env"]: + fenv.write(" %s\n" % line) + fenv.close() if not "remote_proto" in worker: remote_proto = "http" else: |