lib/yun/model/ssh.rb in yun-0.0.5 vs lib/yun/model/ssh.rb in yun-0.0.6
- old
+ new
@@ -2,18 +2,30 @@
require 'net/scp'
module Yun
class Ssh
+ attr_accessor :executor
+
def initialize host, ssh_config
@host = host
@ssh_config = ssh_config
+ self.executor = Yun::CommandExecutor.new
end
def connect
ssh_command = "ssh -i #{key_file} #{user}@#{@host}"
puts ssh_command
- exec ssh_command
+ executor.sys_exec ssh_command
+ end
+
+ def is_ssh_ready?
+ tcp_socket = TCPSocket.new(@host, 22)
+ IO.select([tcp_socket], nil, nil, 10)
+ rescue Exception
+ false
+ ensure
+ tcp_socket && tcp_socket.close
end
def chef role
Net::SSH.start(@host, user, :keys => [key_file]) do |ssh|
puts "packaging chef repo"