ultradns_updater 0.0.21 → 0.0.22

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,9 +26,9 @@ module UltraDNSUpdater::Strategies
26
26
 
27
27
  def self.strategy(strategy_name)
28
28
  if strategy_name.kind_of?(Array)
29
- strategies = []
29
+ strategies = {}
30
30
  strategy_name.each do |strategy_item|
31
- strategies << strategy(strategy_item)
31
+ strategies[strategy_item] = strategy(strategy_item)
32
32
  end
33
33
  UltraDNSUpdater::Strategies::Multiple.factory(strategies)
34
34
  else
@@ -23,8 +23,9 @@ module UltraDNSUpdater::Strategies
23
23
  def initialize(ultradns, strategy_section, logger = ::Logger.new(STDOUT))
24
24
  super(ultradns, strategy_section, logger)
25
25
  @strategy_instances = []
26
- strategies.each do |strategy|
27
- @strategy_instances << strategy.new(ultradns, strategy_section, logger)
26
+ strategies.each do |strategy_name, strategy_clazz|
27
+ @strategy_instances << strategy_clazz.new(ultradns,
28
+ strategy_section.merge(:use => strategy_name), logger)
28
29
  end
29
30
  end
30
31
 
@@ -34,11 +35,12 @@ module UltraDNSUpdater::Strategies
34
35
  def update()
35
36
  @strategy_instances.each do |strategy|
36
37
  begin
37
- strategy_config[:logger].info("Trying strategy #{strategy.class.name}") if strategy_config[:logger]
38
+ @logger.info("Trying strategy #{strategy.class.name}") if @logger
38
39
  result = strategy.update()
39
40
  return result if result
40
- rescue
41
+ rescue => e
41
42
  # ignore, try next
43
+ @logger.debug("Failed: #{e.inspect}\n" + e.backtrace.join("\n"))
42
44
  end
43
45
  end
44
46
  nil
@@ -18,7 +18,7 @@ module UltraDNSUpdater::Strategies
18
18
  def update()
19
19
  opts = {:access_key_id => nil,
20
20
  :secret_access_key => nil,
21
- :logger => strategy_config()[:logger]
21
+ :logger => @logger
22
22
  }
23
23
  ec2 = UltraDNSUpdater::Ec2.new(opts)
24
24
 
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module UltraDNSUpdater
16
- VERSION = "0.0.21"
16
+ VERSION = "0.0.22"
17
17
  end
@@ -17,6 +17,13 @@ require 'fakeweb'
17
17
  require 'yaml'
18
18
 
19
19
  describe UltraDNSUpdater::IpInfo do
20
+ MOCK_DATA = %Q(en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
21
+ ether f8:1e:df:d8:8d:a4
22
+ inet6 fe80::fa1e:dfff:fed8:8da4%en1 prefixlen 64 scopeid 0x5
23
+ inet 192.168.1.2 netmask 0xffffff00 broadcast 192.168.1.255
24
+ media: autoselect
25
+ status: active
26
+ )
20
27
 
21
28
  it "should get an ipv4 address" do
22
29
  UltraDNSUpdater::IpInfo.local_ipv4().should_not == ''
@@ -29,17 +36,20 @@ describe UltraDNSUpdater::IpInfo do
29
36
  if RUBY_PLATFORM =~ /darwin/
30
37
  iface = "en0"
31
38
  end
32
-
39
+ UltraDNSUpdater::IpInfo.should_receive(:ifconfig).twice.with(iface).and_return(MOCK_DATA)
40
+
33
41
  UltraDNSUpdater::IpInfo.ipv4_for_iface(iface).should_not == ''
34
42
  UltraDNSUpdater::IpInfo.ipv4_for_iface(iface).should match(/\d+\.\d+\.\d+\.\d+/)
35
43
  end
36
44
 
37
45
  it "should get an ipv6 address from ifconfig" do
38
46
 
47
+
39
48
  iface = "eth0" # probably have eth0 on linux..
40
49
  if RUBY_PLATFORM =~ /darwin/
41
50
  iface = "en0"
42
- end
51
+ end
52
+ UltraDNSUpdater::IpInfo.should_receive(:ifconfig).twice.with(iface).and_return(MOCK_DATA)
43
53
 
44
54
  UltraDNSUpdater::IpInfo.ipv6_for_iface(iface).should_not == ''
45
55
  UltraDNSUpdater::IpInfo.ipv6_for_iface(iface).should match(/.*:.*:.*:.*:.*:/)
@@ -36,10 +36,12 @@ describe UltraDNSUpdater::Strategies::Multiple do
36
36
  end
37
37
 
38
38
  multiple_factory = UltraDNSUpdater::Strategies::Multiple.factory(
39
- [clazz_bad, UltraDNSUpdater::Strategies::Openstack])
39
+ {'conf' => clazz_bad, 'openstack' => UltraDNSUpdater::Strategies::Openstack}
40
+ )
41
+
40
42
 
41
43
  openstack_strategy = multiple_factory.new(ultradns,
42
- { :use => 'conf', :conf => {} }
44
+ { :use => 'conf', :conf => {}, :openstack => {} }
43
45
  )
44
46
  openstack_strategy.update().should == fake_name
45
47
  ensure
@@ -31,8 +31,8 @@ describe UltraDNSUpdater::Strategies do
31
31
  it "should support multiple strategies" do
32
32
  UltraDNSUpdater::Strategies.strategy(['ec2', 'openstack']).should_not == nil
33
33
  multiple = UltraDNSUpdater::Strategies.strategy(['ec2', 'openstack'])
34
- multiple.new(nil, nil).strategies.should ==
35
- [UltraDNSUpdater::Strategies::Ec2, UltraDNSUpdater::Strategies::Openstack]
34
+ multiple.new(nil, {}).strategies.should ==
35
+ {'ec2' => UltraDNSUpdater::Strategies::Ec2, 'openstack' => UltraDNSUpdater::Strategies::Openstack}
36
36
  end
37
37
 
38
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ultradns_updater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.22
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-05 00:00:00.000000000 Z
12
+ date: 2012-11-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
@@ -163,7 +163,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
163
163
  version: '0'
164
164
  segments:
165
165
  - 0
166
- hash: 1966732010595683364
166
+ hash: -1167376260138909965
167
167
  required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  none: false
169
169
  requirements:
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  version: '0'
173
173
  segments:
174
174
  - 0
175
- hash: 1966732010595683364
175
+ hash: -1167376260138909965
176
176
  requirements: []
177
177
  rubyforge_project: ultradns_updater
178
178
  rubygems_version: 1.8.24