Method: TestLab::Node::SSH#container_ssh

Defined in:
lib/testlab/node/ssh.rb

#container_ssh(container, options = {}) ⇒ ZTK::SSH

Container SSH Connection

Returns:

  • (ZTK::SSH)

    Returns a new or cached ZTK::SSH object for the container.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/testlab/node/ssh.rb', line 26

def container_ssh(container, options={})
  name = container.id
  @container_ssh ||= Hash.new
  if @container_ssh[name].nil?
    @container_ssh[name] ||= ZTK::SSH.new({:ui => @ui, :timeout => 3600, :silence => true}.merge(options))
    @container_ssh[name].config do |c|
      c.proxy_host_name = @provider.ip
      c.proxy_port      = @provider.port
      c.proxy_user      = @provider.user
      c.proxy_keys      = @provider.identity

      c.host_name       = container.ip

      c.user            = (options[:user]   || container.primary_user.username)
      c.password        = (options[:passwd] || container.primary_user.password)
      c.keys            = (options[:keys]   || [container.primary_user.identity, @provider.identity].flatten.compact)
    end
  end
  @container_ssh[name]
end