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 |
# 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() # Check if target is reachable begin @client = PuppetDB::Client.new({ :server => [:server], :pem => { 'key' => [:key], 'cert' => [:cert], 'ca_file' => [:cacert], } }) @client.request('nodes', [:'~', 'certname', '.*'], {:limit => 1}) rescue => e raise Train::TransportError, e.response end end |
Instance Method Details
#local? ⇒ Boolean
33 34 35 |
# File 'lib/train-puppetdb/connection.rb', line 33 def local? false end |
#puppetdb_client ⇒ Object
41 42 43 |
# File 'lib/train-puppetdb/connection.rb', line 41 def puppetdb_client @client end |
#uri ⇒ Object
37 38 39 |
# File 'lib/train-puppetdb/connection.rb', line 37 def uri 'puppetdb://' end |