From 0576e6d95566cf26a0e11c65825e7c0720ebd6cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 25 May 2016 00:49:30 +0200 Subject: [PATCH] Add OVERVIEW_FILTER (#196) --- puppetboard/app.py | 10 ++++++---- puppetboard/default_settings.py | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/puppetboard/app.py b/puppetboard/app.py index ecea8ac..a65e4a7 100644 --- a/puppetboard/app.py +++ b/puppetboard/app.py @@ -140,7 +140,7 @@ def index(env): check_env(env, envs) if env == '*': - query = None + query = app.config['OVERVIEW_FILTER'] prefix = 'puppetlabs.puppetdb.population' num_nodes = get_or_abort( @@ -157,9 +157,11 @@ def index(env): metrics['avg_resources_node'] = "{0:10.0f}".format( avg_resources_node['Value']) else: - query = '["and", {0}]'.format( - ", ".join('["=", "{0}", "{1}"]'.format(field, env) - for field in ['catalog_environment', 'facts_environment'])) + conditions = ", ".join('["=", "{0}", "{1}"]'.format(field, env) + 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( puppetdb._query, 'nodes', diff --git a/puppetboard/default_settings.py b/puppetboard/default_settings.py index 7740dd7..595e690 100644 --- a/puppetboard/default_settings.py +++ b/puppetboard/default_settings.py @@ -18,6 +18,7 @@ LOGLEVEL = 'info' REPORTS_COUNT = 10 OFFLINE_MODE = False ENABLE_CATALOG = False +OVERVIEW_FILTER = None GRAPH_FACTS = ['architecture', 'clientversion', 'domain',