Commit 746a5447 by Gabor Gutyan

Quota widget created

Quota widget added to dashboard indicating nova and cinder tenant usage and limit data.
parent fd8ddbfb
......@@ -585,7 +585,7 @@ footer a, footer a:hover, footer a:visited {
#dashboard-vm-list, #dashboard-node-list, #dashboard-group-list,
#dashboard-template-list, #dashboard-files-toplist, #dashboard-user-list,
#dashboard-vxlan-list {
#dashboard-vxlan-list, #dashboard-quota-list {
min-height: 200px;
}
......@@ -1193,6 +1193,33 @@ textarea[name="new_members"] {
}
}
#dashboard-quota-list{
.list-group-item {
display: flex;
}
.index-quota-list-name {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.index-quota-list-name {
width: 100%;
}
.index-quota-list-name .quota-label{
width:90px;
display:inline-block;
}
.index-quota-list-name .quota-percentage{
width:40px;
display:inline-block;
text-align:right;
}
}
#dashboard-user-list {
.list-group-item {
......
{% load i18n %}
{% load instance_tags %}
<div class="panel panel-default">
<div class="panel-heading">
<div class="pull-right toolbar">
<div class="btn-group">
</div>
<span class="btn btn-default btn-xs infobtn" data-container="body" title="{% trans "Report on used resources based on quota statistics." %}"><i class="fa fa-info-circle"></i></span>
</div>
<h3 class="no-margin">
<span class="visible-xs">
<i class="fa fa-desktop"></i>
{% trans "Quota" %}
</span>
<span class="hidden-xs">
<i class="fa fa-desktop"></i>
{% trans "Resources" %}
</span>
</h3>
</div>
<div class="list-group" id="vm-list-view">
<div id="dashboard-quota-list">
{% for metric, quotastats in quotas.items %}
<div class="list-group-item">
<span class="index-quota-list-name">
<span class="quota-label">
<i class="fa fa-{{ quotastats.icon }}" title="{{ metric }}"></i>
{{ metric }}
</span>
<progress style="width:50%;" title="{{ quotastats.usage }} / {{ quotastats.limit }} " max="{{ quotastats.limit }}" value="{{ quotastats.usage }}"></progress>
<span class="quota-percentage">
{% widthratio quotastats.usage quotastats.limit 100 %} %
</span>
</span>
</div>
{% empty %}
<div class="list-group-item list-group-item-last">
{% trans "You have no quota stats available." %}
</div>
<div id="empty-vm-help">
{% trans "Please try reloading." %}<br />
</div>
{% endfor %}
</div>
<div class="list-group-item list-group-footer">
<div class="row">
</div>
</div>
</div>
</div>
\ No newline at end of file
......@@ -52,6 +52,10 @@
{% include "dashboard/index-vxlans.html" %}
</div>
<div class="col-lg-4 col-sm-6">
{% include "dashboard/index-quota.html" %}
</div>
</div>
</div>
{% endblock %}
{% endblock %}
\ No newline at end of file
......@@ -44,6 +44,7 @@ class IndexView(LoginRequiredMixin, TemplateView):
instances = openstack_api.nova.server_list(self.request)[0] #TODO: flatten?
quotas = openstack_api.nova.tenant_quota_get(self.request, user.project_id)
# instances
favs = [f.instance for f in Favourite.objects.filter(user=user.id)]
fav_instances = [
......@@ -133,6 +134,40 @@ class IndexView(LoginRequiredMixin, TemplateView):
else:
context['no_store'] = True
# quotas widget
novaLimits = openstack_api.nova.tenant_absolute_limits(self.request, False, user.project_id)
cinderLimits = openstack_api.cinder.tenant_absolute_limits(self.request, user.project_id)
context.update({
'quotas': {
'RAM': {
'icon': 'tasks',
'usage': novaLimits["totalRAMUsed"],
'limit': novaLimits["maxTotalRAMSize"]
},
'Cores': {
'icon': 'desktop',
'usage': novaLimits["totalCoresUsed"],
'limit': novaLimits["maxTotalCores"]
},
'Float IPs': {
'icon': 'slack',
'usage': novaLimits["totalFloatingIpsUsed"],
'limit': novaLimits["maxTotalFloatingIps"]
},
'Instances': {
'icon': 'cubes',
'usage': novaLimits["totalInstancesUsed"],
'limit': novaLimits["maxTotalInstances"]
},
'Volumes': {
'icon': 'database',
'usage': cinderLimits["totalVolumesUsed"],
'limit': cinderLimits["maxTotalVolumes"]
},
}
})
return context
......@@ -161,4 +196,4 @@ class IndexView(LoginRequiredMixin, TemplateView):
# **kwargs)
# context['url'] = self.request.build_absolute_uri(
# reverse("dashboard.views.vm-list"))
# return context
# return context
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment