Merge pull request #285 from FirmlyReality/master
Fix a bug of port control & a bug of update_v0.3.2.py
This commit is contained in:
commit
dfa1512296
|
@ -523,7 +523,7 @@ def user_quotainfo_monitor(user, beans, form, issue):
|
||||||
elif issue == 'net_stats':
|
elif issue == 'net_stats':
|
||||||
logger.info("handle request: monitor/user/net_stats/")
|
logger.info("handle request: monitor/user/net_stats/")
|
||||||
res = G_historymgr.get_user_net_stats(user)
|
res = G_historymgr.get_user_net_stats(user)
|
||||||
return json.dumps({'success':'true', 'net_stats':res})
|
return json.dumps({'success':'true', 'net_stats':res})
|
||||||
else:
|
else:
|
||||||
return json.dumps({'success':'false', 'message':"Unspported Method!"})
|
return json.dumps({'success':'false', 'message':"Unspported Method!"})
|
||||||
|
|
||||||
|
@ -768,6 +768,8 @@ if __name__ == '__main__':
|
||||||
if etcdclient.isdir("_lock")[0]:
|
if etcdclient.isdir("_lock")[0]:
|
||||||
etcdclient.deldir("_lock")
|
etcdclient.deldir("_lock")
|
||||||
|
|
||||||
|
#init portcontrol
|
||||||
|
portcontrol.init_new()
|
||||||
|
|
||||||
clusternet = env.getenv("CLUSTER_NET")
|
clusternet = env.getenv("CLUSTER_NET")
|
||||||
logger.info("using CLUSTER_NET %s" % clusternet)
|
logger.info("using CLUSTER_NET %s" % clusternet)
|
||||||
|
@ -786,9 +788,6 @@ if __name__ == '__main__':
|
||||||
G_imagemgr = imagemgr.ImageMgr()
|
G_imagemgr = imagemgr.ImageMgr()
|
||||||
logger.info("imagemgr started")
|
logger.info("imagemgr started")
|
||||||
|
|
||||||
#init portcontrol
|
|
||||||
portcontrol.init_new()
|
|
||||||
|
|
||||||
logger.info("startting to listen on: ")
|
logger.info("startting to listen on: ")
|
||||||
masterip = env.getenv('MASTER_IP')
|
masterip = env.getenv('MASTER_IP')
|
||||||
logger.info("using MASTER_IP %s", masterip)
|
logger.info("using MASTER_IP %s", masterip)
|
||||||
|
|
|
@ -1,10 +1,19 @@
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
def isexist(quotas, key):
|
||||||
|
flag = False
|
||||||
|
for quota in quotas:
|
||||||
|
if quota['name'] == key:
|
||||||
|
flag = True
|
||||||
|
return flag
|
||||||
|
return flag
|
||||||
|
|
||||||
fspath = '/opt/docklet'
|
fspath = '/opt/docklet'
|
||||||
groupfile = open(fspath+"/global/sys/quota",'r')
|
groupfile = open(fspath+"/global/sys/quota",'r')
|
||||||
groups = json.loads(groupfile.read())
|
groups = json.loads(groupfile.read())
|
||||||
groupfile.close()
|
groupfile.close()
|
||||||
for group in groups:
|
for group in groups:
|
||||||
|
group['quotas']['portmapping'] = 8
|
||||||
group['quotas']['input_rate_limit'] = 10000
|
group['quotas']['input_rate_limit'] = 10000
|
||||||
group['quotas']['output_rate_limit'] = 10000
|
group['quotas']['output_rate_limit'] = 10000
|
||||||
groupfile = open(fspath+"/global/sys/quota",'w')
|
groupfile = open(fspath+"/global/sys/quota",'w')
|
||||||
|
@ -14,8 +23,13 @@ groupfile.close()
|
||||||
quotafile = open(fspath+"/global/sys/quotainfo",'r')
|
quotafile = open(fspath+"/global/sys/quotainfo",'r')
|
||||||
quotas = json.loads(quotafile.read())
|
quotas = json.loads(quotafile.read())
|
||||||
quotafile.close()
|
quotafile.close()
|
||||||
quotas['quotainfo'].append({'name':'input_rate_limit', 'hint':'the ingress speed of the network, number of kbps. 0 means the rate are unlimited.'})
|
|
||||||
quotas['quotainfo'].append({'name':'output_rate_limit', 'hint':'the egress speed of the network, number of kbps. 0 means the rate are unlimited.'})
|
if not isexist(quotas['quotainfo'], 'portmapping'):
|
||||||
|
quotas['quotainfo'].append({'name':'portmapping', 'hint':'how many ports the user can map, e.g. 8'})
|
||||||
|
if not isexist(quotas['quotainfo'], 'input_rate_limit'):
|
||||||
|
quotas['quotainfo'].append({'name':'input_rate_limit', 'hint':'the ingress speed of the network, number of kbps. 0 means the rate are unlimited.'})
|
||||||
|
if not isexist(quotas['quotainfo'], 'output_rate_limit'):
|
||||||
|
quotas['quotainfo'].append({'name':'output_rate_limit', 'hint':'the egress speed of the network, number of kbps. 0 means the rate are unlimited.'})
|
||||||
quotafile = open(fspath+"/global/sys/quotainfo",'w')
|
quotafile = open(fspath+"/global/sys/quotainfo",'w')
|
||||||
quotafile.write(json.dumps(quotas))
|
quotafile.write(json.dumps(quotas))
|
||||||
quotafile.close()
|
quotafile.close()
|
||||||
|
|
Loading…
Reference in New Issue