Add a table in status page to display user's quotas.

This commit is contained in:
zhuyj17 2016-04-14 15:52:44 +08:00
parent 8c20111d20
commit 9bdd012bd0
3 changed files with 53 additions and 1 deletions

View File

@ -346,6 +346,10 @@ class DockletHttpHandler(http.server.BaseHTTPRequestHandler):
res['basic_info'] = fetcher.get_basic_info(cmds[2])
self.response(200, {'success':'true', 'monitor':res})
elif cmds[1] == 'user':
if cmds[2] == 'quotainfo':
user_info = G_usermgr.selfQuery(cur_user = cur_user)
quotainfo = user_info['data']['groupinfo']
self.response(200, {'success':'true', 'quotainfo':quotainfo})
if not user == 'root':
self.response(400, {'success':'false', 'message':'Root Required'})
if cmds[3] == 'clustercnt':

View File

@ -16,6 +16,50 @@
{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-12">
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">Your Quotas</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
</div>
</div>
<div class="box-body table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>CPU</th>
<th>Memory</th>
<th>Disk</th>
<th>Network</th>
<th>Image</th>
<th>Idletime</th>
</tr>
</thead>
<tbody>
<tr>
{% if quotainfo['cpu'] > 1 %}
<th>{{ quotainfo['cpu'] }} Cores</th>
{% else %}
<th>{{ quotainfo['cpu'] }} Core</th>
{% endif %}
<th>{{ quotainfo['memory'] }} MB</th>
<th>{{ quotainfo['disk'] }} MB</th>
<th>{{ quotainfo['network'] }} IP addresses</th>
<th>{{ quotainfo['image'] }}</th>
<th>{{ quotainfo['idletime'] }}</th>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
{% for cluster in clusters %}
<div class="row">
<div class="col-md-12">

View File

@ -13,6 +13,10 @@ class statusView(normalView):
}
result = dockletRequest.post('/cluster/list/', data)
clusters = result.get('clusters')
result = dockletRequest.post('/monitor/user/quotainfo/', data)
quotainfo = result.get('quotainfo')
quotainfo['cpu'] = int(int(quotainfo['cpu'])/100000)
print(quotainfo)
if (result):
containers = {}
for cluster in clusters:
@ -23,7 +27,7 @@ class statusView(normalView):
else:
self.error()
containers[cluster] = message
return self.render(self.template_path, clusters = clusters, containers = containers, user = session['username'])
return self.render(self.template_path, clusters = clusters, quotainfo = quotainfo, containers = containers, user = session['username'])
else:
self.error()