Sha256: 061d202293211be9e4929b8f477c1a7b2de61f603d81f0d81c2c1ac6779647ef
Contents?: true
Size: 689 Bytes
Versions: 7
Compression:
Stored size: 689 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], paranoid: false) { |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
7 entries across 7 versions & 1 rubygems