diff --git a/src/userManager.py b/src/userManager.py index 7b077a9..0b763ed 100755 --- a/src/userManager.py +++ b/src/userManager.py @@ -156,13 +156,13 @@ class userManager: groups.append({'name':'root', 'quotas':{ 'cpu':'4', 'disk':'2000', 'data':'100', 'memory':'2000', 'image':'10', 'idletime':'24', 'vnode':'8' }}) groups.append({'name':'admin', 'quotas':{'cpu':'4', 'disk':'2000', 'data':'100', 'memory':'2000', 'image':'10', 'idletime':'24', 'vnode':'8'}}) groups.append({'name':'primary', 'quotas':{'cpu':'4', 'disk':'2000', 'data':'100', 'memory':'2000', 'image':'10', 'idletime':'24', 'vnode':'8'}}) - groups.append({'name':'fundation', 'quotas':{'cpu':'4', 'disk':'2000', 'data':'100', 'memory':'2000', 'image':'10', 'idletime':'24', 'vnode':'8'}}) + groups.append({'name':'foundation', 'quotas':{'cpu':'4', 'disk':'2000', 'data':'100', 'memory':'2000', 'image':'10', 'idletime':'24', 'vnode':'8'}}) groupfile.write(json.dumps(groups)) groupfile.close() if not os.path.exists(fspath+"/global/sys/quotainfo"): quotafile = open(fspath+"/global/sys/quotainfo",'w') quotas = {} - quotas['default'] = 'fundation' + quotas['default'] = 'foundation' quotas['quotainfo'] = [] quotas['quotainfo'].append({'name':'cpu', 'hint':'the cpu quota, number of cores, e.g. 4'}) quotas['quotainfo'].append({'name':'memory', 'hint':'the memory quota, number of MB , e.g. 4000'}) diff --git a/tools/upgrade.py b/tools/upgrade.py index 393a62f..dbe5e7b 100755 --- a/tools/upgrade.py +++ b/tools/upgrade.py @@ -1,7 +1,8 @@ #!/usr/bin/python3 import os, json, sys - +sys.path.append("../src/") +from model import db, User fspath="/opt/docklet" def update_quotainfo(): @@ -13,7 +14,7 @@ def update_quotainfo(): quotafile.close() if type(quotas) is list: new_quotas = {} - new_quotas['default'] = 'fundation' + new_quotas['default'] = 'foundation' new_quotas['quotainfo'] = quotas quotas = new_quotas print("change the type of quotafile from list to dict") @@ -65,6 +66,31 @@ def update_quotainfo(): groupfile.close() +def name_error(): + quotafile = open(fspath+"/global/sys/quotainfo", 'r') + quotas = json.loads(quotafile.read()) + quotafile.close() + if quotas['default'] == 'fundation': + quotas['default'] = 'foundation' + quotafile = open(fspath+"/global/sys/quotainfo",'w') + quotafile.write(json.dumps(quotas)) + quotafile.close() + + groupfile = open(fspath+"/global/sys/quota", 'r') + groups = json.loads(groupfile.read()) + groupfile.close() + for group in groups: + if group['name'] == 'fundation': + group['name'] = 'foundation' + groupfile = open(fspath+"/global/sys/quota",'w') + groupfile.write(json.dumps(groups)) + groupfile.close() + + users = User.query.filter_by(user_group = 'fundation').all() + for user in users: + user.user_group = 'foundation' + db.session.commit() + def allquota(): try: @@ -125,4 +151,6 @@ def enable_gluster_quota(): if __name__ == '__main__': update_quotainfo() + if "fix-name-error" in sys.argv: + name_error() # enable_gluster_quota() diff --git a/web/templates/admin.html b/web/templates/admin.html index 501ec96..c82c765 100644 --- a/web/templates/admin.html +++ b/web/templates/admin.html @@ -153,7 +153,7 @@ {{ group['quotas'][quota['name']] }} {% endfor %} Edit  - {% if group['name'] in [ "root", "primary", "admin", "fundation" ] %} + {% if group['name'] in [ "root", "primary", "admin", "foundation" ] %} Delete  {% else %} Delete