Merge pull request #164 from raphink/v4-api

Make Puppetboard work with the PuppetDB V4 api

This PR just enables the basic functionality of PuppetBoard with the new PyPuppetDB version. https://github.com/puppet-community/puppetboard/pull/176 includes this work as well as other work to make better utilization of the new library
This commit is contained in:
Corey Hammerton
2015-10-26 22:11:40 -04:00
3 changed files with 6 additions and 7 deletions

View File

@@ -37,7 +37,6 @@ app.secret_key = app.config['SECRET_KEY']
app.jinja_env.filters['jsonprint'] = jsonprint app.jinja_env.filters['jsonprint'] = jsonprint
puppetdb = connect( puppetdb = connect(
api_version=3,
host=app.config['PUPPETDB_HOST'], host=app.config['PUPPETDB_HOST'],
port=app.config['PUPPETDB_PORT'], port=app.config['PUPPETDB_PORT'],
ssl_verify=app.config['PUPPETDB_SSL_VERIFY'], ssl_verify=app.config['PUPPETDB_SSL_VERIFY'],
@@ -102,7 +101,7 @@ def index():
""" """
# TODO: Would be great if we could parallelize this somehow, doing these # TODO: Would be great if we could parallelize this somehow, doing these
# requests in sequence is rather pointless. # requests in sequence is rather pointless.
prefix = 'com.puppetlabs.puppetdb.query.population' prefix = 'puppetlabs.puppetdb.query.population'
num_nodes = get_or_abort( num_nodes = get_or_abort(
puppetdb.metric, puppetdb.metric,
"{0}{1}".format(prefix, ':type=default,name=num-nodes')) "{0}{1}".format(prefix, ':type=default,name=num-nodes'))
@@ -272,7 +271,7 @@ def reports_node(node_name):
a table displaying those reports.""" a table displaying those reports."""
reports = limit_reports( reports = limit_reports(
yield_or_stop( yield_or_stop(
puppetdb.reports('["=", "certname", "{0}"]'.format(node_name))), puppetdb.reports(query='["=", "certname", "{0}"]'.format(node_name))),
app.config['REPORTS_COUNT']) app.config['REPORTS_COUNT'])
return render_template( return render_template(
'reports_node.html', 'reports_node.html',
@@ -307,11 +306,11 @@ def report(node_name, report_id):
configuration_version. This allows for better integration configuration_version. This allows for better integration
into puppet-hipchat. into puppet-hipchat.
""" """
reports = puppetdb.reports('["=", "certname", "{0}"]'.format(node_name)) reports = puppetdb.reports(query='["=", "certname", "{0}"]'.format(node_name))
for report in reports: for report in reports:
if report.hash_ == report_id or report.version == report_id: if report.hash_ == report_id or report.version == report_id:
events = puppetdb.events('["=", "report", "{0}"]'.format( events = puppetdb.events(query='["=", "report", "{0}"]'.format(
report.hash_)) report.hash_))
return render_template( return render_template(
'report.html', 'report.html',

View File

@@ -5,5 +5,5 @@ MarkupSafe==0.19
WTForms==1.0.5 WTForms==1.0.5
Werkzeug==0.9.4 Werkzeug==0.9.4
itsdangerous==0.23 itsdangerous==0.23
pypuppetdb==0.1.1 pypuppetdb==0.2.0
requests==2.2.1 requests==2.2.1

View File

@@ -32,7 +32,7 @@ setup(
"Flask >= 0.10.1", "Flask >= 0.10.1",
"Flask-WTF >= 0.9.4, <= 0.9.5", "Flask-WTF >= 0.9.4, <= 0.9.5",
"WTForms < 2.0", "WTForms < 2.0",
"pypuppetdb >= 0.1.0, < 0.2.0", "pypuppetdb >= 0.2.0, < 0.3.0",
], ],
keywords="puppet puppetdb puppetboard", keywords="puppet puppetdb puppetboard",
classifiers=[ classifiers=[