nodes view filter now works with new status attribute
This commit is contained in:
@@ -111,7 +111,7 @@ def index():
|
|||||||
'unreported': 0,
|
'unreported': 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
for node in list(nodes):
|
for node in nodes:
|
||||||
if node.status == 'unreported':
|
if node.status == 'unreported':
|
||||||
stats['unreported'] += 1
|
stats['unreported'] += 1
|
||||||
elif node.status == 'changed':
|
elif node.status == 'changed':
|
||||||
@@ -144,27 +144,13 @@ def nodes():
|
|||||||
provide a search feature instead.
|
provide a search feature instead.
|
||||||
"""
|
"""
|
||||||
status_arg = request.args.get('status', '')
|
status_arg = request.args.get('status', '')
|
||||||
latest_events = puppetdb._query(
|
|
||||||
'event-counts',
|
|
||||||
query='["=", "latest-report?", true]',
|
|
||||||
summarize_by='certname')
|
|
||||||
nodes = []
|
nodes = []
|
||||||
for node in yield_or_stop(puppetdb.nodes()):
|
for node in yield_or_stop(puppetdb.nodes(with_status=True)):
|
||||||
# check if node name is contained in any of the
|
|
||||||
# event-counts (grouped by certname)
|
|
||||||
status = [
|
|
||||||
s for s in latest_events if
|
|
||||||
s['subject']['title'] == node.name]
|
|
||||||
if status:
|
|
||||||
node.status = status[0]
|
|
||||||
else:
|
|
||||||
node.status = {}
|
|
||||||
if status_arg:
|
if status_arg:
|
||||||
if node.status.has_key(status_arg) and node.status[status_arg]:
|
if node.status == status_arg:
|
||||||
nodes.append(node)
|
nodes.append(node)
|
||||||
else:
|
else:
|
||||||
nodes.append(node)
|
nodes.append(node)
|
||||||
nodes = puppetdb.nodes(with_status=True)
|
|
||||||
return Response(stream_with_context(
|
return Response(stream_with_context(
|
||||||
stream_template('nodes.html', nodes=nodes)))
|
stream_template('nodes.html', nodes=nodes)))
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<div class="span4 stat">
|
<div class="span4 stat">
|
||||||
<a href="nodes?status=failures">
|
<a href="nodes?status=failed">
|
||||||
<h1 class="error">{{stats['failed']}}
|
<h1 class="error">{{stats['failed']}}
|
||||||
<small>{% if stats['failed']== 1 %} node {% else %} nodes {% endif %}</small>
|
<small>{% if stats['failed']== 1 %} node {% else %} nodes {% endif %}</small>
|
||||||
</h1>
|
</h1>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<span>with status failed</span>
|
<span>with status failed</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="span4 stat">
|
<div class="span4 stat">
|
||||||
<a href="nodes?status=successes">
|
<a href="nodes?status=changed">
|
||||||
<h1 class="success">{{stats['changed']}}
|
<h1 class="success">{{stats['changed']}}
|
||||||
<small>{% if stats['changed']== 1 %} node {% else %} nodes {% endif %}</small>
|
<small>{% if stats['changed']== 1 %} node {% else %} nodes {% endif %}</small>
|
||||||
</h1>
|
</h1>
|
||||||
@@ -21,9 +21,11 @@
|
|||||||
<span>with status changed</span>
|
<span>with status changed</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="span4 stat">
|
<div class="span4 stat">
|
||||||
<h1 class="noop">{{ stats['unreported'] }}
|
<a href="nodes?status=unreported">
|
||||||
<small>{% if stats['unreported']== 1 %} node {% else %} nodes {% endif %}</small>
|
<h1 class="noop">{{ stats['unreported'] }}
|
||||||
</h1>
|
<small>{% if stats['unreported']== 1 %} node {% else %} nodes {% endif %}</small>
|
||||||
|
</h1>
|
||||||
|
</a>
|
||||||
<span>
|
<span>
|
||||||
unreported in the last {{ config.UNRESPONSIVE_HOURS }} hours
|
unreported in the last {{ config.UNRESPONSIVE_HOURS }} hours
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user