Class: AMI::SSH
- Inherits:
-
Object
- Object
- AMI::SSH
- Defined in:
- lib/ami/ssh.rb
Class Method Summary collapse
Class Method Details
.create_connection(server, user) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ami/ssh.rb', line 5 def self.create_connection(server, user) retries = 5 begin ssh = Gofer::Host.new(server.dns_name, user, :timeout => 30) ssh.ls '/' # force gofer to connect to the host return ssh rescue Errno::ECONNREFUSED, Timeout::Error, Errno::EHOSTUNREACH retries -= 1 if retries > 0 warn "connection attempt failed, #{retries} retries remaining" sleep 1 retry else raise end end end |