ultradns_updater 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ultradns_updater/strategies.rb +2 -2
- data/lib/ultradns_updater/strategies/multiple.rb +6 -4
- data/lib/ultradns_updater/strategies/openstack.rb +1 -1
- data/lib/ultradns_updater/version.rb +1 -1
- data/spec/lib/ip_info_spec.rb +12 -2
- data/spec/lib/multiple_spec.rb +4 -2
- data/spec/lib/strategies_spec.rb +2 -2
- metadata +4 -4
@@ -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
|
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 |
|
27
|
-
@strategy_instances <<
|
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
|
-
|
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
|
data/spec/lib/ip_info_spec.rb
CHANGED
@@ -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(/.*:.*:.*:.*:.*:/)
|
data/spec/lib/multiple_spec.rb
CHANGED
@@ -36,10 +36,12 @@ describe UltraDNSUpdater::Strategies::Multiple do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
multiple_factory = UltraDNSUpdater::Strategies::Multiple.factory(
|
39
|
-
|
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
|
data/spec/lib/strategies_spec.rb
CHANGED
@@ -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,
|
35
|
-
|
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.
|
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-
|
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:
|
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:
|
175
|
+
hash: -1167376260138909965
|
176
176
|
requirements: []
|
177
177
|
rubyforge_project: ultradns_updater
|
178
178
|
rubygems_version: 1.8.24
|