summaryrefslogtreecommitdiffstats
path: root/lavalab-gen.py
diff options
context:
space:
mode:
authorCorentin LABBE <clabbe@baylibre.com>2018-07-04 15:35:13 +0200
committerCorentin LABBE <clabbe@baylibre.com>2018-07-19 21:16:22 +0200
commit70bffaef36b2afe7c732d6f20afca008c5ef1445 (patch)
treea4f70f46f0b6c9e007516b7f2f313d2e0ca09051 /lavalab-gen.py
parent32221a4e8fe36fd5c3c972039932cb53a25b1d5c (diff)
Made the database persistent
Until now, each docker-compose down will loose all data (jobs, devices, etc...). By creating a docker volume, the database will now be persistent other restart. Due to a risk of the lava package reseting the password, it is always reseted at start. This patch add also another volume for job output which are stored in the filesystem and not in database.
Diffstat (limited to 'lavalab-gen.py')
-rwxr-xr-xlavalab-gen.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/lavalab-gen.py b/lavalab-gen.py
index 35b10c7..e0c1c16 100755
--- a/lavalab-gen.py
+++ b/lavalab-gen.py
@@ -85,7 +85,7 @@ def main():
sys.exit(1)
masters = workers["masters"]
for master in masters:
- keywords_master = [ "name", "type", "host", "users", "tokens", "webadmin_https" ]
+ keywords_master = [ "name", "type", "host", "users", "tokens", "webadmin_https", "persistent_db" ]
for keyword in master:
if not keyword in keywords_master:
print("WARNING: unknown keyword %s" % keyword)
@@ -108,6 +108,16 @@ def main():
dockcomp["services"][name]["volumes"] = [ "/boot:/boot", "/lib/modules:/lib/modules" ]
dockcomp["services"][name]["build"] = {}
dockcomp["services"][name]["build"]["context"] = name
+ persistent_db = False
+ if "persistent_db" in master:
+ persistent_db = master["persistent_db"]
+ if persistent_db:
+ pg_volume_name = "pgdata_" + name
+ dockcomp["services"][name]["volumes"].append(pg_volume_name + ":/var/lib/postgresql")
+ dockcomp["services"][name]["volumes"].append("lava_job_output:/var/lib/lava-server/default/media/job-output/")
+ dockcomp["volumes"] = {}
+ dockcomp["volumes"][pg_volume_name] = {}
+ dockcomp["volumes"]["lava_job_output"] = {}
with open(dockcomposeymlpath, 'w') as f:
yaml.dump(dockcomp, f)