Only show charts for provisioned nodes

Only attempt to access metering data when there nodes
which are either provisioned or provisioning.

Also, do not fail when trying to access flavor which has no
associated role.

Change-Id: I2b3608702742524db36182f3bada106c04442405
This commit is contained in:
Ana Krivokapic 2015-04-10 14:51:33 +02:00
parent 761e79dae0
commit 66ff1a5f78
3 changed files with 8 additions and 3 deletions

View File

@ -195,7 +195,7 @@ class FlavorsTest(test.BaseAdminViewTests):
self.assertEqual(get_mock.call_count, 1)
self.assertEqual(plan_mock.call_count, 2)
self.assertEqual(roles_mock.call_count, 1)
self.assertEqual(role_flavor_mock.call_count, 4)
self.assertEqual(role_flavor_mock.call_count, 8)
self.assertTemplateUsed(res, 'infrastructure/flavors/details.html')
def test_details(self):
@ -224,7 +224,7 @@ class FlavorsTest(test.BaseAdminViewTests):
self.assertEqual(flavor_mock.call_count, 1)
self.assertEqual(plan_mock.call_count, 2)
self.assertEqual(roles_mock.call_count, 1)
self.assertEqual(role_flavor_mock.call_count, 4)
self.assertEqual(role_flavor_mock.call_count, 8)
self.assertEqual(stack_mock.call_count, 1)
self.assertEqual(count_mock.call_count, 4)
self.assertTemplateUsed(res, 'infrastructure/flavors/details.html')

View File

@ -99,4 +99,5 @@ class DetailView(horizon.tables.DataTableView):
plan = api.tuskar.Plan.get_the_plan(self.request)
return [role for role in api.tuskar.Role.list(self.request)
if role.flavor(plan).id == flavor_id]
if role.flavor(plan)
and role.flavor(plan).id == flavor_id]

View File

@ -88,11 +88,15 @@
</div>
</div>
<div>
{% if nodes_provisioned_count or nodes_provisioning_count %}
{% url 'horizon:infrastructure:nodes:nodes_performance' as node_perf_url %}
{% include "infrastructure/_performance_chart_box.html" with meter_conf=meter_conf node_perf_url=node_perf_url col_size=2 %}
{% endif %}
</div>
</div>
{% if nodes_provisioned_count or nodes_provisioning_count %}
{% include "infrastructure/_top_5_box.html" %}
{% endif %}
{% if nodes_on_discovery_count or nodes_discovered_count or nodes_discovery_failed_count %}
<h3>{% trans "Nodes Discovery" %}</h3>
<hr>