Add fact recording and browsing

- Add a HostFacts model
- Add or update existing facts from callback
- Add a CLI command to show facts for a host
- Display and link to facts (if available) from the host summary
  page
- Add a new facts page
- Add tests relevant to facts for models, cli, integration, app

Closes: #75
This commit is contained in:
David Moreau-Simard
2016-06-01 18:10:45 -04:00
parent 002004f76d
commit 3680ea6ec1
14 changed files with 188 additions and 8 deletions

View File

@@ -1,3 +1,5 @@
import json
from flask import render_template, abort, Blueprint
from ara import models, utils
@@ -24,3 +26,18 @@ def show_host(host):
stats = utils.get_host_playbook_stats(host)
return render_template('host.html', host=host, stats=stats)
@host.route('/<host>/facts/')
def show_facts(host):
try:
host = models.Host.query.filter_by(name=host).one()
except models.NoResultFound:
abort(404)
if not host.facts:
abort(404)
else:
facts = json.loads(host.facts.values).iteritems()
return render_template('host_facts.html', host=host, facts=facts)