Add OVERVIEW_FILTER (#196)

This commit is contained in:
Raphaël Pinson
2016-05-25 00:49:30 +02:00
committed by Corey Hammerton
parent eb893ffef5
commit 0576e6d955
2 changed files with 7 additions and 4 deletions

View File

@@ -140,7 +140,7 @@ def index(env):
check_env(env, envs) check_env(env, envs)
if env == '*': if env == '*':
query = None query = app.config['OVERVIEW_FILTER']
prefix = 'puppetlabs.puppetdb.population' prefix = 'puppetlabs.puppetdb.population'
num_nodes = get_or_abort( num_nodes = get_or_abort(
@@ -157,9 +157,11 @@ def index(env):
metrics['avg_resources_node'] = "{0:10.0f}".format( metrics['avg_resources_node'] = "{0:10.0f}".format(
avg_resources_node['Value']) avg_resources_node['Value'])
else: else:
query = '["and", {0}]'.format( conditions = ", ".join('["=", "{0}", "{1}"]'.format(field, env)
", ".join('["=", "{0}", "{1}"]'.format(field, env) for field in ['catalog_environment', 'facts_environment'])
for field in ['catalog_environment', 'facts_environment'])) if app.config['OVERVIEW_FILTER'] != None:
conditions += ", {0}".format(app.config['OVERVIEW_FILTER'])
query = '["and", {0}]'.format(conditions)
num_nodes = get_or_abort( num_nodes = get_or_abort(
puppetdb._query, puppetdb._query,
'nodes', 'nodes',

View File

@@ -18,6 +18,7 @@ LOGLEVEL = 'info'
REPORTS_COUNT = 10 REPORTS_COUNT = 10
OFFLINE_MODE = False OFFLINE_MODE = False
ENABLE_CATALOG = False ENABLE_CATALOG = False
OVERVIEW_FILTER = None
GRAPH_FACTS = ['architecture', GRAPH_FACTS = ['architecture',
'clientversion', 'clientversion',
'domain', 'domain',