Sha256: 5f592d24b2eb6e595b1127cedcf4050189b18c6bf1141c629209a94949fbdb33
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
require 'net/ssh' require 'net/ssh/gateway' class Aerosol::Connection include Dockly::Util::DSL include Dockly::Util::Logger::Mixin logger_prefix '[aerosol connection]' dsl_attribute :user, :host, :jump def with_connection(overridden_host=nil, &block) actual_host = overridden_host || host unless actual_host.is_a?(String) actual_host = (actual_host.public_hostname || actual_host.private_ip_address) end if jump info "connecting to gateway #{jump[:user] || user}@#{jump[:host]}" gateway = nil Timeout.timeout(20) do gateway = Net::SSH::Gateway.new(jump[:host], jump[:user] || user, :forward_agent => true) end begin info "connecting to #{user}@#{actual_host} through gateway" gateway.ssh(actual_host, user, &block) ensure info "shutting down gateway connection" gateway.shutdown! end else info "connecting to #{user}@#{actual_host}" Net::SSH.start(actual_host, user, &block) end rescue Timeout::Error => ex error "Timeout error #{ex.message}" error ex.backtrace.join("\n") end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
aerosol-0.5.1 | lib/aerosol/connection.rb |