From 77ec5866188b638927a93c5eeda399bab720a09a Mon Sep 17 00:00:00 2001 From: zhongyh16 <15289788668@163.com> Date: Fri, 6 May 2016 18:00:49 +0800 Subject: [PATCH] change some argument name in docklet.conf.template --- conf/docklet.conf.template | 11 ++++++----- src/env.py | 8 ++++---- src/userManager.py | 11 +++++++---- tools/upgrade.py | 9 +++------ web/templates/addCluster.html | 9 +++++++++ 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/conf/docklet.conf.template b/conf/docklet.conf.template index a5f8727..589c155 100644 --- a/conf/docklet.conf.template +++ b/conf/docklet.conf.template @@ -135,10 +135,11 @@ # default: "" # ADMIN_EMAIL_ADDRESS="" -# GLUSTER_VOLUME_QUOTA : whether enable the quota of glusterfs volume or not +# DATA_QUOTA : whether enable the quota of data or not # default: "NO" -# GLUSTER_VOLUME_QUOTA="" +# DATA_QUOTA="" -# GLUSTER_VOLUME_NAME : the name of glusterfs volume -# default: "docklet-volume" -# GLUSTER_VOLUME_NAME="" +# DATA_QUOTA_CMD : the cmd to set the data quota, the argument of it should be directory name +# and the quota value. +# default: "gluster volume quota docklet-volume %s %s" +# DATA_QUOTA_CMD="" diff --git a/src/env.py b/src/env.py index 88273db..b7b55b6 100755 --- a/src/env.py +++ b/src/env.py @@ -50,9 +50,9 @@ def getenv(key): return os.environ.get("EMAIL_FROM_ADDRESS", "") elif key =="ADMIN_EMAIL_ADDRESS": return os.environ.get("ADMIN_EMAIL_ADDRESS", "") - elif key =="GLUSTER_VOLUME_QUOTA": - return os.environ.get("GLUSTER_VOLUME_QUOTA", "NO") - elif key =="GLUSTER_VOLUME_NAME": - return os.environ.get("GLUSTER_VOLUME_NAME", "docklet-volume") + elif key =="DATA_QUOTA": + return os.environ.get("DATA_QUOTA", "NO") + elif key =="DATA_QUOTA_CMD": + return os.environ.get("DATA_QUOTA_CMD", "gluster volume quota docklet-volume limit-usage %s %s") else: return os.environ[key] diff --git a/src/userManager.py b/src/userManager.py index f545982..7b077a9 100755 --- a/src/userManager.py +++ b/src/userManager.py @@ -27,8 +27,8 @@ email_from_address = env.getenv('EMAIL_FROM_ADDRESS') admin_email_address = env.getenv('ADMIN_EMAIL_ADDRESS') PAM = pam.pam() fspath = env.getenv('FS_PREFIX') -gluster_volume_quota = env.getenv('GLUSTER_VOLUME_QUOTA') -gluster_volume_name = env.getenv('GLUSTER_VOLUME_NAME') +data_quota = env.getenv('DATA_QUOTA') +data_quota_cmd = env.getenv('DATA_QUOTA_CMD') if (env.getenv('EXTERNAL_LOGIN').lower() == 'true'): @@ -311,16 +311,19 @@ class userManager: return user def set_nfs_quota_bygroup(self,groupname, quota): + if not data_quota == "YES": + return users = User.query.filter_by(user_group = groupname).all() for user in users: self.set_nfs_quota(user.username, quota) def set_nfs_quota(self, username, quota): - if not gluster_volume_quota == "YES": + if not data_quota == "YES": return nfspath = "/users/%s/data" % username try: - sys_run("gluster volume quota %s limit-usage %s %sGB" % (gluster_volume_name, nfspath, quota)) + cmd = data_quota_cmd % (nfspath,quota+"GB") + sys_run(cmd.strip('"')) except Exception as e: logger.error(e) diff --git a/tools/upgrade.py b/tools/upgrade.py index 6f5dcab..340585c 100755 --- a/tools/upgrade.py +++ b/tools/upgrade.py @@ -1,9 +1,6 @@ #!/usr/bin/python3 import os, json, sys -sys.path.append("../src") -from model import db, User -from lvmtool import * fspath="/opt/docklet" @@ -65,7 +62,7 @@ def enable_gluster_quota(): enable = False volume_name = "" for line in conf: - if line.startswith("GLUSTER_VOLUME_QUOTA"): + if line.startswith("DATA_QUOTA"): keyvalue = line.split("=") if len(keyvalue) < 2: continue @@ -75,7 +72,7 @@ def enable_gluster_quota(): enable = True break for line in conf: - if line.startswith("GLUSTER_VOLUME_NAME"): + if line.startswith("DATA_QUOTA_CMD"): keyvalue = line.split("=") if len(keyvalue) < 2: continue @@ -101,4 +98,4 @@ def enable_gluster_quota(): if __name__ == '__main__': update_quotainfo() - enable_gluster_quota() +# enable_gluster_quota() diff --git a/web/templates/addCluster.html b/web/templates/addCluster.html index 7221acf..93c66aa 100644 --- a/web/templates/addCluster.html +++ b/web/templates/addCluster.html @@ -43,6 +43,7 @@
+
@@ -91,6 +92,14 @@
+
+
+
+
CPU
+
+
+
+