Sha256: de0f8cc52bce2dc8f8c4ee04a28691747caf32f0244a03b382e0ffa660bf5cfd
Contents?: true
Size: 700 Bytes
Versions: 3
Compression:
Stored size: 700 Bytes
Contents
require 'net/ssh' module AmiSpec class WaitForSSH def self.wait(ip_address, user, key, max_retries) last_error = nil retries = 0 while retries < max_retries begin Net::SSH.start(ip_address, user, keys: [key], :verify_host_key => :never) { |ssh| ssh.exec 'echo boo!' } rescue Errno::ETIMEDOUT, Errno::ECONNREFUSED, Timeout::Error => error last_error = error sleep 1 else break end retries = retries + 1 end if retries > max_retries - 1 raise AmiSpec::InstanceConnectionTimeout.new("Timed out waiting for SSH to become available: #{last_error}") end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ami_spec-1.6.0 | lib/ami_spec/wait_for_ssh.rb |
ami_spec-1.5.0 | lib/ami_spec/wait_for_ssh.rb |
ami_spec-1.4.0 | lib/ami_spec/wait_for_ssh.rb |