Commit Graph

123 Commits

Author SHA1 Message Date
redref
4b96cfe196 Fix facts method doc 2017-03-23 23:12:57 +01:00
redref
484727b62c Fix #356 with the new template
Created a custom template_filter as in python3, the groupby filter cannot order Bool vs Str. Needed to push format before the groupby which is not currently possible in jinja.
2017-03-23 22:35:28 +01:00
redref
40511c007a Fact pages and node page tests 2017-03-23 22:35:28 +01:00
redref
a21bd0ac1d Revamp fact pages and tables to datatables 2017-03-23 22:35:28 +01:00
redref
f13100664a Facts page fix + performance revamp
Removed facts query to let only fact-names. facts query time grow pretty quickly with number of nodes. Drawback: no filter on environment (which seems acceptable)
Add testing about view and column repartition (broken in jinja2 2.9.X / inner loop variables).
Rework facts page (jinja 2.9 compliant)
2017-03-23 22:35:28 +01:00
Mike Terzo
cdedf94506 Remove 204-NoContent, Flask, and Werkzeug no longer provide
public apis to add additional error code exception handling.
2017-03-20 19:47:13 -04:00
Mike Terzo
fd4051b619 Merge pull request #353 from redref/catalogs
Revamp catalog page with paging
2017-02-15 04:53:07 -05:00
Mike Terzo
1e5f683b66 Moving version to a single place in version.py (#358)
* Moving version to a single place in version.py
* Requirements in setup.py + tox.ini
2017-02-13 00:35:15 -05:00
redref
f908a1e86c Catalogs tests - better data testing 2017-02-06 16:19:45 +01:00
redref
4190e36278 Add some tests to catalogs 2017-02-03 23:11:08 +01:00
redref
b947bf05c2 Revamp catalog page: paging + datatables 2017-02-03 22:08:05 +01:00
Mike Terzo
596f0110f1 Support for new Flask errorhandling 2017-02-02 08:19:59 -05:00
Mike Terzo
58d613ba02 Fixing pep8 issues for the future 2017-02-02 08:19:59 -05:00
Mike Terzo
48ab6b615a Support for PuppetDB 3.x on all environments
Mbeans use type=default in puppetdb 3x, type was removed in 4x.
2017-01-27 07:40:08 -05:00
Tim Meusel
7119098e8f Merge pull request #336 from mterzo/js_to_head
Moving java_script to head tag
2017-01-26 23:45:30 +01:00
Mike Terzo
5a12c08d2f Metrics can appear as paths, if these paths are passed
to Flask, it 500's
2017-01-26 17:32:24 -05:00
Mike Terzo
ebab9ccdbc Adding noop map from metrics 2017-01-26 13:52:55 -05:00
Mike Terzo
86fe05f5f9 Adding default values to parameters 2017-01-26 04:25:32 -05:00
Mike Terzo
680ee0e217 Following the format of all the other app.route definitions 2017-01-26 04:24:53 -05:00
Mike Terzo
7943414691 Use the data that's provided by reports.metrics instead
of calling the API again
2017-01-26 01:25:34 -05:00
redref
103eaa8843 Paging - fix empty list 2017-01-25 22:38:12 +01:00
redref
c1b1badc96 Paging - Revamp tables with Jquery Datatables (Ajax) 2017-01-25 18:07:55 +01:00
Mike Terzo
86488280c9 Test error conditions.
Fix 412 template to use standard styling that the other 400 templates use.
Update forbidden error to return status code 403 instead of 400.

Signed-off-by: Mike Terzo <mike@terzo.org>
2017-01-23 19:53:55 -05:00
Robert Fletcher
333347d113 Radiator JSON output (#329)
Json output from radiator when Accept header is application/json
2017-01-23 16:15:18 -05:00
Joris Dedieu
9fe0f091f3 catch a division by zero in radiator while environment has no nodes (#325)
* catch a division by zero in radiator while environment has no nodes
2017-01-05 15:51:38 -05:00
Manuel Quiñones
08e214ec15 Overview, Node pages: Add bar chart of daily runs
The Overview will display a bar chart of daily runs, categorized by
report status (changed, unchanged, failed).

The chart data is loaded asynchronously from JSON so it doesn't provoke
a delay in the page load. The data is JSON enconded.

This feature was in the original Puppet Dashboard.  The change was
proposed and discussed in issue #308 .

Application changes:

- app.py: New view daily_reports_chart to serve the chart data as JSON.

- dailychart.py: Submodule to query and format the chart data.

Template changes:

- layout.html: New block to add more elements to the HTML header.

- index.html, node.html: Add C3 CSS in header block, add DIV placeholder
  for the chart in content block, add dailychart.js (and dependencies)
  in script block.

Settings:

- DAILY_REPORTS_CHART_ENABLED: New setting to turn off the charts. By
  default is on.

- DAILY_REPORTS_CHART_DAYS: Changes the range of days to display in the
  charts.

Javascript changes:

- dailychart.js: New script that loads the JSON data for the chart and
  calls C3 to generate a bar chart.

CSS changes:

- puppetboard.css: Set fixed height to the chart container to avoid a
  page resize after the chart is loaded.
2016-10-26 16:39:03 -03:00
Mike Terzo
3fbd182453 Adding unittests (#300)
* Create a custom class to handle aborting 204 properly.  If this isn't
covered the server will send a 500 due to a python exception

* Moved py.test configuration under tool:pytest, this was causing a
warning.  This is new to 3.0.1 which is now the pinned version

* Unittest for puppetboard.utils
2016-09-11 21:01:13 -04:00
Corey Hammerton
df3d4a5eaa puppetboard/app.py: Adding an environment filter for displaying Fact names (#295)
This resolves #276

Current behaviour of the Facts page would query the fact_names endpoint
regardless of environment. This update would query the Facts endpoint,
extracting each unique fact name known to the environment.
2016-09-03 17:11:28 -04:00
Corey Hammerton
5048662861 puppetboard/app.py: Simplifying the Inventory Code (#289)
* puppetboard/app.py: Simplifying the code generating and rendering the Inventory

This resolves #275

This update eliminates one iteration over the resulting inventory facts
that generates a multidimensional dictionary keyed by the node's certname
to another dictionary of key-value pairs of the fact name and fact value.

* puppetboard/templates/inventory.html: Wrapping the fact values in links to the Node page

This comes as a request from #280
2016-09-03 17:10:33 -04:00
Corey Hammerton
0c0a15bdf2 puppetboard/app.py: Enhancing queries for Node and Report states (#271)
* puppetboard/app.py: Enhancing queries for Node and Report states

This resolves #264

On the Nodes and Reports tabs when the user adds a status query string
argument additional query clauses are generated based on its value.
Can be one of failed, changed, unchanged, noop or unreported (for Nodes
only)

No query clause is generated for noop on the Nodes tab. The query field
latest_report_noop was added in PuppetDB 4.1 and we do not want to break
compatability between minor or bug-fix versions.

* puppetboard/app.py: Simplifying the query logic in nodes()

The new logic starts with a blank `AndOperator()` object then proceeds
to build the query based on environment and status values. After all
after all checking if there are no operations declare the object as
None.

* puppetboard/app.py: Simplifying the query logic for reports()

Similar to the work done for nodes()

* puppetboard/app.py: Fixing pep8 formatting in nodes()

* Add pagination to reports/<node>
2016-08-18 20:39:31 -04:00
Thomas Hager
294e2d6559 Fixed a typo in Puppetboard's catalog view (#282)
Replaced oder_by_str with order_by_str in get_or_abort() to fix app crash.
2016-07-27 19:59:20 -04:00
Mike Terzo
faac5fa1bc Travis ci integration (#267)
* Initial travis-ci integration

* Format code base to PEP8
2016-07-13 20:59:07 -04:00
Corey Hammerton
2a6e2380ad puppetboard/app.py: Using the plain-text metric name in metrics() (#259)
This fixes #258

URL quoting is now done in pypuppetdb >= 0.2.3 which contributed to the
metric URL being double-quoted by the time it reached PuppetDB, which
responds with a 404. Instead using the plain-text name to build the
link to metric()
2016-06-28 20:09:30 -04:00
Corey Hammerton
da044271ee PuppetBoard: Upgrading WTForms to latest version and restoring CSRF Protection (#250)
Upgrading the following packages to the respected versions:

WTForms==2.1
Flask-WTF==0.12
Werkzeug==0.11.0

Passing newly required metadata to the QueryForm constructor in puppetboard/app.py

Apache >= 2.4 with mod_wsgi experienced a major issue where it would re-generate
the app's secret key on each request. The fix for this turned out to be placing
a permanent statis 'secret_key' value in the wsgi.py. Adding a block in README.rst
on how to implement the user's own secret_key
2016-06-23 20:32:31 -04:00
Corey Hammerton
adac2a46bf Implementing new pypuppetdb.QueryBuilder (#251)
* puppetboard/app.py: Implementing and utilizing the new PyPuppetDB QueryBuilder

This fixes https://github.com/voxpupuli/puppetboard/issues/239

Replacing all the directly declared query strings with various objects
from the pypuppetdb.QueryBuilder sub-module. Using this Object-Oriented
functionality it is programmatically safer to construct large, complex
queries.

* puppetboard/app.py: Simplifying the environment logic in `node()`

The query in this function will now always be an `AndOperator()` object.
If a specific environment is queried then that constraint is added.

The resulting query difference will be:

env == 'production'

`["and",["=", "environment", "production"],["=", "certname", "puppet01.hammertime.local"]]`

env == '*'

`["and",["=", "certname", "puppet01.hammertime.local"]]`

* puppetboard/app.py: Minor code simplification for more accurate results.

In index() adding the configured OVERVIEW_FILTER query after adding the previous
constraints to num_nodes_query
In inventory() wrapping fact_query in an AndOperator() regardless of environment.
This update makes it more common with other endpoints that only add environment
constraints if an environment is selected.

* requirements.txt: Bumping the pypuppetdb version requirement

* requirements.txt: Bumping pypuppetdb version to new requirement.

* puppetboard/app.py: Fixing module load error.
2016-06-23 20:26:21 -04:00
Raphaël Pinson
6a072d1f1b Merge branch 'pql' 2016-06-21 09:46:02 +02:00
Raphaël Pinson
38986047a6 Add PQL endpoint to Query form
Requires https://github.com/voxpupuli/pypuppetdb/pull/97
2016-06-21 06:59:24 +02:00
Raphaël Pinson
4887588662 Pretty print data from Query tab (#257) 2016-06-20 21:26:15 -04:00
Corey Hammerton
b7cd58ac2c More Easily View All Reports (#245)
* puppetboard/app.py: Refactoring the report event counts.

Writing the report event counts code in the node(), reports() and
reports_node() functions to iterate through report.events() instead
of querying the event counts endpoint for each report.

This solution is heavier than the original because we have to query
for all full event objects for each report and iterate through them
to interpret their statuses. I originally wanted to replace the
report.events() function with an events variable for the Report object
but that turned out to be not technically possible presently because
the report extended events' timestamps for in a different format which
python can't interpret. Specifically the timezone values contain ':',
there is no Python 2.x documentation that states timezones containing
colons is supported.

This does, however, lighten our dependency on the event-counts endpoint
which is marked as experimental. Which means that it may change or be
removed in a future release.

This also resolves a silent bug which may or may not include environment
filters on the event-counts queries. report.events() searches the Events
endpoint based on the report hash which eliminates the possibility of
mistaken relationships.

* puppetboard/app.py: Replacing url_for_* functions with a single url_for_field()

The url_for_pagination and url_for_environments functions only worked
with a single, fixed request argument, 'page' and 'env' respectively.
The new url_for_field() excepts 2 arguments, field: the name of the
argument to update, and value: its intended value.

Should consider adding a url_for_fields() function that accepts a
dict argument and updates all the request arguments using a dict.update().
There is currently no requirement for it so it will remain in the backlog.

* puppetboard/templates/reports.html: Adding a dropdown menu to limit the report count

This fixes https://github.com/voxpupuli/puppetboard/issues/202

This new dropdown allows users to select their desired number of reports
on the reports() and reports_node() pages. The available options are
app.config['REPORTS_COUNT'], 25, 50, 100 or All. The default value
is determined by the REPORTS_COUNT configuration value.

Had to modify url_for_field() to merge the request args to the view args
in order to generate the links that include the limit query string.
2016-06-06 20:09:07 -04:00
Raphaël Pinson
0576e6d955 Add OVERVIEW_FILTER (#196) 2016-05-24 18:49:30 -04:00
Corey Hammerton
eb893ffef5 puppetboard/app.py: Protecting against ZeroDivisionErrors on calculations (#244)
This (re-)fixes https://github.com/voxpupuli/puppetboard/issues/220

Corner cases where new installations or empty environments will return
zero resources and zero nodes, this will result in a ZeroDivisionError.
Now if this happens setting the average-resources-per-node to zero.
2016-05-21 16:00:32 -04:00
Corey Hammerton
54fb258b06 puppetboard/app.py: Removing :func:puppetboard/report_latest (#237)
This fixes https://github.com/voxpupuli/puppetboard/issues/234

The report_latest() function was effectively deprecated when PuppetDB
introduced the latest_report_hash field in the Nodes endpoint response
format in version 3.2. With the breaking changes to PuppetDB 4.0.0
support this function can be safely removed.
2016-05-16 20:00:35 -04:00
Corey Hammerton
3833bbf0a1 puppetboard/app.py: Adding Radiator view (#232)
* puppetboard/app.py: Adding Radiator view

Part 2 of https://github.com/voxpupuli/puppetboard/issues/70

This is a refactoring of the changes in https://github.com/voxpupuli/puppetboard/pull/100.
Adds a simple Heads-Up Display of the last run statuses of managed nodes,
either environment filtered or not.

* puppetboard/app.py: Fixing environment filters and metric strings.

* The names of the population metrics have changes in PuppetDB 4.0, the initial
  commit used the metric names from PuppetDB 2.x.
* The main nodes query did not include a query string to filter on environments.
2016-05-16 19:59:40 -04:00
Michael
b5ba2515e2 Semantic UI update to 2.1.8 (#211)
* Update to Semantic UI 2.1.6

Basically I tried to rebuild the old layout as closely as possible.
It is a bit more mobile friendly but still misses Semantic UIs collapsable menu:
  https://github.com/Semantic-Org/Semantic-UI/issues/157

+ ditch old tablesorter for recommended one
+ use em instead of percentage for status labels in macros

Overview:

+ sort overview by report date per default
+ slightly different colors

Facts:

+ template based approach to even out the columns in facts view
+ don't show empty containers
+ needed an additional variable in context

* get rid of unnecessary semantic src files

* more cleanup

* clean jquery-tablesort directory as well

* drop unused theme files

* remove symlinks in static/{js,css}

* semantic_update

+ bump to semantic 2.1.8
+ minor adjustments
  - default-sort class in tables
  - table type in inventory
  - fixed and wrapped table for reports

* updated screenshots
2016-04-23 20:30:20 -04:00
Matthew Gyurgyik
a7a35c1829 puppetdb 4.x metric api calls (#228) 2016-04-23 20:08:29 -04:00
corey.hammerton
c13389cc3e Version bump to 0.1.2 2016-02-15 19:57:43 -05:00
Corey Hammerton
3844d72bcb Merge pull request #219 from corey-hammerton/issue-218
puppetboard/app: Enabling environment filtering on overview metrics
2016-02-09 19:37:42 -05:00
corey.hammerton
0111e52096 puppetboard/app: Enabling environment filtering on overview metrics
This fixes https://github.com/voxpupuli/puppetboard/issues/218

Adding environment filters to only report then number of managed nodes
and resources that are present in the current environment. Still using
the same metrics endpoint information for all environments.
2016-02-08 21:48:49 -05:00
corey.hammerton
492e1057e0 puppetboard/app: Disabling CSRF protection globally.
I really did not want to resort to this but I could not find any answers
from previously asked questions on the subject. The template is properly
creating the csrf_token hidden field which is being submitted to the server,
but I could not figure out why it was not using it it.

This fixes https://github.com/voxpupuli/puppetboard/issues/198

This will not be permanent, will have to look into upgrading the flask-wtf
and WTForms packages to the latest versions.
2016-02-06 18:55:45 -05:00
Corey Hammerton
65c6251bac Merge pull request #214 from corey-hammerton/issue-213
templates/index: Directly referencing config.REFRESH_RATE
2016-02-01 20:44:24 -05:00