Merge pull request #204 from corey-hammerton/pypuppetdb-0.2.1
Using new Node and Catalog fields available in pypuppetdb 0.2.1 With the latest_report_hash field available on the Node object the report_latest can be partially deprecated. Will hopefully be removed in the next major/minor release.
This commit is contained in:
@@ -517,25 +517,43 @@ def report_latest(env, node_name):
|
|||||||
check_env(env, envs)
|
check_env(env, envs)
|
||||||
|
|
||||||
if env == '*':
|
if env == '*':
|
||||||
query='["and",' \
|
node_query = '["=", "certname", "{0}"]'.format(node_name)
|
||||||
'["=", "certname", "{0}"],' \
|
|
||||||
'["=", "latest_report?", true]]'.format(node_name)
|
|
||||||
else:
|
else:
|
||||||
query='["and",' \
|
node_query = '["and",' \
|
||||||
'["=", "environment", "{0}"],' \
|
'["=", "report_environment", "{0}"],' \
|
||||||
'["=", "certname", "{1}"],' \
|
'["=", "certname", "{1}"]]'.format(env, node_name)
|
||||||
'["=", "latest_report?", true]]'.format(
|
|
||||||
env,
|
|
||||||
node_name)
|
|
||||||
|
|
||||||
reports = get_or_abort(puppetdb.reports, query=query)
|
|
||||||
try:
|
try:
|
||||||
report = next(reports)
|
node = next(get_or_abort(puppetdb.nodes,
|
||||||
|
query=node_query,
|
||||||
|
with_status=True))
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
if node.latest_report_hash is not None:
|
||||||
|
hash_ = node.latest_report_hash
|
||||||
|
else:
|
||||||
|
if env == '*':
|
||||||
|
query='["and",' \
|
||||||
|
'["=", "certname", "{0}"],' \
|
||||||
|
'["=", "latest_report?", true]]'.format(node.name)
|
||||||
|
else:
|
||||||
|
query='["and",' \
|
||||||
|
'["=", "environment", "{0}"],' \
|
||||||
|
'["=", "certname", "{1}"],' \
|
||||||
|
'["=", "latest_report?", true]]'.format(
|
||||||
|
env,
|
||||||
|
node.name)
|
||||||
|
|
||||||
|
reports = get_or_abort(puppetdb.reports, query=query)
|
||||||
|
try:
|
||||||
|
report = next(reports)
|
||||||
|
hash_ = report.hash_
|
||||||
|
except StopIteration:
|
||||||
|
abort(404)
|
||||||
|
|
||||||
return redirect(
|
return redirect(
|
||||||
url_for('report', env=env, node_name=node_name, report_id=report.hash_))
|
url_for('report', env=env, node_name=node_name, report_id=hash_))
|
||||||
|
|
||||||
|
|
||||||
@app.route('/report/<node_name>/<report_id>', defaults={'env': app.config['DEFAULT_ENVIRONMENT']})
|
@app.route('/report/<node_name>/<report_id>', defaults={'env': app.config['DEFAULT_ENVIRONMENT']})
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
<th>Hostname</th>
|
<th>Hostname</th>
|
||||||
<th>Version</th>
|
<th>Version</th>
|
||||||
<th>Transaction UUID</th>
|
<th>Transaction UUID</th>
|
||||||
|
<th>Code ID</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
<td><a href="{{url_for('node', env=current_env, node_name=catalog.node)}}">{{catalog.node}}</a></td>
|
<td><a href="{{url_for('node', env=current_env, node_name=catalog.node)}}">{{catalog.node}}</a></td>
|
||||||
<td>{{catalog.version}}</td>
|
<td>{{catalog.version}}</td>
|
||||||
<td>{{catalog.transaction_uuid}}</td>
|
<td>{{catalog.transaction_uuid}}</td>
|
||||||
|
<td>{{catalog.code_id}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -79,14 +79,22 @@
|
|||||||
{% if node.status != 'unchanged' %}
|
{% if node.status != 'unchanged' %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{{macros.status_counts(status=node.status, node_name=node.name, events=node.events, unreported_time=node.unreported_time, current_env=current_env)}}
|
{% if node.latest_report_hash %}
|
||||||
|
{{macros.status_counts(status=node.status, node_name=node.name, events=node.events, unreported_time=node.unreported_time, current_env=current_env, report_hash=node.latest_report_hash)}}
|
||||||
|
{% else %}
|
||||||
|
{{macros.status_counts(status=node.status, node_name=node.name, events=node.events, unreported_time=node.unreported_time, current_env=current_env)}}
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{url_for('node', env=current_env, node_name=node.name)}}">{{ node.name }}</a>
|
<a href="{{url_for('node', env=current_env, node_name=node.name)}}">{{ node.name }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if node.report_timestamp %}
|
{% if node.report_timestamp %}
|
||||||
<a href="{{url_for('report_latest', env=current_env, node_name=node.name)}}" rel='utctimestamp'>{{ node.report_timestamp }}</a>
|
{% if node.latest_report_hash %}
|
||||||
|
<a href="{{url_for('report', env=current_env, node_name=node.name, report_id=node.latest_report_hash)}}" rel='utctimestamp'>{{ node.report_timestamp }}</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="{{url_for('report_latest', env=current_env, node_name=node.name)}}" rel='utctimestamp'>{{ node.report_timestamp }}</a>
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<i class="large ban circle icon"></i>
|
<i class="large ban circle icon"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -18,13 +18,21 @@
|
|||||||
{% for node in nodes %}
|
{% for node in nodes %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{{macros.status_counts(status=node.status, node_name=node.name, events=node.events, unreported_time=node.unreported_time, current_env=current_env)}}
|
{% if node.latest_report_hash %}
|
||||||
|
{{macros.status_counts(status=node.status, node_name=node.name, events=node.events, unreported_time=node.unreported_time, current_env=current_env, report_hash=node.latest_report_hash)}}
|
||||||
|
{% else %}
|
||||||
|
{{macros.status_counts(status=node.status, node_name=node.name, events=node.events, unreported_time=node.unreported_time, current_env=current_env)}}
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td><a href="{{url_for('node', env=current_env, node_name=node.name)}}">{{node.name}}</a></td>
|
<td><a href="{{url_for('node', env=current_env, node_name=node.name)}}">{{node.name}}</a></td>
|
||||||
<td><a rel="utctimestamp" href="{{url_for('catalog_node', env=current_env, node_name=node.name)}}">{{node.catalog_timestamp}}</a></td>
|
<td><a rel="utctimestamp" href="{{url_for('catalog_node', env=current_env, node_name=node.name)}}">{{node.catalog_timestamp}}</a></td>
|
||||||
<td>
|
<td>
|
||||||
{% if node.report_timestamp %}
|
{% if node.report_timestamp %}
|
||||||
<a href="{{url_for('report_latest', env=current_env, node_name=node.name)}}" rel='utctimestamp'>{{ node.report_timestamp }}</a>
|
{% if node.latest_report_hash %}
|
||||||
|
<a href="{{url_for('report', env=current_env, node_name=node.name, report_id=node.latest_report_hash)}}" rel='utctimestamp'>{{ node.report_timestamp }}</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="{{url_for('report_latest', env=current_env, node_name=node.name)}}" rel='utctimestamp'>{{ node.report_timestamp }}</a>
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<i class="large ban circle icon"></i>
|
<i class="large ban circle icon"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -32,7 +32,7 @@ setup(
|
|||||||
"Flask >= 0.10.1",
|
"Flask >= 0.10.1",
|
||||||
"Flask-WTF >= 0.9.4, <= 0.9.5",
|
"Flask-WTF >= 0.9.4, <= 0.9.5",
|
||||||
"WTForms < 2.0",
|
"WTForms < 2.0",
|
||||||
"pypuppetdb >= 0.2.0, < 0.3.0",
|
"pypuppetdb >= 0.2.1, < 0.3.0",
|
||||||
],
|
],
|
||||||
keywords="puppet puppetdb puppetboard",
|
keywords="puppet puppetdb puppetboard",
|
||||||
classifiers=[
|
classifiers=[
|
||||||
|
|||||||
Reference in New Issue
Block a user