From 709d14e9a2020254b6597ad5afdeb3e2d1f0bdd1 Mon Sep 17 00:00:00 2001 From: redref Date: Sat, 4 Feb 2017 20:03:09 +0100 Subject: [PATCH 01/10] Inventory revamp - client side --- puppetboard/app.py | 84 ++++++++++++++---------- puppetboard/templates/inventory.html | 23 +++---- puppetboard/templates/inventory.json.tpl | 23 +++++++ 3 files changed, 82 insertions(+), 48 deletions(-) create mode 100644 puppetboard/templates/inventory.json.tpl diff --git a/puppetboard/app.py b/puppetboard/app.py index 9dfe18a..05ce75d 100644 --- a/puppetboard/app.py +++ b/puppetboard/app.py @@ -343,29 +343,11 @@ def nodes(env): current_env=env))) -@app.route('/inventory', defaults={'env': app.config['DEFAULT_ENVIRONMENT']}) -@app.route('//inventory') -def inventory(env): - """Fetch all (active) nodes from PuppetDB and stream a table displaying - those nodes along with a set of facts about them. - - Downside of the streaming aproach is that since we've already sent our - headers we can't abort the request if we detect an error. Because of this - we'll end up with an empty table instead because of how yield_or_stop - works. Once pagination is in place we can change this but we'll need to - provide a search feature instead. - - :param env: Search for facts in this environment - :type env: :obj:`string` - """ - envs = environments() - check_env(env, envs) - - headers = [] # a list of fact descriptions to go - # in the table header - fact_names = [] # a list of inventory fact names - fact_data = {} # a multidimensional dict for node and - # fact data +def inventory_facts(): + # a list of facts descriptions to go in table header + headers = [] + # a list of inventory fact names + fact_names = [] # load the list of items/facts we want in our inventory try: @@ -383,33 +365,65 @@ def inventory(env): headers.append(desc) fact_names.append(name) + return headers, fact_names + + +@app.route('/inventory', defaults={'env': app.config['DEFAULT_ENVIRONMENT']}) +@app.route('//inventory') +def inventory(env): + """Fetch all (active) nodes from PuppetDB and stream a table displaying + those nodes along with a set of facts about them. + + :param env: Search for facts in this environment + :type env: :obj:`string` + """ + envs = environments() + check_env(env, envs) + headers, fact_names = inventory_facts() + + return render_template( + 'inventory.html', + envs=envs, + current_env=env, + fact_headers=headers) + + +@app.route('/inventory/json', + defaults={'env': app.config['DEFAULT_ENVIRONMENT']}) +@app.route('//inventory/json') +def inventory_ajax(env): + """Backend endpoint for inventory table""" + draw = int(request.args.get('draw', 0)) + + envs = environments() + check_env(env, envs) + headers, fact_names = inventory_facts() + query = AndOperator() fact_query = OrOperator() fact_query.add([EqualsOperator("name", name) for name in fact_names]) + query.add(fact_query) if env != '*': query.add(EqualsOperator("environment", env)) - query.add(fact_query) - - # get all the facts from PuppetDB facts = puppetdb.facts(query=query) + fact_data = {} for fact in facts: if fact.node not in fact_data: fact_data[fact.node] = {} - fact_data[fact.node][fact.name] = fact.value - return Response(stream_with_context( - stream_template( - 'inventory.html', - headers=headers, - fact_names=fact_names, + total = len(fact_data) + + return render_template( + 'inventory.json.tpl', + draw=draw, + total=total, + total_filtered=total, fact_data=fact_data, - envs=envs, - current_env=env - ))) + columns=fact_names) @app.route('/node//', diff --git a/puppetboard/templates/inventory.html b/puppetboard/templates/inventory.html index 5eedeb7..098e1d8 100644 --- a/puppetboard/templates/inventory.html +++ b/puppetboard/templates/inventory.html @@ -1,24 +1,21 @@ {% extends 'layout.html' %} +{% import '_macros.html' as macros %} {% block content %} -
- -
- +
- {% for head in headers %} - {{head}} + {% for head in fact_headers %} + {% endfor %} - {% for node, facts in fact_data.iteritems() %} - - {% for name in fact_names %} - - {% endfor %} - - {% endfor %}
{{head}}
{{facts.get(name, 'undef')}}
{% endblock content %} +{% block onload_script %} +{% macro extra_options(caller) %} + 'serverSide': false, +{% endmacro %} +{{ macros.datatable_init(table_html_id="inventory_table", ajax_url=url_for('inventory_ajax', env=current_env), default_length=config.NORMAL_TABLE_COUNT, length_selector=config.TABLE_COUNT_SELECTOR, extra_options=extra_options) }} +{% endblock onload_script %} diff --git a/puppetboard/templates/inventory.json.tpl b/puppetboard/templates/inventory.json.tpl new file mode 100644 index 0000000..4d94bcd --- /dev/null +++ b/puppetboard/templates/inventory.json.tpl @@ -0,0 +1,23 @@ +{%- import '_macros.html' as macros -%} +{ + "draw": {{draw}}, + "recordsTotal": {{total}}, + "recordsFiltered": {{total_filtered}}, + "data": [ + {% for node in fact_data -%} + {%- if not loop.first %},{%- endif -%} + [ + {%- for column in columns -%} + {%- if not loop.first %},{%- endif -%} + {%- if column in ['fqdn', 'hostname'] -%} + {% filter jsonprint %}{{ node }}{% endfilter %} + {%- elif fact_data[node][column] -%} + {{ fact_data[node][column] | jsonprint }} + {%- else -%} + "" + {%- endif -%} + {%- endfor -%} + ] + {% endfor -%} + ] +} From 507df872340635743a43ae107dbfff7a6a8f74bb Mon Sep 17 00:00:00 2001 From: redref Date: Sat, 4 Feb 2017 22:21:01 +0100 Subject: [PATCH 02/10] Inventory page testing --- puppetboard/app.py | 12 ++++++------ test/test_app.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/puppetboard/app.py b/puppetboard/app.py index 05ce75d..6fce637 100644 --- a/puppetboard/app.py +++ b/puppetboard/app.py @@ -418,12 +418,12 @@ def inventory_ajax(env): total = len(fact_data) return render_template( - 'inventory.json.tpl', - draw=draw, - total=total, - total_filtered=total, - fact_data=fact_data, - columns=fact_names) + 'inventory.json.tpl', + draw=draw, + total=total, + total_filtered=total, + fact_data=fact_data, + columns=fact_names) @app.route('/node//', diff --git a/test/test_app.py b/test/test_app.py index a3cc494..fc1ec6e 100644 --- a/test/test_app.py +++ b/test/test_app.py @@ -620,3 +620,49 @@ def test_catalogs_json_compare(client, mocker, "action": "/catalogs/compare/node-unreported...node-%s" % found_status}) assert len(val) == 1 + + +def test_inventory_view(client, mocker, mock_puppetdb_environments): + rv = client.get('/inventory') + assert rv.status_code == 200 + soup = BeautifulSoup(rv.data, 'html.parser') + assert soup.title.contents[0] == 'Puppetboard' + + +def test_inventory_json(client, mocker, mock_puppetdb_environments): + facts = ['fqdn', 'ipaddress', 'lsbdistdescription', 'hardwaremodel', + 'kernelrelease', 'puppetversion'] + values = [ + ['node-1', 'X.X.X.X', 'os7', 'server', '4.3', 'X.X.X'], + ['node-2', 'X.X.X.X', 'os5', 'server', '4.1', 'X.X.X'], + ['node-3', 'X.X.X.X', 'os6', 'server', '4.2', 'X.X.X'], + ['node-4', 'X.X.X.X', 'os4', 'server', '4.3', 'X.X.X'], + ] + query_data = {'facts': []} + query_data['facts'].append([]) + + for i, value in enumerate(values): + for idx, column in enumerate(facts): + query_data['facts'][0].append({ + 'certname': value[0], + 'name': column, + 'value': value[idx], + 'environment': 'production' + }) + + dbquery = MockDbQuery(query_data) + + mocker.patch.object(app.puppetdb, '_query', side_effect=dbquery.get) + + rv = client.get('/inventory/json') + assert rv.status_code == 200 + result_json = json.loads(rv.data.decode('utf-8')) + assert 'data' in result_json + + for value in values: + for line in result_json['data']: + if value[0] in line[0]: + assert line[1:] == value[1:] + break + else: + raise Exception("Input %s not found" % value) From c229f51556132b11d67684ff4bdc6ded4c178a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Mon, 3 Apr 2017 23:37:21 +0200 Subject: [PATCH 03/10] Commonmark version (#321) * Allow HTML in config_version to be interpreted * Allow Markdown in config_version --- puppetboard/app.py | 3 +++ puppetboard/templates/report.html | 2 +- requirements.txt | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/puppetboard/app.py b/puppetboard/app.py index fc45f1c..20571ea 100644 --- a/puppetboard/app.py +++ b/puppetboard/app.py @@ -27,6 +27,7 @@ from puppetboard.utils import ( from puppetboard.dailychart import get_daily_reports_chart import werkzeug.exceptions as ex +import CommonMark from . import __version__ @@ -606,6 +607,8 @@ def report(env, node_name, report_id): except StopIteration: abort(404) + report.version = CommonMark.commonmark(report.version) + return render_template( 'report.html', report=report, diff --git a/puppetboard/templates/report.html b/puppetboard/templates/report.html index 0989f76..276dc74 100644 --- a/puppetboard/templates/report.html +++ b/puppetboard/templates/report.html @@ -14,7 +14,7 @@ {{ report.node }} - {{report.version}} + {{report.version|safe}} {{report.start}} diff --git a/requirements.txt b/requirements.txt index 0f51820..489e34f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,4 @@ Werkzeug >=0.12.1 itsdangerous >=0.23 pypuppetdb >=0.3.2 requests >=2.13.0 +CommonMark==0.7.2 From 3b817e0a5ed3e1029a61b55e5c9197d6cb25f30c Mon Sep 17 00:00:00 2001 From: Celant Date: Tue, 16 May 2017 14:07:36 +0100 Subject: [PATCH 04/10] Fix dailychart when using non-root location When puppetboard is being run from a directory instead of the root of the domain, the daily chart will not work as it tries to load the data from the root. This change makes it load the data from the current working URL, instead of forcing root. --- puppetboard/static/js/dailychart.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/puppetboard/static/js/dailychart.js b/puppetboard/static/js/dailychart.js index a14dca2..f68d428 100644 --- a/puppetboard/static/js/dailychart.js +++ b/puppetboard/static/js/dailychart.js @@ -1,6 +1,6 @@ jQuery(function ($) { function generateChart(el) { - var url = "/daily_reports_chart.json"; + var url = "daily_reports_chart.json"; var certname = $(el).attr('data-certname'); if (typeof certname !== typeof undefined && certname !== false) { url = url + "?certname=" + certname; From 1758f972f1a2cc4ba773500e6d0d5357a5d16551 Mon Sep 17 00:00:00 2001 From: redref Date: Tue, 31 Jan 2017 23:33:03 +0100 Subject: [PATCH 05/10] Reports counts - add total and noop --- puppetboard/app.py | 21 ++++++++++----------- puppetboard/static/css/puppetboard.css | 8 ++++++++ puppetboard/templates/_macros.html | 13 +++++++++++++ puppetboard/templates/reports.json.tpl | 2 +- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/puppetboard/app.py b/puppetboard/app.py index 20571ea..c7301dc 100644 --- a/puppetboard/app.py +++ b/puppetboard/app.py @@ -534,21 +534,20 @@ def reports_ajax(env, node_name): report_event_counts = {} # Create a map from the metrics data to what the templates # use to express the data. - report_map = { - 'success': 'successes', - 'failure': 'failures', - 'skipped': 'skips', - 'noops': 'noop' - } + events_metrics = ['success', 'failure', 'noop'] + resources_metrics = ['total', 'skipped'] for report in reports_events: if total is None: total = puppetdb.total - report_counts = {'successes': 0, 'failures': 0, 'skips': 0} - for metrics in report.metrics: - if 'name' in metrics and metrics['name'] in report_map: - key_name = report_map[metrics['name']] - report_counts[key_name] = metrics['value'] + report_counts = {} + for metric in report.metrics: + if ('category' in metric and metric['category'] == 'events' and + 'name' in metric and metric['name'] in events_metrics): + report_counts[metric['name']] = metric['value'] + if ('category' in metric and metric['category'] == 'resources' and + 'name' in metric and metric['name'] in resources_metrics): + report_counts[metric['name']] = metric['value'] report_event_counts[report.hash_] = report_counts diff --git a/puppetboard/static/css/puppetboard.css b/puppetboard/static/css/puppetboard.css index 19506f5..71b6856 100644 --- a/puppetboard/static/css/puppetboard.css +++ b/puppetboard/static/css/puppetboard.css @@ -72,6 +72,14 @@ h1.ui.header.no-margin-bottom { background-color: #DB843D; } +.ui.header.total { + color: #989898; +} + +.ui.label.total { + background-color: #989898; +} + .ui.label.unchanged { background-color: #89A54E; } diff --git a/puppetboard/templates/_macros.html b/puppetboard/templates/_macros.html index fe28cc5..7a07f15 100644 --- a/puppetboard/templates/_macros.html +++ b/puppetboard/templates/_macros.html @@ -57,6 +57,19 @@ {% endif %} {%- endmacro %} +{% macro report_status(caller, status, node_name, events, current_env, unreported_time=False, report_hash=False) -%} + {{ status|upper }} + {% if status == 'unreported' %} + {{ unreported_time|upper }} + {% else %} + {{events['total']}}{% else %}">0{% endif%} + {{events['failure']}}{% else %}">0{% endif%} + {{events['success']}}{% else %}">0{% endif%} + {{events['skipped']}}{% else %}">0{% endif%} + {{events['noop']}}{% else %}">0{% endif%} + {% endif %} +{%- endmacro %} + {% macro datatable_init(table_html_id, ajax_url, default_length, length_selector, extra_options=None) -%} // Init datatable $.fn.dataTable.ext.errMode = 'throw'; diff --git a/puppetboard/templates/reports.json.tpl b/puppetboard/templates/reports.json.tpl index 2c24659..9f74e31 100644 --- a/puppetboard/templates/reports.json.tpl +++ b/puppetboard/templates/reports.json.tpl @@ -15,7 +15,7 @@ "{{ report[column.attr] }}" {%- elif column.type == 'status' -%} {% filter jsonprint -%} - {{ macros.status_counts(status=report.status, node_name=report.node, events=report_event_counts[report.hash_], report_hash=report.hash_, current_env=current_env) }} + {{ macros.report_status(status=report.status, node_name=report.node, events=report_event_counts[report.hash_], report_hash=report.hash_, current_env=current_env) }} {%- endfilter %} {%- elif column.type == 'node' -%} {% filter jsonprint %}{{ report.node }}{% endfilter %} From bb26c5bbeae6e0405e97c1b0c35ac6a5ea1ebf17 Mon Sep 17 00:00:00 2001 From: redref Date: Wed, 1 Feb 2017 13:56:31 +0100 Subject: [PATCH 06/10] Metrics display tune --- puppetboard/app.py | 24 ++++++++---------------- puppetboard/templates/_macros.html | 12 ++++++------ puppetboard/templates/reports.json.tpl | 2 +- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/puppetboard/app.py b/puppetboard/app.py index c7301dc..4aef489 100644 --- a/puppetboard/app.py +++ b/puppetboard/app.py @@ -531,25 +531,17 @@ def reports_ajax(env, node_name): reports_events = [] total = 0 - report_event_counts = {} - # Create a map from the metrics data to what the templates - # use to express the data. - events_metrics = ['success', 'failure', 'noop'] - resources_metrics = ['total', 'skipped'] + # Convert metrics to relational dict + metrics = {} for report in reports_events: if total is None: total = puppetdb.total - report_counts = {} - for metric in report.metrics: - if ('category' in metric and metric['category'] == 'events' and - 'name' in metric and metric['name'] in events_metrics): - report_counts[metric['name']] = metric['value'] - if ('category' in metric and metric['category'] == 'resources' and - 'name' in metric and metric['name'] in resources_metrics): - report_counts[metric['name']] = metric['value'] - - report_event_counts[report.hash_] = report_counts + metrics[report.hash_] = {'resources': {}, 'events': {}} + for m in report.metrics: + if m['category'] not in metrics[report.hash_]: + metrics[report.hash_][m['category']] = {} + metrics[report.hash_][m['category']][m['name']] = m['value'] if total is None: total = 0 @@ -560,7 +552,7 @@ def reports_ajax(env, node_name): total=total, total_filtered=total, reports=reports, - report_event_counts=report_event_counts, + metrics=metrics, envs=envs, current_env=env, columns=REPORTS_COLUMNS[:max_col]) diff --git a/puppetboard/templates/_macros.html b/puppetboard/templates/_macros.html index 7a07f15..f7ce947 100644 --- a/puppetboard/templates/_macros.html +++ b/puppetboard/templates/_macros.html @@ -57,16 +57,16 @@ {% endif %} {%- endmacro %} -{% macro report_status(caller, status, node_name, events, current_env, unreported_time=False, report_hash=False) -%} +{% macro report_status(caller, status, node_name, metrics, current_env, unreported_time=False, report_hash=False) -%} {{ status|upper }} {% if status == 'unreported' %} {{ unreported_time|upper }} {% else %} - {{events['total']}}{% else %}">0{% endif%} - {{events['failure']}}{% else %}">0{% endif%} - {{events['success']}}{% else %}">0{% endif%} - {{events['skipped']}}{% else %}">0{% endif%} - {{events['noop']}}{% else %}">0{% endif%} + {{ metrics.resources.total }}{% else %}">0{% endif%} + {{ metrics.events.failure }}{% else %}">0{% endif%} + {{ metrics.events.success }}{% else %}">0{% endif%} + {{ metrics.resources.skipped }}{% else %}">0{% endif%} + {{ metrics.events.noop }}{% else %}">0{% endif%} {% endif %} {%- endmacro %} diff --git a/puppetboard/templates/reports.json.tpl b/puppetboard/templates/reports.json.tpl index 9f74e31..b773105 100644 --- a/puppetboard/templates/reports.json.tpl +++ b/puppetboard/templates/reports.json.tpl @@ -15,7 +15,7 @@ "{{ report[column.attr] }}" {%- elif column.type == 'status' -%} {% filter jsonprint -%} - {{ macros.report_status(status=report.status, node_name=report.node, events=report_event_counts[report.hash_], report_hash=report.hash_, current_env=current_env) }} + {{ macros.report_status(status=report.status, node_name=report.node, metrics=metrics[report.hash_], report_hash=report.hash_, current_env=current_env) }} {%- endfilter %} {%- elif column.type == 'node' -%} {% filter jsonprint %}{{ report.node }}{% endfilter %} From 16b197e0ce20635b876924322616dbdbbef86622 Mon Sep 17 00:00:00 2001 From: redref Date: Thu, 2 Feb 2017 10:05:49 +0100 Subject: [PATCH 07/10] Make counters configureable --- puppetboard/app.py | 2 +- puppetboard/default_settings.py | 5 +++++ puppetboard/static/css/puppetboard.css | 14 +++++--------- puppetboard/templates/_macros.html | 10 +++++----- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/puppetboard/app.py b/puppetboard/app.py index 4aef489..296f13e 100644 --- a/puppetboard/app.py +++ b/puppetboard/app.py @@ -537,7 +537,7 @@ def reports_ajax(env, node_name): if total is None: total = puppetdb.total - metrics[report.hash_] = {'resources': {}, 'events': {}} + metrics[report.hash_] = {} for m in report.metrics: if m['category'] not in metrics[report.hash_]: metrics[report.hash_][m['category']] = {} diff --git a/puppetboard/default_settings.py b/puppetboard/default_settings.py index 717925b..7bd6cc1 100644 --- a/puppetboard/default_settings.py +++ b/puppetboard/default_settings.py @@ -18,6 +18,11 @@ LOGLEVEL = 'info' NORMAL_TABLE_COUNT = 100 LITTLE_TABLE_COUNT = 10 TABLE_COUNT_SELECTOR = [10, 20, 50, 100, 500] +DISPLAYED_METRICS = ['resources.total', + 'events.failure', + 'events.success', + 'resources.skipped', + 'events.noop'] OFFLINE_MODE = False ENABLE_CATALOG = False OVERVIEW_FILTER = None diff --git a/puppetboard/static/css/puppetboard.css b/puppetboard/static/css/puppetboard.css index 71b6856..db50a38 100644 --- a/puppetboard/static/css/puppetboard.css +++ b/puppetboard/static/css/puppetboard.css @@ -44,7 +44,7 @@ h1.ui.header.no-margin-bottom { color: #AA4643; } -.ui.label.failed { +.ui.label.failed, .ui.label.events.failure { background-color: #AA4643; } @@ -52,7 +52,7 @@ h1.ui.header.no-margin-bottom { color: #4572A7; } -.ui.label.changed { +.ui.label.changed, .ui.label.events.success { background-color: #4572A7; } @@ -68,15 +68,11 @@ h1.ui.header.no-margin-bottom { color: #DB843D; } -.ui.label.noop { +.ui.label.noop, .ui.label.events.noop { background-color: #DB843D; } -.ui.header.total { - color: #989898; -} - -.ui.label.total { +.ui.label.resources.total { background-color: #989898; } @@ -88,7 +84,7 @@ h1.ui.header.no-margin-bottom { color: orange; } -.ui.label.skipped { +.ui.label.skipped, .ui.label.resources.skipped { background-color: orange; } diff --git a/puppetboard/templates/_macros.html b/puppetboard/templates/_macros.html index f7ce947..b39fadb 100644 --- a/puppetboard/templates/_macros.html +++ b/puppetboard/templates/_macros.html @@ -62,11 +62,11 @@ {% if status == 'unreported' %} {{ unreported_time|upper }} {% else %} - {{ metrics.resources.total }}{% else %}">0{% endif%} - {{ metrics.events.failure }}{% else %}">0{% endif%} - {{ metrics.events.success }}{% else %}">0{% endif%} - {{ metrics.resources.skipped }}{% else %}">0{% endif%} - {{ metrics.events.noop }}{% else %}">0{% endif%} + {% for metric in config.DISPLAYED_METRICS %} + {% set path = metric.split('.') %} + {% set title = ' '.join(path) %} + {{ "%.2g"|format(metrics[path[0]][path[1]]) }}{% else %}">0{% endif%} + {% endfor %} {% endif %} {%- endmacro %} From 42ed123fe37d1e234f80624609ebec9269e733cd Mon Sep 17 00:00:00 2001 From: redref Date: Thu, 2 Feb 2017 18:23:09 +0100 Subject: [PATCH 08/10] Fix number formating in counters --- puppetboard/templates/_macros.html | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/puppetboard/templates/_macros.html b/puppetboard/templates/_macros.html index b39fadb..e4cb163 100644 --- a/puppetboard/templates/_macros.html +++ b/puppetboard/templates/_macros.html @@ -65,7 +65,17 @@ {% for metric in config.DISPLAYED_METRICS %} {% set path = metric.split('.') %} {% set title = ' '.join(path) %} - {{ "%.2g"|format(metrics[path[0]][path[1]]) }}{% else %}">0{% endif%} + {% if metrics[path[0]] and metrics[path[0]][path[1]] %} + {% set value = metrics[path[0]][path[1]] %} + {% if value != 0 and value|int != value %} + {% set format_str = '%.2f' %} + {% else %} + {% set format_str = '%s' %} + {% endif %} + {{ format_str|format(value) }} + {% else %} + 0 + {% endif%} {% endfor %} {% endif %} {%- endmacro %} From 671d538a8bcd00714c3cdc873a0df359a7f16639 Mon Sep 17 00:00:00 2001 From: Mike Terzo Date: Thu, 2 Feb 2017 20:14:02 -0500 Subject: [PATCH 09/10] Add report column settings to docker_settings --- puppetboard/docker_settings.py | 8 +++++++- test/test_docker_settings.py | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/puppetboard/docker_settings.py b/puppetboard/docker_settings.py index e32ac2a..3f61b33 100644 --- a/puppetboard/docker_settings.py +++ b/puppetboard/docker_settings.py @@ -33,6 +33,13 @@ TABLE_COUNT_DEF = "10,20,50,100,500" TABLE_COUNT_SELECTOR = [int(x) for x in os.getenv('TABLE_COUNT_SELECTOR', TABLE_COUNT_DEF).split(',')] +DISP_METR_DEF = ','.join(['resources.total', 'events.failure', + 'events.success', 'resources.skipped', + 'events.noop']) + +DISPLAYED_METRICS = [x.strip() for x in os.getenv('DISPLAYED_METRICS', + DISP_METR_DEF).split(',')] + OFFLINE_MODE = bool(os.getenv('OFFLINE_MODE', 'False').upper() == 'TRUE') ENABLE_CATALOG = bool(os.getenv('ENABLE_CATALOG', 'False').upper() == 'TRUE') OVERVIEW_FILTER = os.getenv('OVERVIEW_FILTER', None) @@ -46,7 +53,6 @@ GRAPH_FACTS_DEFAULT = ','.join(['architecture', 'clientversion', 'domain', GRAPH_FACTS = [x.strip() for x in os.getenv('GRAPH_FACTS', GRAPH_FACTS_DEFAULT).split(',')] - GRAPH_TYPE = os.getenv('GRAPH_TYPE', 'pie') # Tuples are hard to express as an environment variable, so here diff --git a/test/test_docker_settings.py b/test/test_docker_settings.py index 4b36a6d..6a44ab1 100644 --- a/test/test_docker_settings.py +++ b/test/test_docker_settings.py @@ -116,3 +116,11 @@ def test_env_table_selector(cleanUpEnv): os.environ['TABLE_COUNT_SELECTOR'] = '5,15,25' reload(docker_settings) assert [5, 15, 25] == docker_settings.TABLE_COUNT_SELECTOR + + +def test_env_column_options(cleanUpEnv): + os.environ['DISPLAYED_METRICS'] = 'resources.total, events.failure' + + reload(docker_settings) + assert ['resources.total', + 'events.failure'] == docker_settings.DISPLAYED_METRICS From db2f8f8b59053b705663063d40a15b71998e7ed7 Mon Sep 17 00:00:00 2001 From: Mike Terzo Date: Sat, 10 Jun 2017 02:32:33 -0400 Subject: [PATCH 10/10] Adding Docker puppet version tagging --- hooks/pre_build | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 hooks/pre_build diff --git a/hooks/pre_build b/hooks/pre_build new file mode 100755 index 0000000..8c914a4 --- /dev/null +++ b/hooks/pre_build @@ -0,0 +1,11 @@ +#!/bin/bash + +version=$(git describe HEAD --abbrev=4) + +cat << EOF > puppetboard/version.py +# +# Puppetboard version module +# +__version__ = '${version}' +EOF +