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