lib/vagrant/ssh.rb in vagrant-0.1.1 vs lib/vagrant/ssh.rb in vagrant-0.1.2
- old
+ new
@@ -24,16 +24,22 @@
scp.upload!(from, to)
end
end
def up?
- Net::SSH.start(Vagrant.config.ssh.host, Vagrant.config.ssh.username, :port => port, :password => Vagrant.config.ssh.password, :timeout => 5) do |ssh|
- return true
+ check_thread = Thread.new do
+ begin
+ Thread.current[:result] = false
+ Net::SSH.start(Vagrant.config.ssh.host, Vagrant.config.ssh.username, :port => port, :password => Vagrant.config.ssh.password, :timeout => Vagrant.config.ssh.timeout) do |ssh|
+ Thread.current[:result] = true
+ end
+ rescue Errno::ECONNREFUSED, Net::SSH::Disconnect
+ # False, its defaulted above
+ end
end
- false
- rescue Errno::ECONNREFUSED, Net::SSH::Disconnect
- false
+ check_thread.join(Vagrant.config.ssh.timeout)
+ return check_thread[:result]
end
def port(opts={})
opts[:port] || Vagrant.config.vm.forwarded_ports[Vagrant.config.ssh.forwarded_port_key][:hostport]
end