34: def update_dns(rset)
35: raise NoMachines if rset.boxes.empty?
36: rset.boxes.each do |rbox|
37: mach = rbox.stash
38:
39: if !mach.address.nil? && !mach.address.empty?
40: begin
41:
42: if Rudy::AWS::EC2::Addresses.exists?(mach.address)
43: li "Associating #{mach.address} to #{mach.instid}"
44: Rudy::AWS::EC2::Addresses.associate(mach.address, mach.instid)
45: else
46: le "Unknown address: #{mach.address}"
47: end
48: rescue => ex
49: le "Error associating address: #{ex.message}"
50: ld ex.backtrace
51: end
52: end
53:
54:
55: msg = "Waiting for public DNS on #{rbox.nickname} ..."
56: multi = rbox.stash.windows? ? 3 : 2
57: interval, max = 2*multi, 60*multi
58: Rudy::Utils.waiter(interval, max, STDOUT, msg, 0) {
59: mach.refresh!
60: if mach.address
61: mach.dns_public.to_s =~ /#{mach.address.to_s.gsub('.', '-')}/
62: else
63: !mach.dns_public.nil? && !mach.dns_public.empty?
64: end
65: }
66: rbox.host = mach.dns_public
67: end
68: end