Method: KnifeCloudstack::CsServerCreate#is_ssh_open?
- Defined in:
- lib/chef/knife/cs_server_create.rb
#is_ssh_open?(ip) ⇒ Boolean
noinspection RubyArgCount,RubyResolve
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/chef/knife/cs_server_create.rb', line 281 def is_ssh_open?(ip) s = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0) sa = Socket.sockaddr_in(22, ip) begin s.connect_nonblock(sa) rescue Errno::EINPROGRESS resp = IO.select(nil, [s], nil, 1) if resp.nil? sleep SSH_POLL_INTERVAL return false end begin s.connect_nonblock(sa) rescue Errno::EISCONN Chef::Log.debug("sshd accepting connections on #{ip}") yield return true rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH sleep SSH_POLL_INTERVAL return false end ensure s && s.close end end |