SSH.up? actually times out properly now

This commit is contained in:
Mitchell Hashimoto 2010-03-08 19:17:43 -08:00
parent 2f7de333ec
commit 1139ec9e0c
1 changed files with 11 additions and 5 deletions

View File

@ -26,13 +26,19 @@ module Vagrant
end end
def up? def up?
Net::SSH.start(Vagrant.config.ssh.host, Vagrant.config.ssh.username, :port => port, :password => Vagrant.config.ssh.password, :timeout => 5) do |ssh| check_thread = Thread.new do
return true begin
Thread.current[:result] = false
Net::SSH.start(Vagrant.config.ssh.host, Vagrant.config.ssh.username, :port => port, :password => Vagrant.config.ssh.password, :timeout => 5) do |ssh|
Thread.current[:result] = true
end
rescue Errno::ECONNREFUSED, Net::SSH::Disconnect
# False, its defaulted above
end
end end
false check_thread.join(5)
rescue Errno::ECONNREFUSED, Net::SSH::Disconnect return check_thread[:result]
false
end end
def port(opts={}) def port(opts={})