Adding maintenance state to pie chart

Adding maintenance state to nodes overview page pie chart.

Change-Id: I398ac65f7cfefd9681ceac95af7da91c292d701c
This commit is contained in:
Ladislav Smola 2014-10-23 15:35:54 +02:00
parent cb0fd4282b
commit 4a8736cf07
2 changed files with 22 additions and 5 deletions

View File

@ -42,6 +42,22 @@ class OverviewTab(tabs.Tab):
nodes_provisioned = api.node.Node.list(request, associated=True)
nodes_free = api.node.Node.list(request, associated=False)
nodes_all_count = (utils.length(nodes_provisioned) +
utils.length(nodes_free))
nodes_provisioned_maintenance = list(utils.filter_items(
nodes_provisioned, maintenance=True))
nodes_provisioned_not_maintenance = list(
set(nodes_provisioned) - set(nodes_provisioned_maintenance))
nodes_free_maintenance = list(utils.filter_items(
nodes_free, maintenance=True))
nodes_free_not_maintenance = list(
set(nodes_free) - set(nodes_free_maintenance))
nodes_maintenance = (
nodes_provisioned_maintenance + nodes_free_maintenance)
nodes_provisioned_down = utils.filter_items(
nodes_provisioned, power_state__not_in=api.node.POWER_ON_STATES)
nodes_free_down = utils.filter_items(
@ -57,10 +73,11 @@ class OverviewTab(tabs.Tab):
'local_gb': local_gb,
'nodes_up_count': utils.length(nodes_up),
'nodes_down_count': utils.length(nodes_down),
'nodes_provisioned_count': utils.length(nodes_provisioned),
'nodes_free_count': utils.length(nodes_free),
'nodes_all_count': (utils.length(nodes_provisioned) +
utils.length(nodes_free))
'nodes_provisioned_count': utils.length(
nodes_provisioned_not_maintenance),
'nodes_free_count': utils.length(nodes_free_not_maintenance),
'nodes_maintenance_count': utils.length(nodes_maintenance),
'nodes_all_count': nodes_all_count
}
if api_base.is_service_enabled(self.request, 'metering'):

View File

@ -17,7 +17,7 @@
</div>
<div class="widget">
<h3>{% trans 'Nodes Status' %}</h3>
<div class="d3_pie_chart_distribution" data-used="Provisioned={{ nodes_provisioned_count }}|Free={{ nodes_free_count }}"></div>
<div class="d3_pie_chart_distribution" data-used="Provisioned={{ nodes_provisioned_count }}|Free={{ nodes_free_count }}|Maintenance={{ nodes_maintenance_count }}"></div>
</div>
<div class="widget">
<h3>{% trans 'Power Status' %}</h3>