summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorImre Farkas <ifarkas@redhat.com>2013-07-29 13:55:39 +0200
committerTomas Sedovic <tomas@sedovic.cz>2013-08-01 16:18:58 +0200
commitabdae9c3286a5b0c3c78cbd728f4e7a240bae5c8 (patch)
tree2dff2de48bf1663cb508aca27ff931234d7d328f
parentb7863774b7b0ac8398525ae9da4bd06f328932eb (diff)
downloadtuskar-ui-abdae9c3286a5b0c3c78cbd728f4e7a240bae5c8.tar.gz
Disable charts on resource class detail page without a provisioned rack
Change-Id: I5a38474ac6cd8e8198b8f9c7ce6f32079d1ff29b
-rw-r--r--openstack_dashboard/api/tuskar.py4
-rw-r--r--openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/_detail_overview.html34
-rw-r--r--openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/detail.html7
3 files changed, 42 insertions, 3 deletions
diff --git a/openstack_dashboard/api/tuskar.py b/openstack_dashboard/api/tuskar.py
index 8f0e6e89..db2ae0e1 100644
--- a/openstack_dashboard/api/tuskar.py
+++ b/openstack_dashboard/api/tuskar.py
@@ -708,6 +708,10 @@ class ResourceClass(StringIdAPIResourceWrapper):
return [rack for rack in self.list_racks if (rack.alerts +
rack.aggregated_alerts)]
+ @property
+ def has_provisioned_rack(self):
+ return any([rack.is_provisioned for rack in self.list_racks])
+
class FlavorTemplate(StringIdAPIResourceWrapper):
"""Wrapper for the Flavor object returned by the
diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/_detail_overview.html b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/_detail_overview.html
index 3e1b0e8d..8916e47e 100644
--- a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/_detail_overview.html
+++ b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/_detail_overview.html
@@ -36,6 +36,7 @@
<table class="capacities">
{% for capacity in resource_class.capacities %}
<tr>
+ {% if resource_class.has_provisioned_rack %}
<td class="capacity_label">{{ capacity.name }}:</td>
<td>
<div id="{{ capacity.name }}_capacity_usage"
@@ -49,6 +50,15 @@
<td>
<a href="#" data-chart-type="modal_line_chart" data-url="/infrastructure/resource_management/racks/usage_data" data-series="{{ capacity.name }}">{{ capacity.usage|default:_(" - ") }}/{{ capacity.value|default:_(" - ") }} {{ capacity.unit }}</a>
</td>
+ {% else %}
+ <td>
+ <div id="{{ capacity.name }}_capacity_usage"
+ class="capacity_bar"
+ data-chart-type="capacity_bar_chart">
+ </div>
+ </td>
+ <td></td>
+ {% endif %}
</tr>
{% endfor %}
</table>
@@ -62,12 +72,17 @@
<div class="span6">
<h4>{% trans "Capacity Usage" %}</h4>
<hr class="header_rule">
+ {% if resource_class.has_provisioned_rack %}
<div data-chart-type="line_chart" data-url="/infrastructure/resource_management/racks/usage_data" data-series="cpu,ram,storage,network"></div>
+ {% else %}
+ <p>{% trans "No data available yet." %}</p>
+ {% endif %}
</div>
<div class="span6 alerts">
<h4>{% trans "Active Alerts" %}</h4>
<hr class="header_rule">
+ {% if resource_class.has_provisioned_rack %}
<ul>
{% for rack in resource_class.aggregated_alerts %}
<li>
@@ -76,6 +91,9 @@
</li>
{% endfor %}
</ul>
+ {% else %}
+ <p>{% trans "No data available yet." %}</p>
+ {% endif %}
</div>
</div>
@@ -83,6 +101,7 @@
<div class="span6">
<h4>{% trans "Summary of Instances and Usage" %}</h4>
<hr class="header_rule">
+ {% if resource_class.has_provisioned_rack %}
<!--
<dl>
{% for flavor in resource_class.running_virtual_machines %}
@@ -93,8 +112,10 @@
-->
<div class="clear"></div>
- <div><strong>{{ resource_class.total_instances }}</strong> instances
- <strong>{{resource_class.remaining_capacity}}%</strong> capacity remaining</div>
+ <div>
+ <strong>{{ resource_class.total_instances }}</strong> instances
+ <strong>{{resource_class.remaining_capacity}}%</strong> capacity remaining
+ </div>
<div class="flavor_usage_bar"
data-popup-free='{{resource_class|remaining_capacity_by_flavors}}'
data-single-bar-orientation="horizontal"
@@ -146,7 +167,9 @@
{% endfor %}
</tr>
</table>
-
+ {% else %}
+ <p>{% trans "No data available yet." %}</p>
+ {% endif %}
</div>
<div class="span6">
@@ -164,6 +187,7 @@
<h4>Rack health</h4>
+ {% if resource_class.has_provisioned_rack %}
<ul class="nav nav-tabs"
data-circles-chart-command="change_url"
data-receiver=".rack_health_chart">
@@ -207,5 +231,9 @@
data-time="now"
data-size="22">
</div>
+ {% else %}
+ <hr class="header_rule">
+ <p>{% trans "No data available yet." %}</p>
+ {% endif %}
</div>
</div>
diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/detail.html b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/detail.html
index ea39d5df..0c6ecaef 100644
--- a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/detail.html
+++ b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/detail.html
@@ -43,12 +43,19 @@
<tr>
<td class="capacity_label">{% trans "Usage" %}:</td>
<td>
+ {% if resource_class.has_provisioned_rack %}
<div id="resource_class_usage"
class="capacity_bar"
data-chart-type="capacity_bar_chart"
data-capacity-limit="{{ resource_class.vm_capacity.value }}"
data-capacity-used="{{ resource_class.vm_capacity.usage }}"
</div>
+ {% else %}
+ <div id="resource_class_usage"
+ class="capacity_bar"
+ data-chart-type="capacity_bar_chart">
+ </div>
+ {% endif %}
</td>
</tr>
</table>