Sha256: d02dd710ae39854bbf205d991dbb72c231d96ec61c33ba34eccc7f33e49d15a2

Contents?: true

Size: 1.35 KB

Versions: 4

Compression:

Stored size: 1.35 KB

Contents

class TestLab
  class Node

    module SSH

      # SSH to the Node
      def ssh(options={})
        if (!defined?(@ssh) || @ssh.nil?)
          @ssh ||= ZTK::SSH.new({:ui => @ui, :timeout => 1200, :silence => true}.merge(options))
          @ssh.config do |c|
            c.host_name = @provider.ip
            c.port      = @provider.port
            c.user      = @provider.user
            c.keys      = @provider.identity
          end
        end
        @ssh
      end

      # SSH to a container running on the Node
      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 => 1200, :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.user)
            c.password        = (options[:passwd] || container.passwd)
            c.keys            = (options[:keys]   || container.keys || @provider.identity)
          end
        end
        @container_ssh[name]
      end

    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
testlab-0.4.16 lib/testlab/node/ssh.rb
testlab-0.4.15 lib/testlab/node/ssh.rb
testlab-0.4.14 lib/testlab/node/ssh.rb
testlab-0.4.13 lib/testlab/node/ssh.rb