Class: TrainPlugins::PuppetDBInterface::Connection
- Inherits:
-
Train::Plugins::Transport::BaseConnection
- Object
- Train::Plugins::Transport::BaseConnection
- TrainPlugins::PuppetDBInterface::Connection
- Includes:
- Platform
- Defined in:
- lib/train-puppetdb/connection.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ Connection
constructor
A new instance of Connection.
- #local? ⇒ Boolean
- #puppetdb_client ⇒ Object
- #uri ⇒ Object
Methods included from Platform
Constructor Details
#initialize(options) ⇒ Connection
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/train-puppetdb/connection.rb', line 9 def initialize() if .nil? || [:server].nil? raise Train::TransportError, "You must set a PuppetDB server." end super() @tmp_dir = Dir.mktmpdir # Check if target is reachable begin @client = PuppetDB::Client.new({ :server => [:server], :pem => { 'key' => sanitize_cert("key", [:key]), 'cert' => sanitize_cert("cert", [:cert]), 'ca_file' => sanitize_cert("ca", [:cacert]), } }) @client.request('nodes', [:'~', 'certname', '.*'], {:limit => 1}) rescue => e raise Train::TransportError, e.response end end |
Instance Method Details
#local? ⇒ Boolean
35 36 37 |
# File 'lib/train-puppetdb/connection.rb', line 35 def local? false end |
#puppetdb_client ⇒ Object
43 44 45 |
# File 'lib/train-puppetdb/connection.rb', line 43 def puppetdb_client @client end |
#uri ⇒ Object
39 40 41 |
# File 'lib/train-puppetdb/connection.rb', line 39 def uri 'puppetdb://' end |