Module: TestLab::Node::SSH
- Included in:
- TestLab::Node
- Defined in:
- lib/testlab/node/ssh.rb
Instance Method Summary collapse
-
#container_ssh(container, options = {}) ⇒ ZTK::SSH
Container SSH Connection.
-
#ssh(options = {}) ⇒ ZTK::SSH
Node SSH Connection.
-
#ssh_shutdown! ⇒ Boolean
Shutdown all SSH connections.
Instance Method Details
#container_ssh(container, options = {}) ⇒ ZTK::SSH
Container SSH Connection
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, ={}) 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()) @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 = ([:user] || container.primary_user.username) c.password = ([:passwd] || container.primary_user.password) c.keys = ([:keys] || [container.primary_user.identity, @provider.identity].flatten.compact) end end @container_ssh[name] end |
#ssh(options = {}) ⇒ ZTK::SSH
Node SSH Connection
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/testlab/node/ssh.rb', line 9 def ssh(={}) if (!defined?(@ssh) || @ssh.nil?) @ssh ||= ZTK::SSH.new({:ui => @ui, :timeout => 3600, :silence => true}.merge()) @ssh.config do |c| c.host_name = @provider.ip c.port = @provider.port c.user = @provider.user c.keys = [@provider.identity].flatten.compact end end @ssh end |
#ssh_shutdown! ⇒ Boolean
Shutdown all SSH connections
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/testlab/node/ssh.rb', line 50 def ssh_shutdown! @ssh.nil? or @ssh.close @ssh = nil @container_ssh.nil? or @container_ssh.each do |name, ssh| ssh.nil? or ssh.close end @container_ssh = nil true end |