summaryrefslogtreecommitdiffstats
path: root/lavalab-gen.py
diff options
context:
space:
mode:
authorkhilman <khilman@users.noreply.github.com>2018-10-18 10:41:32 +0200
committerGitHub <noreply@github.com>2018-10-18 10:41:32 +0200
commit444653525a07faeee32eab0c07ec972ed6fe8967 (patch)
treeacb42f5c455385dcac78d82e7ece15da57622405 /lavalab-gen.py
parent24fb00544ba3191216876112d3bad8a742812ed6 (diff)
parent135f1dca856775d0d365c0c1045a7add8626da01 (diff)
Merge pull request #53 from montjoie/board_for_user
Permit to give board to user
Diffstat (limited to 'lavalab-gen.py')
-rwxr-xr-xlavalab-gen.py36
1 files changed, 34 insertions, 2 deletions
diff --git a/lavalab-gen.py b/lavalab-gen.py
index ce24e2d..9af872b 100755
--- a/lavalab-gen.py
+++ b/lavalab-gen.py
@@ -90,7 +90,7 @@ def main():
else:
masters = workers["masters"]
for master in masters:
- keywords_master = [ "name", "type", "host", "users", "tokens", "webadmin_https", "persistent_db", "zmq_auth", "zmq_auth_key", "zmq_auth_key_secret", "http_fqdn" ]
+ keywords_master = [ "name", "type", "host", "users", "groups", "tokens", "webadmin_https", "persistent_db", "zmq_auth", "zmq_auth_key", "zmq_auth_key_secret", "http_fqdn" ]
for keyword in master:
if not keyword in keywords_master:
print("WARNING: unknown keyword %s" % keyword)
@@ -131,6 +131,8 @@ def main():
# handle users / tokens
userdir = "%s/users" % workerdir
os.mkdir(userdir)
+ groupdir = "%s/groups" % workerdir
+ os.mkdir(groupdir)
worker = master
webadmin_https = False
if "webadmin_https" in worker:
@@ -163,7 +165,7 @@ def main():
need_zmq_auth_gen = True
if "users" in worker:
for user in worker["users"]:
- keywords_users = [ "name", "staff", "superuser", "password", "token", "email" ]
+ keywords_users = [ "name", "staff", "superuser", "password", "token", "email", "groups" ]
for keyword in user:
if not keyword in keywords_users:
print("WARNING: unknown keyword %s" % keyword)
@@ -188,6 +190,25 @@ def main():
if value is True:
ftok.write("SUPERUSER=1\n")
ftok.close()
+ if "groups" in user:
+ for group in user["groups"]:
+ groupname = group["name"]
+ print("\tAdd user %s to %s" % (username, groupname))
+ fgrp_userlist = open("%s/%s.group.list" % (groupdir, groupname), "a")
+ fgrp_userlist.write("%s\n" % username)
+ fgrp_userlist.close()
+ if "groups" in worker:
+ for group in worker["groups"]:
+ groupname = group["name"]
+ print("\tAdding group %s" % groupname)
+ fgrp = open("%s/%s.group" % (groupdir, groupname), "w")
+ fgrp.write("GROUPNAME=%s\n" % groupname)
+ submitter = False
+ if "submitter" in group:
+ submitter = group["submitter"]
+ if submitter:
+ fgrp.write("SUBMIT=1\n")
+ fgrp.close()
tokendir = "%s/tokens" % workerdir
os.mkdir(tokendir)
if "tokens" in worker:
@@ -465,6 +486,17 @@ def main():
for tag in board["tags"]:
ftag.write("%s\n" % tag)
ftag.close()
+ if "user" in board:
+ deviceinfo = open("%s/deviceinfo/%s" % (workerdir, board_name), 'w')
+ deviceinfo.write("DEVICE_USER=%s\n" % board["user"])
+ deviceinfo.close()
+ if "group" in board:
+ if "user" in board:
+ print("user and group are exclusive")
+ sys.exit(1)
+ deviceinfo = open("%s/deviceinfo/%s" % (workerdir, board_name), 'w')
+ deviceinfo.write("DEVICE_GROUP=%s\n" % board["group"])
+ deviceinfo.close()
if "custom_option" in board:
for coption in board["custom_option"]:
device_line += "{%% %s %%}\n" % coption