class Tunneler::SshTunnel::Remote

Constants

ACCEPTABLE_CONNECTIVITY_ERRORS
SSH_READY_TIMEOUT

Public Class Methods

new(gateway, user, host, options={}) click to toggle source
Calls superclass method Tunneler::Ssh::new
# File lib/tunneler/ssh_tunnel.rb, line 59
def initialize(gateway, user, host, options={})
  @gateway = gateway
  super(user, host, options)
end

Public Instance Methods

gateway_reconnect() click to toggle source
# File lib/tunneler/ssh_tunnel.rb, line 78
def gateway_reconnect
  @gateway = @gateway.reconnect
end
scp(local_path, remote_path) click to toggle source
# File lib/tunneler/ssh_tunnel.rb, line 95
def scp(local_path, remote_path)
  @gateway.ssh(@host, @user, @options) do |ssh|
    ssh.scp.upload!(local_path, remote_path, SCP_OPTIONS)
  end
end
ssh(command, options_override={}) click to toggle source
# File lib/tunneler/ssh_tunnel.rb, line 82
def ssh(command, options_override={})
  if options_override.empty?
    options = @options
  else
    options = options_override
  end
  output = ""
  @gateway.ssh(@host, @user, @options) do |ssh|
    output = ssh.exec!(command)
  end
  output
end
sshable?() click to toggle source
# File lib/tunneler/ssh_tunnel.rb, line 64
def sshable?
  begin
    gateway_reconnect
    return test_connectivity
  rescue Exception => e
    if ACCEPTABLE_CONNECTIVITY_ERRORS.include?(e.class)
      Tunneler.log "Connectivity error: #{e.class} - #{e.message}", :debug
      return false
    else
      raise e
    end
  end
end