rubber 2.0.5 → 2.0.6
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/.travis.yml +2 -2
- data/CHANGELOG +50 -0
- data/lib/rubber/commands/cron.rb +9 -11
- data/lib/rubber/commands/util.rb +1 -0
- data/lib/rubber/dns.rb +29 -4
- data/lib/rubber/dns/aws.rb +181 -0
- data/lib/rubber/dns/nettica.rb +74 -36
- data/lib/rubber/dns/zerigo.rb +110 -4
- data/lib/rubber/instance.rb +1 -1
- data/lib/rubber/recipes/rubber/instances.rb +13 -5
- data/lib/rubber/recipes/rubber/security_groups.rb +1 -1
- data/lib/rubber/recipes/rubber/setup.rb +80 -64
- data/lib/rubber/util.rb +7 -0
- data/lib/rubber/version.rb +1 -1
- data/templates/base/config/rubber/deploy-setup.rb +12 -0
- data/templates/base/config/rubber/rubber-dns.yml +17 -21
- data/templates/base/config/rubber/rubber.yml +2 -2
- data/templates/collectd/config/rubber/role/passenger/passenger-status-sudoers.conf +1 -1
- data/templates/elasticsearch/config/rubber/rubber-elasticsearch.yml +1 -1
- data/templates/graphite/config/rubber/role/graphite_web/dashboard.html +5 -3
- data/templates/jenkins/config/environments/jenkins.rb +1 -1
- data/templates/jenkins/config/rubber/rubber-jenkins.yml +1 -1
- data/templates/passenger/config/rubber/deploy-passenger.rb +0 -8
- data/templates/postgresql/config/rubber/rubber-postgresql.yml +2 -2
- data/templates/resque/config/initializers/resque.rb +2 -2
- data/templates/resque/config/resque.yml +4 -0
- data/templates/resque/config/rubber/common/resque.yml +1 -1
- data/templates/resque_scheduler/config/rubber/common/resque_schedule.yml +9 -0
- data/templates/resque_scheduler/config/rubber/deploy-resque_scheduler.rb +38 -0
- data/templates/resque_scheduler/config/rubber/role/resque_scheduler/resque-scheduler-upstart.conf +20 -0
- data/templates/resque_scheduler/config/rubber/rubber-resque_scheduler.yml +7 -0
- data/templates/resque_scheduler/lib/tasks/resque-scheduler.rake +28 -0
- data/templates/resque_scheduler/templates.rb +1 -0
- data/templates/resque_scheduler/templates.yml +3 -0
- data/templates/torquebox/config/rubber/rubber-torquebox.yml +1 -1
- data/templates/zookeeper/config/rubber/role/zookeeper/myid.conf +5 -4
- data/templates/zookeeper/config/rubber/role/zookeeper/zoo.cfg +6 -1
- data/test/command_test.rb +0 -55
- data/test/commands/cron_test.rb +83 -0
- data/test/dns/aws_test.rb +192 -0
- data/test/dns/zerigo_test.rb +180 -0
- data/test/instance_test.rb +17 -2
- data/test/test_helper.rb +37 -2
- metadata +20 -8
- data/lib/rubber/dns/fog.rb +0 -219
- data/test/dns/fog_test.rb +0 -169
@@ -0,0 +1,192 @@
|
|
1
|
+
require File.expand_path(File.join(__FILE__, '../..', 'test_helper'))
|
2
|
+
require 'rubber/dns/aws'
|
3
|
+
|
4
|
+
if ENV['NO_FOG_MOCK']
|
5
|
+
|
6
|
+
class AwsTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
context "fog aws dns" do
|
9
|
+
|
10
|
+
setup do
|
11
|
+
env = {'access_key' => get_secret('cloud_providers.aws.access_key') || 'xxx',
|
12
|
+
'access_secret' => get_secret('cloud_providers.aws.secret_access_key') || 'yyy'}
|
13
|
+
@env = Rubber::Configuration::Environment::BoundEnv.new(env, nil, nil)
|
14
|
+
|
15
|
+
@dns = Rubber::Dns::Aws.new(@env)
|
16
|
+
destroy_test_domains(@dns)
|
17
|
+
end
|
18
|
+
|
19
|
+
context "compatibility" do
|
20
|
+
should "create using old credential style" do
|
21
|
+
env = {'dns_provider' => 'fog',
|
22
|
+
'dns_providers' => {
|
23
|
+
'fog' => {
|
24
|
+
'credentials' => {
|
25
|
+
'provider' => 'aws', 'aws_access_key_id' => 'xxx', 'aws_secret_access_key' => 'yyy'
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
@env = Rubber::Configuration::Environment::BoundEnv.new(env, nil, nil)
|
31
|
+
|
32
|
+
provider = Rubber::Dns::get_provider(@env.dns_provider, @env)
|
33
|
+
assert provider
|
34
|
+
assert provider.instance_of?(Rubber::Dns::Aws)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "find_or_create" do
|
39
|
+
|
40
|
+
should "create domain if it doesn't exist" do
|
41
|
+
assert_equal 0, all_test_zones(@dns).size
|
42
|
+
|
43
|
+
zone0 = @dns.find_or_create_zone("#{TEST_DOMAIN}1.com")
|
44
|
+
|
45
|
+
assert_equal 1, all_test_zones(@dns).size
|
46
|
+
zone1 = all_test_zones(@dns).find {|z| z.domain =~ /^#{TEST_DOMAIN}1.com/ }
|
47
|
+
assert zone1
|
48
|
+
assert_equal zone0.id, zone1.id
|
49
|
+
assert_equal zone0.domain, zone1.domain
|
50
|
+
end
|
51
|
+
|
52
|
+
should "match the same domain that was passed" do
|
53
|
+
assert_equal 0, all_test_zones(@dns).size
|
54
|
+
|
55
|
+
zone0 = @dns.find_or_create_zone("abc#{TEST_DOMAIN}2.com")
|
56
|
+
zone1 = @dns.find_or_create_zone("#{TEST_DOMAIN}2.com")
|
57
|
+
|
58
|
+
assert_equal 2, all_test_zones(@dns).size
|
59
|
+
|
60
|
+
zone2 = all_test_zones(@dns).find {|z| z.domain =~ /^#{TEST_DOMAIN}2.com/ }
|
61
|
+
assert zone2
|
62
|
+
assert_equal zone1.id, zone2.id
|
63
|
+
assert_equal zone1.domain, zone2.domain
|
64
|
+
end
|
65
|
+
|
66
|
+
should "do nothing if domain already exists" do
|
67
|
+
@dns.client.zones.create(:domain => "#{TEST_DOMAIN}3.com")
|
68
|
+
assert_equal 1, all_test_zones(@dns).size
|
69
|
+
|
70
|
+
zone0 = @dns.find_or_create_zone("#{TEST_DOMAIN}3.com")
|
71
|
+
|
72
|
+
assert_equal 1, all_test_zones(@dns).size
|
73
|
+
zone1 = all_test_zones(@dns).find {|z| z.domain =~ /^#{TEST_DOMAIN}3.com/ }
|
74
|
+
assert_equal zone0.id, zone1.id
|
75
|
+
assert_equal zone0.domain, zone1.domain
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
context "records" do
|
81
|
+
|
82
|
+
setup do
|
83
|
+
@domain = "#{TEST_DOMAIN}#{rand(90) + 10}.com"
|
84
|
+
@zone = @dns.find_or_create_zone(@domain)
|
85
|
+
end
|
86
|
+
|
87
|
+
should "create_record" do
|
88
|
+
@dns.create_host_record({:host => 'newhost', :domain => @domain, :data => ['1.1.1.1'], :type => 'A', :ttl => '333'})
|
89
|
+
|
90
|
+
assert_equal @zone.records.all.size, 1
|
91
|
+
record = @zone.records.first
|
92
|
+
attributes = @dns.host_to_opts(record)
|
93
|
+
|
94
|
+
assert_equal 'newhost', attributes[:host]
|
95
|
+
assert_equal @domain, attributes[:domain]
|
96
|
+
assert_equal ['1.1.1.1'], attributes[:data]
|
97
|
+
assert_equal 'A', attributes[:type]
|
98
|
+
assert_equal 333, attributes[:ttl]
|
99
|
+
end
|
100
|
+
|
101
|
+
should "destroy_record" do
|
102
|
+
# Create the record we want to test destroying.
|
103
|
+
@dns.create_host_record({:host => 'newhost', :domain => @domain, :data => ['1.1.1.1'], :type => 'A'})
|
104
|
+
assert_equal 1, @zone.records.all.size
|
105
|
+
|
106
|
+
@dns.destroy_host_record({:host => 'newhost', :domain => @domain})
|
107
|
+
|
108
|
+
assert_equal 0, @zone.records.all.size
|
109
|
+
end
|
110
|
+
|
111
|
+
should "update_record" do
|
112
|
+
params = {:host => 'host1', :domain => @domain, :data => ["1.1.1.1"]}
|
113
|
+
new = {:host => 'host1', :domain => @domain, :data => ["1.1.1.2"]}
|
114
|
+
|
115
|
+
@dns.create_host_record({:host => 'host1', :domain => @domain, :data => ['1.1.1.1'], :type => 'A'})
|
116
|
+
assert_equal 1, @zone.records.all.size
|
117
|
+
|
118
|
+
@dns.update_host_record(params, new)
|
119
|
+
assert_equal 1, @zone.records.all.size
|
120
|
+
|
121
|
+
record = @zone.records.all.first
|
122
|
+
attributes = @dns.host_to_opts(record)
|
123
|
+
assert_equal ['1.1.1.2'], attributes[:data]
|
124
|
+
end
|
125
|
+
|
126
|
+
should "find_records" do
|
127
|
+
# Set up some sample records.
|
128
|
+
created = []
|
129
|
+
created << {:host => 'host1', :domain => @domain, :data => ['1.1.1.1'], :type => 'A'}
|
130
|
+
created << {:host => '', :domain => @domain, :data => ['1.1.1.1'], :type => 'A'}
|
131
|
+
created.each {|r| @dns.create_host_record(r) }
|
132
|
+
|
133
|
+
# Search for records through the rubber DNS interface and make sure whe get what we expected.
|
134
|
+
|
135
|
+
# Wildcard search.
|
136
|
+
records = @dns.find_host_records(:host => '*', :domain => @domain)
|
137
|
+
assert_equal 2, records.size
|
138
|
+
|
139
|
+
# Blank hostname search.
|
140
|
+
records = @dns.find_host_records(:host => '', :domain => @domain)
|
141
|
+
assert_equal 1, records.size
|
142
|
+
assert_equal '', records.first[:host]
|
143
|
+
|
144
|
+
# Specific hostname search.
|
145
|
+
records = @dns.find_host_records(:host => 'host1', :domain => @domain)
|
146
|
+
assert_equal 1, records.size
|
147
|
+
assert_equal 'host1', records.first[:host]
|
148
|
+
end
|
149
|
+
|
150
|
+
should "find_many_records" do
|
151
|
+
# Set up many sample records - more than the max returned
|
152
|
+
# in a single fetch so we can test pagination
|
153
|
+
max = 102
|
154
|
+
created = []
|
155
|
+
max.times do |i|
|
156
|
+
created << {:host => "host#{i}", :domain => @domain, :data => ['1.1.1.1'], :type => 'A'}
|
157
|
+
end
|
158
|
+
created.each_slice(20) do |group|
|
159
|
+
group = group.collect do |o|
|
160
|
+
r = @dns.opts_to_host(o)
|
161
|
+
r[:action] = 'CREATE'
|
162
|
+
r[:resource_records] = r.delete(:value)
|
163
|
+
r[:ttl] = 300
|
164
|
+
r
|
165
|
+
end
|
166
|
+
@zone.connection.change_resource_record_sets(@zone.id, group)
|
167
|
+
end
|
168
|
+
|
169
|
+
# Search for records through the rubber DNS interface and make sure whe get what we expected.
|
170
|
+
|
171
|
+
# Wildcard search.
|
172
|
+
records = @dns.find_host_records(:host => '*', :domain => @domain)
|
173
|
+
assert_equal max, records.size
|
174
|
+
|
175
|
+
# Specific hostname search.
|
176
|
+
records = @dns.find_host_records(:host => 'host1', :domain => @domain)
|
177
|
+
assert_equal 1, records.size
|
178
|
+
assert_equal 'host1', records.first[:host]
|
179
|
+
|
180
|
+
# Specific hostname search.
|
181
|
+
records = @dns.find_host_records(:host => "host#{max - 1}", :domain => @domain)
|
182
|
+
assert_equal 1, records.size
|
183
|
+
assert_equal "host#{max - 1}", records.first[:host]
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
@@ -0,0 +1,180 @@
|
|
1
|
+
require File.expand_path(File.join(__FILE__, '../..', 'test_helper'))
|
2
|
+
require 'rubber/dns/zerigo'
|
3
|
+
|
4
|
+
class ZerigoTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
context "fog zerigo dns" do
|
7
|
+
|
8
|
+
setup do
|
9
|
+
env = {'email' => get_secret('dns_providers.zerigo.email') || 'xxx',
|
10
|
+
'token' => get_secret('dns_providers.zerigo.token') || 'yyy'}
|
11
|
+
@env = Rubber::Configuration::Environment::BoundEnv.new(env, nil, nil)
|
12
|
+
|
13
|
+
@dns = Rubber::Dns::Zerigo.new(@env)
|
14
|
+
destroy_test_domains(@dns)
|
15
|
+
end
|
16
|
+
|
17
|
+
context "compatibility" do
|
18
|
+
should "create using old credential style" do
|
19
|
+
env = {'dns_provider' => 'fog',
|
20
|
+
'dns_providers' => {
|
21
|
+
'fog' => {
|
22
|
+
'credentials' => {
|
23
|
+
'provider' => 'zerigo', 'zerigo_email' => 'xxx', 'zerigo_token' => 'yyy'
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
@env = Rubber::Configuration::Environment::BoundEnv.new(env, nil, nil)
|
29
|
+
|
30
|
+
provider = Rubber::Dns::get_provider(@env.dns_provider, @env)
|
31
|
+
assert provider
|
32
|
+
assert provider.instance_of?(Rubber::Dns::Zerigo)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "find_or_create" do
|
37
|
+
|
38
|
+
should "create domain if it doesn't exist" do
|
39
|
+
assert_equal 0, all_test_zones(@dns).size
|
40
|
+
|
41
|
+
zone0 = @dns.find_or_create_zone("#{TEST_DOMAIN}1.com")
|
42
|
+
|
43
|
+
assert_equal 1, all_test_zones(@dns).size
|
44
|
+
zone1 = all_test_zones(@dns).find {|z| z.domain =~ /^#{TEST_DOMAIN}1.com/ }
|
45
|
+
assert zone1
|
46
|
+
assert_equal zone0.id, zone1.id
|
47
|
+
assert_equal zone0.domain, zone1.domain
|
48
|
+
end
|
49
|
+
|
50
|
+
should "match the same domain that was passed" do
|
51
|
+
assert_equal 0, all_test_zones(@dns).size
|
52
|
+
|
53
|
+
zone0 = @dns.find_or_create_zone("abc#{TEST_DOMAIN}2.com")
|
54
|
+
zone1 = @dns.find_or_create_zone("#{TEST_DOMAIN}2.com")
|
55
|
+
|
56
|
+
assert_equal 2, all_test_zones(@dns).size
|
57
|
+
|
58
|
+
zone2 = all_test_zones(@dns).find {|z| z.domain =~ /^#{TEST_DOMAIN}2.com/ }
|
59
|
+
assert zone2
|
60
|
+
assert_equal zone1.id, zone2.id
|
61
|
+
assert_equal zone1.domain, zone2.domain
|
62
|
+
end
|
63
|
+
|
64
|
+
should "do nothing if domain already exists" do
|
65
|
+
@dns.client.zones.create(:domain => "#{TEST_DOMAIN}3.com")
|
66
|
+
assert_equal 1, all_test_zones(@dns).size
|
67
|
+
|
68
|
+
zone0 = @dns.find_or_create_zone("#{TEST_DOMAIN}3.com")
|
69
|
+
|
70
|
+
assert_equal 1, all_test_zones(@dns).size
|
71
|
+
zone1 = all_test_zones(@dns).find {|z| z.domain =~ /^#{TEST_DOMAIN}3.com/ }
|
72
|
+
assert_equal zone0.id, zone1.id
|
73
|
+
assert_equal zone0.domain, zone1.domain
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
context "records" do
|
79
|
+
|
80
|
+
setup do
|
81
|
+
@domain = "#{TEST_DOMAIN}#{rand(90) + 10}.com"
|
82
|
+
@zone = @dns.find_or_create_zone(@domain)
|
83
|
+
end
|
84
|
+
|
85
|
+
should "create_record" do
|
86
|
+
@dns.create_host_record({:host => 'newhost', :domain => @domain, :data => ['1.1.1.1'], :type => 'A', :ttl => '333'})
|
87
|
+
|
88
|
+
assert_equal @zone.records.all.size, 1
|
89
|
+
record = @zone.records.first
|
90
|
+
attributes = @dns.hosts_to_opts([record])
|
91
|
+
|
92
|
+
assert_equal 'newhost', attributes[:host]
|
93
|
+
assert_equal @domain, attributes[:domain]
|
94
|
+
assert_equal ['1.1.1.1'], attributes[:data]
|
95
|
+
assert_equal 'A', attributes[:type]
|
96
|
+
assert_equal 333, attributes[:ttl]
|
97
|
+
end
|
98
|
+
|
99
|
+
should "destroy_record" do
|
100
|
+
# Create the record we want to test destroying.
|
101
|
+
@dns.create_host_record({:host => 'newhost', :domain => @domain, :data => ['1.1.1.1'], :type => 'A'})
|
102
|
+
assert_equal 1, @zone.records.all.size
|
103
|
+
|
104
|
+
@dns.destroy_host_record({:host => 'newhost', :domain => @domain})
|
105
|
+
|
106
|
+
assert_equal 0, @zone.records.all.size
|
107
|
+
end
|
108
|
+
|
109
|
+
should "update_record" do
|
110
|
+
params = {:host => 'host1', :domain => @domain, :data => ["1.1.1.1"]}
|
111
|
+
new = {:host => 'host1', :domain => @domain, :data => ["1.1.1.2"]}
|
112
|
+
|
113
|
+
@dns.create_host_record({:host => 'host1', :domain => @domain, :data => ['1.1.1.1'], :type => 'A'})
|
114
|
+
assert_equal 1, @zone.records.all.size
|
115
|
+
|
116
|
+
@dns.update_host_record(params, new)
|
117
|
+
assert_equal 1, @zone.records.all.size
|
118
|
+
|
119
|
+
record = @zone.records.all.first
|
120
|
+
attributes = @dns.hosts_to_opts([record])
|
121
|
+
assert_equal ['1.1.1.2'], attributes[:data]
|
122
|
+
end
|
123
|
+
|
124
|
+
should "find_records" do
|
125
|
+
# Set up some sample records.
|
126
|
+
created = []
|
127
|
+
created << {:host => 'host1', :domain => @domain, :data => ['1.1.1.1'], :type => 'A'}
|
128
|
+
created << {:host => '', :domain => @domain, :data => ['1.1.1.1'], :type => 'A'}
|
129
|
+
created.each {|r| @dns.create_host_record(r) }
|
130
|
+
# Search for records through the rubber DNS interface and make sure whe get what we expected.
|
131
|
+
|
132
|
+
# Wildcard search.
|
133
|
+
records = @dns.find_host_records(:host => '*', :domain => @domain)
|
134
|
+
assert_equal 2, records.size
|
135
|
+
|
136
|
+
# Blank hostname search.
|
137
|
+
records = @dns.find_host_records(:host => '', :domain => @domain)
|
138
|
+
assert_equal 1, records.size
|
139
|
+
assert_equal '', records.first[:host]
|
140
|
+
|
141
|
+
# Specific hostname search.
|
142
|
+
records = @dns.find_host_records(:host => 'host1', :domain => @domain)
|
143
|
+
assert_equal 1, records.size
|
144
|
+
assert_equal 'host1', records.first[:host]
|
145
|
+
end
|
146
|
+
|
147
|
+
should "find_many_records" do
|
148
|
+
omit "fog-zerigo implementation doesn't support pagination" if ENV['NO_FOG_MOCK']
|
149
|
+
|
150
|
+
# Set up many sample records - more than the max returned
|
151
|
+
# in a single fetch so we can test pagination
|
152
|
+
max = 302
|
153
|
+
created = []
|
154
|
+
max.times do |i|
|
155
|
+
created << {:host => "host#{i}", :domain => @domain, :data => ['1.1.1.1'], :type => 'A'}
|
156
|
+
end
|
157
|
+
created.each {|r| @dns.create_host_record(r) }
|
158
|
+
|
159
|
+
# Search for records through the rubber DNS interface and make sure whe get what we expected.
|
160
|
+
|
161
|
+
# Wildcard search.
|
162
|
+
records = @dns.find_host_records(:host => '*', :domain => @domain)
|
163
|
+
assert_equal max, records.size
|
164
|
+
|
165
|
+
# Specific hostname search.
|
166
|
+
records = @dns.find_host_records(:host => 'host1', :domain => @domain)
|
167
|
+
assert_equal 1, records.size
|
168
|
+
assert_equal 'host1', records.first[:host]
|
169
|
+
|
170
|
+
# Specific hostname search.
|
171
|
+
records = @dns.find_host_records(:host => "host#{max - 1}", :domain => @domain)
|
172
|
+
assert_equal 1, records.size
|
173
|
+
assert_equal "host#{max - 1}", records.first[:host]
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
data/test/instance_test.rb
CHANGED
@@ -220,7 +220,16 @@ class InstanceTest < Test::Unit::TestCase
|
|
220
220
|
location = "file:#{Tempfile.new('instancestorage').path}"
|
221
221
|
Instance.any_instance.expects(:load_from_file)
|
222
222
|
Instance.any_instance.expects(:save_to_file)
|
223
|
-
Instance.new(location).save
|
223
|
+
Instance.new(location).save
|
224
|
+
end
|
225
|
+
|
226
|
+
should "create new instance in filesystem when instance file doesn't exist" do
|
227
|
+
tempfile = Tempfile.new('instancestorage')
|
228
|
+
location = "file:#{tempfile.path}"
|
229
|
+
tempfile.unlink
|
230
|
+
Instance.any_instance.expects(:load_from_file).never
|
231
|
+
Instance.any_instance.expects(:save_to_file)
|
232
|
+
Instance.new(location).save
|
224
233
|
end
|
225
234
|
|
226
235
|
should "load and save from storage when storage given" do
|
@@ -229,7 +238,13 @@ class InstanceTest < Test::Unit::TestCase
|
|
229
238
|
Instance.any_instance.expects(:save_to_file)
|
230
239
|
Instance.new('storage:bucket/key').save
|
231
240
|
end
|
232
|
-
|
241
|
+
|
242
|
+
should "create a new instance in cloud storage when the instance file doesn't exist" do
|
243
|
+
Instance.any_instance.expects(:load_from_file).never
|
244
|
+
Instance.any_instance.expects(:save_to_file)
|
245
|
+
Instance.new('storage:bucket/key').save
|
246
|
+
end
|
247
|
+
|
233
248
|
should "load and save from table when table given" do
|
234
249
|
Instance.any_instance.expects(:load_from_table)
|
235
250
|
Instance.any_instance.expects(:save_to_table)
|
data/test/test_helper.rb
CHANGED
@@ -12,11 +12,46 @@ require 'tempfile'
|
|
12
12
|
require 'fog'
|
13
13
|
|
14
14
|
class Test::Unit::TestCase
|
15
|
+
# ENV['NO_FOG_MOCK'] = 'true'
|
16
|
+
|
15
17
|
setup do
|
16
|
-
Fog.mock!
|
18
|
+
Fog.mock! unless ENV['NO_FOG_MOCK']
|
17
19
|
end
|
18
20
|
|
19
21
|
teardown do
|
20
|
-
Fog::Mock.reset
|
22
|
+
Fog::Mock.reset unless ENV['NO_FOG_MOCK']
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
SECRET = YAML.load_file(File.expand_path("~/rubber-secret.yml")) rescue {}
|
28
|
+
|
29
|
+
def get_secret(path)
|
30
|
+
parts = path.split('.')
|
31
|
+
result = SECRET
|
32
|
+
|
33
|
+
parts.each do |part|
|
34
|
+
result = result[part] if result
|
35
|
+
end
|
36
|
+
return result
|
37
|
+
end
|
38
|
+
|
39
|
+
TEST_DOMAIN = 'rubbertester'
|
40
|
+
|
41
|
+
def all_test_zones(dns)
|
42
|
+
dns.client.zones.all.find_all {|z| z.domain =~ /#{TEST_DOMAIN}/ }
|
43
|
+
end
|
44
|
+
|
45
|
+
def destroy_test_domains(dns)
|
46
|
+
all_test_zones(dns).each do |zone|
|
47
|
+
# hardcoded failsafe to prevent destruction of real domains
|
48
|
+
raise "Trying to destroy non-rubber domain!" if zone.domain !~ /rubber/
|
49
|
+
|
50
|
+
while zone.records.all.size != 0
|
51
|
+
zone.records.all.each do |record|
|
52
|
+
record.destroy
|
53
|
+
end
|
54
|
+
end
|
55
|
+
zone.destroy
|
21
56
|
end
|
22
57
|
end
|