Improve deployment page
Use num_nodes attribute of overcloud.counts to determine number of nodes associated with each role on the overcloud overview page. Also, improve the deployment template to show accurate information about number of nodes currently deployed, deploying, waiting for deployment, and in error state. Change-Id: I8ce533d6f7229af551be3a42a0adca8c54909e13 Closes-bug: #1288193
This commit is contained in:
parent
ace9b39b96
commit
7d54c81eb2
|
@ -12,7 +12,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ungettext_lazy
|
||||
|
||||
from horizon import tabs
|
||||
|
||||
|
@ -22,32 +21,54 @@ from tuskar_ui import utils
|
|||
|
||||
|
||||
def _get_role_data(overcloud, role):
|
||||
"""Gathers data about a single deployment role from the related Overcloud
|
||||
and OvercloudRole objects, and presents it in the form convenient for use
|
||||
from the template.
|
||||
|
||||
:param overcloud: Overcloud object
|
||||
:type overcloud: tuskar_ui.api.Overcloud
|
||||
:param role: Role object
|
||||
:type role: tuskar_ui.api.OvercloudRole
|
||||
:return: dict with information about the role, to be used by template
|
||||
:rtype: dict
|
||||
"""
|
||||
resources = overcloud.resources(role, with_joins=True)
|
||||
nodes = [r.node for r in resources]
|
||||
node_count = len(nodes)
|
||||
counts = getattr(overcloud, 'counts', [])
|
||||
|
||||
for c in counts:
|
||||
if c['overcloud_role_id'] == role.id:
|
||||
node_count = c['num_nodes']
|
||||
break
|
||||
else:
|
||||
node_count = 0
|
||||
|
||||
data = {
|
||||
'role': role,
|
||||
'name': role.name,
|
||||
'node_count': node_count,
|
||||
'total_node_count': node_count,
|
||||
}
|
||||
deployed_node_count = 0
|
||||
deploying_node_count = 0
|
||||
error_node_count = 0
|
||||
waiting_node_count = node_count
|
||||
|
||||
if nodes:
|
||||
running_node_count = sum(1 for node in nodes
|
||||
if node.instance.status == 'ACTIVE')
|
||||
deployed_node_count = sum(1 for node in nodes
|
||||
if node.instance.status == 'ACTIVE')
|
||||
deploying_node_count = sum(1 for node in nodes
|
||||
if node.instance.status == 'BUILD')
|
||||
error_node_count = sum(1 for node in nodes
|
||||
if node.instance.status == 'ERROR')
|
||||
deploying_node_count = (node_count - error_node_count -
|
||||
running_node_count)
|
||||
data.update({
|
||||
'running_node_count': running_node_count,
|
||||
'error_node_count': error_node_count,
|
||||
'error_node_message': ungettext_lazy("node is down",
|
||||
"nodes are down",
|
||||
error_node_count),
|
||||
'deploying_node_count': deploying_node_count,
|
||||
'deploying_node_message': ungettext_lazy("node is deploying",
|
||||
"nodes are deploying",
|
||||
deploying_node_count),
|
||||
})
|
||||
waiting_node_count = (node_count - deployed_node_count -
|
||||
deploying_node_count - error_node_count)
|
||||
|
||||
data.update({
|
||||
'deployed_node_count': deployed_node_count,
|
||||
'deploying_node_count': deploying_node_count,
|
||||
'waiting_node_count': waiting_node_count,
|
||||
'error_node_count': error_node_count,
|
||||
})
|
||||
# TODO(rdopieralski) get this from ceilometer
|
||||
# data['capacity'] = 20
|
||||
return data
|
||||
|
@ -63,8 +84,8 @@ class OverviewTab(tabs.Tab):
|
|||
overcloud = self.tab_group.kwargs['overcloud']
|
||||
roles = api.OvercloudRole.list(request)
|
||||
role_data = [_get_role_data(overcloud, role) for role in roles]
|
||||
total = sum(d['node_count'] for d in role_data)
|
||||
progress = 100 * sum(d.get('running_node_count', 0)
|
||||
total = sum(d['total_node_count'] for d in role_data)
|
||||
progress = 100 * sum(d.get('deployed_node_count', 0)
|
||||
for d in role_data) // (total or 1)
|
||||
|
||||
events = overcloud.stack_events
|
||||
|
|
|
@ -120,32 +120,41 @@
|
|||
<tr>
|
||||
<td><a
|
||||
href="{% url 'horizon:infrastructure:overcloud:role' overcloud.id role.role.id %}"
|
||||
>{{ role.name }} <span class="badge">({{ role.node_count }})</span></a>
|
||||
</td><td>
|
||||
{% if role.deploying_node_count %}
|
||||
<div class="text-warning">
|
||||
<i class="icon-cog"></i>
|
||||
{{ role.deploying_node_count }} / {{ role.node_count }}
|
||||
{{ role.deploying_node_message }}
|
||||
</div>
|
||||
{% elif role.error_node_count %}
|
||||
<div class="text-error">
|
||||
<i class="icon-warning"></i>
|
||||
{{ role.error_node_count }} / {{ role.node_count }}
|
||||
{{ role.error_node_message }}
|
||||
</div>
|
||||
{% elif role.node_count %}
|
||||
<div class="text-success">
|
||||
<i class="icon-ok"></i>
|
||||
{% trans "All nodes run correctly" %}
|
||||
</div>
|
||||
{% else %}
|
||||
>{{ role.name }} <span class="badge">({{ role.total_node_count }})</span></a>
|
||||
</td>
|
||||
<td>
|
||||
{% if not role.total_node_count %}
|
||||
<div class="muted">
|
||||
<i class="icon-minus"></i>
|
||||
{% trans "No nodes" %}
|
||||
{% trans "No node" %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% if role.error_node_count %}
|
||||
<div class="text-error">
|
||||
<i class="icon-exclamation-sign"></i>
|
||||
{% elif role.deploying_node_count or role.waiting_node_count %}
|
||||
<div class="text-warning">
|
||||
<i class="icon-cog"></i>
|
||||
{% else %}
|
||||
<div class="text-success">
|
||||
<i class="icon-ok"></i>
|
||||
{% endif %}
|
||||
{% if role.total_node_count == role.deployed_node_count %}
|
||||
{% trans "All nodes are running" %}
|
||||
{% else %}
|
||||
{{ role.deployed_node_count }} {% trans "deployed" %} /
|
||||
{{ role.deploying_node_count }} {% trans "deploying" %} /
|
||||
{{ role.waiting_node_count }} {% trans "waiting" %}
|
||||
{% if role.error_node_count %}
|
||||
<span style="color: red">
|
||||
/ {{ role.error_node_count }} {% trans "error" %}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</td><td>
|
||||
</td>
|
||||
<td>
|
||||
{% if role.capacity %}
|
||||
<div class="row-fluid">
|
||||
<div class="span6"><p>{{ role.capacity }}%</p></div>
|
||||
|
@ -165,7 +174,7 @@
|
|||
<div class="span4">
|
||||
<div class="widget">
|
||||
<h2>{% trans "Deployment Role Distribution" %}</h2>
|
||||
<div class="d3_pie_chart_distribution pull-left" data-used="{% for role in roles %}{{ role.name }}={{ role.node_count }}{% if not forloop.last %}|{% endif %}{% endfor %}"></div>
|
||||
<div class="d3_pie_chart_distribution pull-left" data-used='{% for role in roles %}{{ role.name }}={{ role.deployed_node_count|default:"0" }}{% if not forloop.last %}|{% endif %}{% endfor %}'></div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<div class="widget">
|
||||
|
|
Loading…
Reference in New Issue