Merge "Refactor last events"
This commit is contained in:
commit
f7a495786f
@ -110,20 +110,16 @@ class IndexView(horizon.forms.ModalFormView, StackMixin):
|
||||
success_url = reverse_lazy(INDEX_URL)
|
||||
|
||||
def get_progress_update(self, request, data):
|
||||
last_event = data.get('last_event')
|
||||
return {
|
||||
'progress': data.get('progress'),
|
||||
'last_event': {
|
||||
'event_time': last_event.event_time,
|
||||
'resource_name': last_event.resource_name,
|
||||
'resource_status': last_event.resource_status,
|
||||
} if last_event else None,
|
||||
'last_failed_events': [{
|
||||
'show_last_events': data.get('show_last_events'),
|
||||
'last_events_title': unicode(data.get('last_events_title')),
|
||||
'last_events': [{
|
||||
'event_time': event.event_time,
|
||||
'resource_name': event.resource_name,
|
||||
'resource_status': event.resource_status,
|
||||
'resource_status_reason': event.resource_status_reason,
|
||||
} for event in data.get('last_failed_events', [])],
|
||||
} for event in data.get('last_events', [])],
|
||||
'roles': [{
|
||||
'status': role.get('status', 'warning'),
|
||||
'finished': role.get('finished', False),
|
||||
@ -171,12 +167,19 @@ class IndexView(horizon.forms.ModalFormView, StackMixin):
|
||||
context['roles'] = roles
|
||||
|
||||
if stack:
|
||||
context['last_failed_events'] = [
|
||||
e for e in stack.events
|
||||
if 'FAILED' in e.resource_status][-3:]
|
||||
context['show_last_events'] = True
|
||||
failed_events = [e for e in stack.events
|
||||
if 'FAILED' in e.resource_status and
|
||||
'aborted' not in e.resource_status_reason][-3:]
|
||||
|
||||
if failed_events:
|
||||
context['last_events_title'] = _('Last failed events')
|
||||
context['last_events'] = failed_events
|
||||
else:
|
||||
context['last_events_title'] = _('Last event')
|
||||
context['last_events'] = [stack.events[0]]
|
||||
|
||||
if stack.is_deleting or stack.is_delete_failed:
|
||||
context['last_event'] = stack.events[0]
|
||||
# TODO(lsmola) since at this point we don't have total number
|
||||
# of nodes we will hack this around, till API can show this
|
||||
# information. So it will actually show progress like the total
|
||||
@ -200,7 +203,6 @@ class IndexView(horizon.forms.ModalFormView, StackMixin):
|
||||
context['progress'] = min(95, max(
|
||||
5, 100 * float(resources_count) / total_num_nodes_count))
|
||||
elif stack.is_deploying:
|
||||
context['last_event'] = stack.events[0]
|
||||
total = sum(d['total_node_count'] for d in roles)
|
||||
context['progress'] = min(95, max(
|
||||
5, 100 * sum(float(d.get('deployed_node_count', 0))
|
||||
@ -208,6 +210,8 @@ class IndexView(horizon.forms.ModalFormView, StackMixin):
|
||||
))
|
||||
else:
|
||||
# stack is active
|
||||
if not stack.is_failed:
|
||||
context['show_last_events'] = False
|
||||
context['progress'] = 100
|
||||
controller_role = plan.get_role_by_name("controller")
|
||||
context['admin_password'] = plan.parameter_value(
|
||||
|
@ -30,7 +30,7 @@ tuskar.deployment_progress = (function () {
|
||||
}
|
||||
var $bar = $('div.deployment-box div.progress div.progress-bar');
|
||||
$bar.css('width', '' + data.progress + '%');
|
||||
if (data.last_failed_events.length > 0 || data.last_event) {
|
||||
if (data.show_last_events) {
|
||||
$('div.deploy-last-events').html(module.events_template.render(data));
|
||||
} else {
|
||||
$('div.deploy-last-events').html('');
|
||||
|
@ -0,0 +1,18 @@
|
||||
{% if show_last_events %}
|
||||
<strong>{{ last_events_title }}</strong>
|
||||
<div>
|
||||
<dl>
|
||||
{% for event in last_events %}
|
||||
<dd>
|
||||
<time datetime="{{ event.event_time }}">{{ event.event_time }}</time>
|
||||
<br />
|
||||
{{ event.resource_name }} |
|
||||
{{ event.resource_status }} |
|
||||
{{ event.resource_status_reason }}
|
||||
</dd>
|
||||
<br />
|
||||
{% endfor %}
|
||||
</dl>
|
||||
</div>
|
||||
<p><a href="{% url 'horizon:infrastructure:history:index' %}">See full log</a></p>
|
||||
{% endif %}
|
@ -16,24 +16,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block deployment-info %}
|
||||
{% if last_failed_events %}
|
||||
<strong>{% trans "Last failed events:" %}</strong>
|
||||
{% for event in last_failed_events %}
|
||||
<div>
|
||||
<dl>
|
||||
<dt>{% trans "Timestamp" %}</dt>
|
||||
<dd><time datetime="{{ event.event_time }}">{{ event.event_time }}</time></dd>
|
||||
<dt>{% trans "Resource Name" %}</dt>
|
||||
<dd>{{ event.resource_name }}</dd>
|
||||
<dt>{% trans "Status" %}</dt>
|
||||
<dd>{{ event.resource_status }}</dd>
|
||||
<dt>{% trans "Reason" %}</dt>
|
||||
<dd>{{ event.resource_status_reason }}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<p><a href="{% url 'horizon:infrastructure:history:index' %}">See full log</a></p>
|
||||
{% include "infrastructure/overview/_last_events.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block deployment-buttons %}
|
||||
|
@ -28,36 +28,7 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="deploy-last-events">
|
||||
{% if last_failed_events %}
|
||||
<strong>{% trans "Last failed events:" %}</strong>
|
||||
{% for event in last_failed_events %}
|
||||
<div>
|
||||
<dl>
|
||||
<dt>{% trans "Timestamp" %}</dt>
|
||||
<dd><time datetime="{{ event.event_time }}">{{ event.event_time }}</time></dd>
|
||||
<dt>{% trans "Resource Name" %}</dt>
|
||||
<dd>{{ event.resource_name }}</dd>
|
||||
<dt>{% trans "Status" %}</dt>
|
||||
<dd>{{ event.resource_status }}</dd>
|
||||
<dt>{% trans "Reason" %}</dt>
|
||||
<dd>{{ event.resource_status_reason }}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% elif last_event %}
|
||||
<div>
|
||||
<dl>
|
||||
<dt>{% trans "Last Update" %}</dt>
|
||||
<dd>
|
||||
<time datetime="{{ last_event.event_time }}">{{ last_event.event_time }}</time>
|
||||
<br />
|
||||
{{ last_event.resource_name }}
|
||||
{{ last_event.resource_status }}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
{% endif %}
|
||||
<p><a href="{% url 'horizon:infrastructure:history:index' %}">See full log</a></p>
|
||||
{% include "infrastructure/overview/_last_events.html" %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@ -74,34 +45,23 @@
|
||||
|
||||
{% block templates %}
|
||||
<script type="text/html" id="events-template">{% spaceless %}{% jstemplate %}
|
||||
[[#last_failed_events]]
|
||||
<strong>{% trans "Last failed events:" %}</strong>
|
||||
[[#show_last_events]]
|
||||
<strong>[[ last_events_title ]]</strong>
|
||||
<div>
|
||||
<dl>
|
||||
<dt>{% trans "Timestamp" %}</dt>
|
||||
<dd><time datetime="[[ event_time ]]">[[ event_time ]]</time></dd>
|
||||
<dt>{% trans "Resource Name" %}</dt>
|
||||
<dd>[[ resource_name ]]</dd>
|
||||
<dt>{% trans "Status" %}</dt>
|
||||
<dd>[[ resource_status ]]</dd>
|
||||
<dt>{% trans "Reason" %}</dt>
|
||||
<dd>[[ resource_status_reason ]]</dd>
|
||||
</dl>
|
||||
</div>
|
||||
[[/last_failed_events]]
|
||||
[[#last_event]]
|
||||
<div>
|
||||
<dl>
|
||||
<dt>{% trans "Last Update" %}</dt>
|
||||
[[#last_events]]
|
||||
<dd>
|
||||
<time datetime="[[ event_time ]]">[[ event_time ]]</time>
|
||||
<br />
|
||||
[[ resource_name ]]
|
||||
[[ resource_status ]]
|
||||
[[ resource_name ]] |
|
||||
[[ resource_status ]] |
|
||||
[[ resource_status_reason ]]
|
||||
</dd>
|
||||
<br />
|
||||
[[/last_events]]
|
||||
</dl>
|
||||
</div>
|
||||
[[/last_event]]
|
||||
[[/show_last_events]]
|
||||
<p><a href="{% url 'horizon:infrastructure:history:index' %}">See full log</a></p>
|
||||
{% endjstemplate %}{% endspaceless %}</script>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user