Class: Services::Connection

Inherits:
Object
  • Object
show all
Includes:
Chef::DSL::DataQuery, Chef::Mixin::Language
Defined in:
lib/services/connection.rb

Overview

Setup ETCD connection via chef or plain host Also stores that aconnection in Services.connection Most other classes require this to be setup

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Connection

Initialize etcd client

You should pass either a run_context or explicit host/port arguments the run_context will take prescedence

Parameters:

  • options (Hash)
  • args (Hash)

    a customizable set of options

Options Hash (args):

  • :run_context (Chef::RunContext) — default: nil

    The chef run context to find things in

  • :host (String) — default: nil

    The host address to connect too

  • :port (String) — default: 4001

    The etcd port to connect too



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/services/connection.rb', line 31

def initialize(args)
  @run_context = args.fetch(:run_context, nil)
  Services.run_context = args[:run_context]
  @node = args[:run_context].node if run_context
  @host = args[:host]
  @port = args[:port] || 4001
  @redirect = args[:redirect] || true
  @ssl_verify = args[:verify] || OpenSSL::SSL::VERIFY_NONE

  validate
  load_gem
  Services.connection = get_connection(find_servers)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



10
11
12
# File 'lib/services/connection.rb', line 10

def client
  @client
end

#hostObject (readonly)

Returns the value of attribute host.



10
11
12
# File 'lib/services/connection.rb', line 10

def host
  @host
end

#nodeObject (readonly)

Returns the value of attribute node.



10
11
12
# File 'lib/services/connection.rb', line 10

def node
  @node
end

#portObject (readonly)

Returns the value of attribute port.



10
11
12
# File 'lib/services/connection.rb', line 10

def port
  @port
end

#run_contextObject (readonly)

Returns the value of attribute run_context.



10
11
12
# File 'lib/services/connection.rb', line 10

def run_context
  @run_context
end

#ssl_verifyObject (readonly)

Returns the value of attribute ssl_verify.



10
11
12
# File 'lib/services/connection.rb', line 10

def ssl_verify
  @ssl_verify
end