Module: Dployr::Compute::Common

Included in:
AWS, BAREMETAL, GCE
Defined in:
lib/dployr/compute/common.rb

Class Method Summary collapse

Class Method Details

.wait_ssh(attrs, server, use_public_ip) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dployr/compute/common.rb', line 9

def wait_ssh(attrs, server, use_public_ip)
  if use_public_ip
    @ip = server.public_ip_address
  else
    @ip = server.private_ip_address
  end
  print "Wait for ssh (#{@ip}) to get ready...".yellow

  while true
    begin
      Net::SSH.start(@ip, attrs["username"], :keys => attrs["private_key_path"]) do |ssh|
        print "\n"
        return @ip
      end
    rescue Exception => e
      print ".".yellow
      sleep 2
    end
  end
  print "\n"
end