Class: UltraDNSUpdater::Strategies::UpdateStrategy

Inherits:
Object
  • Object
show all
Includes:
Preconditions
Defined in:
lib/ultradns_updater/strategies/update_strategy.rb

Overview

Copyright 2012 NeuStar, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Direct Known Subclasses

Configured, Ec2, Multiple, Openstack

Instance Method Summary collapse

Methods included from Preconditions

#not_empty, #precondition

Constructor Details

#initialize(ultradns, strategy_section, logger = ::Logger.new(STDOUT)) ⇒ UpdateStrategy

Returns a new instance of UpdateStrategy.



18
19
20
21
22
# File 'lib/ultradns_updater/strategies/update_strategy.rb', line 18

def initialize(ultradns, strategy_section, logger = ::Logger.new(STDOUT))
  @ultradns = ultradns
  @strategy_section = strategy_section
  @logger = logger
end

Instance Method Details

#iface_ip(strategy_config) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/ultradns_updater/strategies/update_strategy.rb', line 40

def iface_ip(strategy_config)
  ip = nil
  if strategy_config[:iface] == 'auto'
    ip = UltraDNSUpdater::IpInfo.local_ipv4
  else
    ip = UltraDNSUpdater::IpInfo.ipv4_for_iface(strategy_config[:iface])
  end
  ip
end

#strategy_configObject



36
37
38
# File 'lib/ultradns_updater/strategies/update_strategy.rb', line 36

def strategy_config
  @strategy_section[strategy_to_use.to_sym].merge({:logger => @logger}) rescue nil
end

#strategy_to_useObject



32
33
34
# File 'lib/ultradns_updater/strategies/update_strategy.rb', line 32

def strategy_to_use
  @strategy_section[:use]
end

#ultradnsObject



28
29
30
# File 'lib/ultradns_updater/strategies/update_strategy.rb', line 28

def ultradns
  @ultradns
end

#updateObject

update ultradns based on the configuration provided returns: the hostname applied or else nil



26
# File 'lib/ultradns_updater/strategies/update_strategy.rb', line 26

def update(); end