Class: Bcome::Ssh::Driver

Inherits:
Object
  • Object
show all
Includes:
DriverCommandStrings, DriverConnection, DriverFunctions, DriverUser
Defined in:
lib/objects/ssh/driver.rb

Constant Summary

Constants included from DriverConnection

Bcome::Ssh::DriverConnection::DEFAULT_TIMEOUT_IN_SECONDS

Instance Attribute Summary collapse

Attributes included from DriverConnection

#connection

Instance Method Summary collapse

Methods included from DriverCommandStrings

#local_port_forward_command, #rsync_command, #ssh_command

Methods included from DriverUser

#fallback_bastion_host_user, #fallback_local_user, #get_overriden_local_user, #overriden_local_user, #user

Methods included from DriverFunctions

#do_ssh, #get, #local_port_forward, #ping, #put, #put_str, #rsync, #scp

Methods included from DriverConnection

#close_ssh_connection, #has_open_ssh_con?, #net_ssh_params, #node_host_or_ip, #proxy, #ssh_connect!, #ssh_connection, #timeout_in_seconds

Constructor Details

#initialize(config, context_node) ⇒ Driver

Returns a new instance of Driver.



14
15
16
17
# File 'lib/objects/ssh/driver.rb', line 14

def initialize(config, context_node)
  @config = config
  @context_node = context_node
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/objects/ssh/driver.rb', line 7

def config
  @config
end

#context_nodeObject (readonly)

Returns the value of attribute context_node.



7
8
9
# File 'lib/objects/ssh/driver.rb', line 7

def context_node
  @context_node
end

Instance Method Details

#connection_wranglerObject



19
20
21
# File 'lib/objects/ssh/driver.rb', line 19

def connection_wrangler
  @connection_wrangler ||= set_connection_wrangler
end

#has_multi_hop_proxy?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/objects/ssh/driver.rb', line 54

def has_multi_hop_proxy?
  !multi_hop_proxy_config.nil?
end

#has_proxy?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/objects/ssh/driver.rb', line 58

def has_proxy?
  return connection_wrangler.has_hop?
end

#multi_hop_proxy_configObject



50
51
52
# File 'lib/objects/ssh/driver.rb', line 50

def multi_hop_proxy_config
  @config[:multi_hop_proxy]
end

#pretty_ssh_configObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/objects/ssh/driver.rb', line 31

def pretty_ssh_config
  config = {
    user: user,
    timeout: timeout_in_seconds
  }

  if has_proxy?
    config[:proxy] = connection_wrangler.proxy_details
  else
    config[:host_or_ip] = node_host_or_ip
  end

  config
end

#proxy_chainObject



23
24
25
# File 'lib/objects/ssh/driver.rb', line 23

def proxy_chain
  @proxy_chain ||= ::Bcome::Ssh::ProxyChain.new(connection_wrangler)
end

#proxy_config_valueObject



46
47
48
# File 'lib/objects/ssh/driver.rb', line 46

def proxy_config_value
  @config[:proxy]
end

#set_connection_wranglerObject



27
28
29
# File 'lib/objects/ssh/driver.rb', line 27

def set_connection_wrangler
  @connection_wrangler = ::Bcome::Ssh::ConnectionWrangler.new(self)
end