puppetdb_foreman 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48759390553b86a6fc48221336d87d82ba8709cf
4
- data.tar.gz: ab85080bdfd95fc4695b74fd2c249fc17a952008
3
+ metadata.gz: 1142db9229ad1c8bac8c3c5a19587953049fc273
4
+ data.tar.gz: a86d737820c3bf8d943e05950542b35a87297fa4
5
5
  SHA512:
6
- metadata.gz: 4412889fa8bd32783a15f367ee0283f7a88be4418f14e919ff93932caa982b4db2e3ae664c94bc3322c4bd25a486a60b3e06e15eeebc8eeddad39cdc817c3570
7
- data.tar.gz: 0c330cf7fb392595a319825456e7c5920f3953c40b704dd3c7dd575d686e162b5ea21cb3c07dcdaac258e11efb1ae7ea6a1a8521729ab17052e121cc4be0489e
6
+ metadata.gz: ed22d996b91c1654132baa44a0c09c63614e159d2c65bf44b991e3a61dc22545eb27927fc65e631d5eb145056a2a98e097543f92bc308051ef17b0cc4880c5bc
7
+ data.tar.gz: 035013ec2eef2701caaf1fae461bcc669dc5c2c7eac02181764dadebebb5bb282d2dee403ec80582120548ebfe9234555f067994dca648ebe05ac67f393fd33a
@@ -0,0 +1,25 @@
1
+ module PuppetdbForeman
2
+ class PuppetdbController < ApplicationController
3
+
4
+ def index
5
+ begin
6
+ uri = URI.parse(Setting[:puppetdb_dashboard_address])
7
+ puppetdb_url, layout = case params[:puppetdb]
8
+ when 'd3.v2', 'charts' then ["#{uri.path}#{request.original_fullpath}", false]
9
+ when 'v3' then [request.original_fullpath, false]
10
+ else ["#{uri.path}/index.html", true]
11
+ end
12
+ result = Net::HTTP.get_response(uri.host, puppetdb_url, uri.port)
13
+ render :text => result.body, :layout => layout
14
+ rescue SocketError => error
15
+ render :action => :error, :layout => true
16
+ end
17
+ end
18
+
19
+ # Override from application controller to fix issue
20
+ def api_request?
21
+ request.format && (request.format.json? || request.format.yaml?)
22
+ end
23
+
24
+ end
25
+ end
@@ -5,10 +5,12 @@ class Setting::Puppetdb < ::Setting
5
5
  if SETTINGS[:puppetdb].present?
6
6
  default_enabled = SETTINGS[:puppetdb][:enabled]
7
7
  default_address = SETTINGS[:puppetdb][:address]
8
+ default_dashboard_address = SETTINGS[:puppetdb][:dashboard_address]
8
9
  end
9
10
 
10
11
  default_enabled = false if default_enabled.nil?
11
12
  default_address ||= 'https://puppetdb:8081/v2/commands'
13
+ default_dashboard_address ||= 'http://puppetdb:8080/dashboard'
12
14
 
13
15
  Setting.transaction do
14
16
  [
@@ -21,5 +23,11 @@ class Setting::Puppetdb < ::Setting
21
23
  self.set('puppetdb_address', _('Foreman will send PuppetDB requests to this address'), default_address)
22
24
  ].compact.each { |s| self.create s.update(:category => 'Setting::Puppetdb')}
23
25
  end
26
+
27
+ Setting.transaction do
28
+ [
29
+ self.set('puppetdb_dashboard_address', _('Foreman will proxy PuppetDB Performance Dashboard requests to this address'), default_dashboard_address)
30
+ ].compact.each { |s| self.create s.update(:category => 'Setting::Puppetdb')}
31
+ end
24
32
  end
25
33
  end
@@ -0,0 +1,4 @@
1
+ <div class="alert alert-block alert-warning">
2
+ <p><strong><%= _("Notice") %></strong> <%= _("Error Proxying PuppetDB Dashboard") %></p>
3
+ <p><%= _("Maybe you need to set") %> <%= link_to(_("puppetdb_dashboard_address"), settings_path(:search => 'puppetdb_dashboard_address')) %> <%= _("in Settings") %></p>
4
+ </div>
@@ -23,6 +23,14 @@ module PuppetdbForeman
23
23
  initializer 'puppetdb_foreman.register_plugin', :after=> :finisher_hook do |app|
24
24
  Foreman::Plugin.register :puppetdb_foreman do
25
25
  requires_foreman '> 1.0'
26
+ security_block :puppetdb_foreman do
27
+ permission :view_puppetdb_dashboard, {:'puppetdb_foreman/puppetdb' => [:index]}
28
+ end
29
+ role 'PuppetDB Dashboard', [:view_puppetdb_dashboard]
30
+ menu :top_menu, :puppetdb, :caption => N_('PuppetDB Dashboard'),
31
+ :url_hash => {:controller => 'puppetdb_foreman/puppetdb', :action => 'index', :puppetdb => 'puppetdb'},
32
+ :parent => :monitor_menu,
33
+ :last => true
26
34
  end
27
35
  end
28
36
 
metadata CHANGED
@@ -1,25 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppetdb_foreman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Lobato Garcia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-02 00:00:00.000000000 Z
11
+ date: 2014-10-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Disable hosts on puppetdb after they are deleted or built in Foreman.
14
- Follow https://github.com/theforeman/puppetdb_foreman and raise an issue/submit
15
- a pull request if you need extra functionality
13
+ description: 'Disable hosts on PuppetDB after they are deleted or built in Foreman,
14
+ and proxy the PuppetDB dashboard to Foreman. Follow https://github.com/theforeman/puppetdb_foreman
15
+ and raise an issue/submit a pull request if you need extra functionality. You can
16
+ also find some help in #theforeman IRC channel on Freenode.'
16
17
  email: elobatocs@gmail.com
17
18
  executables: []
18
19
  extensions: []
19
20
  extra_rdoc_files: []
20
21
  files:
22
+ - app/controllers/puppetdb_foreman/puppetdb_controller.rb
21
23
  - app/models/puppetdb_foreman/host_extensions.rb
22
24
  - app/models/setting/puppetdb.rb
25
+ - app/views/puppetdb_foreman/puppetdb/error.html.erb
23
26
  - lib/puppetdb_foreman.rb
24
27
  - lib/puppetdb_foreman/engine.rb
25
28
  homepage: http://www.github.com/theforeman/puppetdb_foreman
@@ -45,5 +48,6 @@ rubyforge_project:
45
48
  rubygems_version: 2.2.2
46
49
  signing_key:
47
50
  specification_version: 4
48
- summary: This is a foreman plugin to interact with puppetdb through callbacks.
51
+ summary: This is a Foreman plugin to interact with PuppetDB.
49
52
  test_files: []
53
+ has_rdoc: