Merge pull request #36 from digitalmediacenter/fix-noreport
Fix for latest report if there is no report available
This commit is contained in:
@@ -203,11 +203,15 @@ def report_latest(node_name):
|
||||
as long as PuppetDB can't filter reports for latest-report? field. This
|
||||
feature has been requested: http://projects.puppetlabs.com/issues/21554
|
||||
"""
|
||||
# TODO: use limit parameter in _query to get just one report
|
||||
node = get_or_abort(puppetdb.node, node_name)
|
||||
reports = ten_reports(node.reports())
|
||||
report = list(yield_or_stop(reports))[0]
|
||||
return redirect(url_for('report', node=node_name, report_id=report))
|
||||
reports = get_or_abort(puppetdb._query, 'reports',
|
||||
query='["=","certname","{0}"]'.format(node_name),
|
||||
limit=1)
|
||||
if len(reports) > 0:
|
||||
report = reports[0]['hash']
|
||||
return redirect(url_for('report', node=node_name, report_id=report))
|
||||
else:
|
||||
abort(404)
|
||||
|
||||
|
||||
@app.route('/report/<node>/<report_id>')
|
||||
|
||||
@@ -99,3 +99,6 @@ div[id^='message-event'] {
|
||||
background-color: rgb(231, 76, 60);
|
||||
background-color: rgb(129, 145, 146);
|
||||
}
|
||||
.btn-lastreport {
|
||||
width:100px;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,13 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
<td><a href="{{url_for('node', node_name=node.name)}}">{{ node.name }}</a></td>
|
||||
<td><a class="btn btn-small btn-primary" href="{{url_for('report_latest', node_name=node.name)}}">Latest Report</a></td>
|
||||
<td>
|
||||
{% if node.unreported_time != None or node.status != 'unreported' %}
|
||||
<a class="btn btn-small btn-primary btn-lastreport" href="{{url_for('report_latest', node_name=node.name)}}">Latest Report</a>
|
||||
{% else %}
|
||||
<a class="btn btn-small btn-lastreport"> No Report </a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user