Selecting which graphs to show with config option

Known-good facts to graph are set as defaults. This list is merged
with whatever facts are listed in settings.py
This commit is contained in:
Spencer Krum
2014-07-01 02:24:45 -07:00
committed by William Van Hevelingen
parent 3940c84de3
commit 7a0c4bd837
3 changed files with 20 additions and 1 deletions

View File

@@ -27,7 +27,9 @@ from puppetboard.utils import (
app = Flask(__name__)
app.config.from_object('puppetboard.default_settings')
graph_facts = app.config['GRAPH_FACTS']
app.config.from_envvar('PUPPETBOARD_SETTINGS', silent=True)
graph_facts += app.config['GRAPH_FACTS']
app.secret_key = os.urandom(24)
app.jinja_env.filters['jsonprint'] = jsonprint
@@ -263,10 +265,14 @@ def fact(fact):
node for which this fact is known."""
# we can only consume the generator once, lists can be doubly consumed
# om nom nom
render_graph = False
if fact in graph_facts:
render_graph = True
localfacts = [f for f in yield_or_stop(puppetdb.facts(name=fact))]
return Response(stream_with_context(stream_template(
'fact.html',
name=fact,
render_graph=render_graph,
facts=localfacts)))

View File

@@ -12,3 +12,14 @@ LOCALISE_TIMESTAMP = True
LOGLEVEL = 'info'
REPORTS_COUNT = 10
OFFLINE_MODE = False
GRAPH_FACTS = ['architecture',
'domain',
'lsbcodename',
'lsbdistcodename',
'lsbdistid',
'lsbdistrelease',
'lsbmajdistrelease',
'netmask',
'osfamily',
'puppetversion',
'processorcount']

View File

@@ -2,7 +2,9 @@
{% import '_macros.html' as macros %}
{% block content %}
<h1>{{name}}{% if value %}/{{value}}{% endif %} ({{facts|length}})</h1>
{% if render_graph %}
{{macros.facts_graph(facts, autofocus=True, show_node=True, margin_bottom=10)}}
{% endif %}
{% if value %}
{{macros.facts_table(facts, autofocus=True, show_node=True, show_value=False, margin_bottom=10)}}
{% else %}