Class: UltraDNSUpdater::Strategies::Ec2

Inherits:
UpdateStrategy show all
Defined in:
lib/ultradns_updater/strategies/ec2.rb

Instance Method Summary collapse

Methods inherited from UpdateStrategy

#iface_ip, #initialize, #strategy_config, #strategy_to_use, #ultradns

Methods included from Preconditions

#not_empty, #precondition

Constructor Details

This class inherits a constructor from UltraDNSUpdater::Strategies::UpdateStrategy

Instance Method Details

#updateObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ultradns_updater/strategies/ec2.rb', line 18

def update()
  ec2 = UltraDNSUpdater::Ec2.new(strategy_config)
  name_tag_value = ec2.get_name_tag

  result = false
  if ec2.get_instance_public_hostname != ''
    result = ultradns.create_or_update_cname(name_tag_value, ec2.get_instance_public_hostname)
  else
    ip = iface_ip(strategy_config)
    
    unless ip.nil?
      # try using an ip that reaches the internet
      result = ultradns.create_or_update_a(name_tag_value, ip)
    end
  end
  
  result ? name_tag_value : nil
end