Module: PuppetRestClient::DB

Extended by:
Config
Defined in:
lib/puppet-rest.rb,
lib/puppet-rest/db/client.rb,
lib/puppet-rest/db/config.rb,
lib/puppet-rest/db/request.rb,
lib/puppet-rest/db/connection.rb,
lib/puppet-rest/db/entities/base.rb,
lib/puppet-rest/db/entities/fact.rb,
lib/puppet-rest/db/entities/node.rb,
lib/puppet-rest/db/connection/facts.rb,
lib/puppet-rest/db/connection/nodes.rb,
lib/puppet-rest/db/entities/resource.rb,
lib/puppet-rest/db/connection/resources.rb,
lib/puppet-rest/db/connection/fact-names.rb

Defined Under Namespace

Modules: Config, Request Classes: Base, Connection, Fact, Node, Resource

Constant Summary

Constants included from Config

Config::DEFAULT_API_VERSION, Config::DEFAULT_CLIENT_KEY, Config::DEFAULT_CLIENT_NAME, Config::DEFAULT_CONNECTION_OPTIONS, Config::DEFAULT_MIDDLEWARE, Config::DEFAULT_SERVER_URL, Config::DEFAULT_USER_AGENT, Config::VALID_OPTIONS_KEYS

Class Method Summary collapse

Methods included from Config

extended, options, reset, setup

Class Method Details

.method_missing(method, *args, &block) ⇒ Object

Delegate methods to PuppetRestClient::Connection



13
14
15
16
# File 'lib/puppet-rest/db/client.rb', line 13

def method_missing(method, *args, &block)
  return super unless new.respond_to?(method)
  new.send(method, *args, &block)
end

.new(options = Mash.new) ⇒ Object

Convenience alias for PuppetRestClient::DB::Connection.new

return [PuppetRestClient::DB::Connection]



8
9
10
# File 'lib/puppet-rest/db/client.rb', line 8

def new(options=Mash.new)
  PuppetRestClient::DB::Connection.new(options)
end

.read_key_file(path) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/puppet-rest/db/client.rb', line 22

def read_key_file(path)
  key_file_path = File.expand_path(path)

  begin
    raw_key = File.read(key_file_path).strip
  rescue SystemCallError, IOError => e
    raise IOError, "Unable to read #{key_file_path}"
  end

  begin_rsa = '-----BEGIN RSA PRIVATE KEY-----'
  end_rsa   = '-----END RSA PRIVATE KEY-----'

  unless (raw_key =~ /\A#{begin_rsa}$/) && (raw_key =~ /^#{end_rsa}\Z/)
    msg = "The file #{key_file_path} is not a properly formatted private key.\n"
    msg << "It must contain '#{begin_rsa}' and '#{end_rsa}'"
    raise ArgumentError, msg
  end
  return OpenSSL::PKey::RSA.new(raw_key)
end

.respond_to?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/puppet-rest/db/client.rb', line 18

def respond_to?(method, include_private=false)
  new.respond_to?(method, include_private) || super(method, include_private)
end