change some argument name in docklet.conf.template
This commit is contained in:
parent
acbe31325a
commit
77ec586618
|
@ -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=""
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<br/>
|
||||
<div class="row">
|
||||
<div class="form-group"><label class="col-sm-2 control-label">Image Choose</label>
|
||||
<div class="col-sm-10">
|
||||
|
@ -91,6 +92,14 @@
|
|||
</div>
|
||||
|
||||
<div class="hr-line-dashed"></div>
|
||||
<br/>
|
||||
<div class="row">
|
||||
<div class="form-group"><label class="col-sm-2 control-label">Configure Setting</label>
|
||||
<div class="col-sm-8">CPU<input type="text" class="form-control" name="clusterName" id="clusterName"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<br/>
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-4 col-sm-offset-2">
|
||||
|
|
Loading…
Reference in New Issue