ultradns_updater 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +66 -0
- data/LICENSE +202 -0
- data/README.md +47 -0
- data/Rakefile +6 -0
- data/bin/ultradns_updater +28 -0
- data/config/sample.config.yaml +24 -0
- data/lib/ultradns_updater/cli.rb +136 -0
- data/lib/ultradns_updater/ec2.rb +80 -0
- data/lib/ultradns_updater/ip_info.rb +70 -0
- data/lib/ultradns_updater/preconditions.rb +25 -0
- data/lib/ultradns_updater/strategies/configured.rb +29 -0
- data/lib/ultradns_updater/strategies/ec2.rb +38 -0
- data/lib/ultradns_updater/strategies/hostname.rb +24 -0
- data/lib/ultradns_updater/strategies/update_strategy.rb +39 -0
- data/lib/ultradns_updater/strategies.rb +39 -0
- data/lib/ultradns_updater/ultradns.rb +218 -0
- data/lib/ultradns_updater/version.rb +17 -0
- data/lib/ultradns_updater.rb +32 -0
- data/spec/lib/configured_spec.rb +38 -0
- data/spec/lib/ec2_spec.rb +74 -0
- data/spec/lib/hostname_spec.rb +39 -0
- data/spec/lib/ip_info_spec.rb +47 -0
- data/spec/lib/ultradns_spec.rb +158 -0
- data/spec/spec_helper.rb +18 -0
- data/ultradns_updater.gemspec +31 -0
- metadata +153 -0
@@ -0,0 +1,158 @@
|
|
1
|
+
# Copyright 2012 NeuStar, Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'spec_helper'
|
16
|
+
require 'fakeweb'
|
17
|
+
require 'yaml'
|
18
|
+
|
19
|
+
describe UltraDNSUpdater::UltraDNS do
|
20
|
+
|
21
|
+
it "should raise if cname is empty" do
|
22
|
+
ultra = UltraDNSUpdater::UltraDNS.new({:username => 'blah', :password => 'blah', :zone => 'ultrandns.com.'})
|
23
|
+
expect { ultra.create_or_update_cname }.to raise_error
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should raise if to_hostname is empty" do
|
27
|
+
ultra = UltraDNSUpdater::UltraDNS.new({:username => 'blah', :password => 'blah', :zone => 'ultrandns.com.'})
|
28
|
+
expect { ultra.create_or_update_cname("adsf", '') }.to raise_error
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should fix a zone name without a trailing dot" do
|
32
|
+
ultra = UltraDNSUpdater::UltraDNS.new({:username => 'blah', :password => 'blah', :zone => 'ultrandns.com.'})
|
33
|
+
ultra.fix_zone_name("a.b.com").should == "a.b.com."
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should not change a zone name with a trailing dot" do
|
37
|
+
ultra = UltraDNSUpdater::UltraDNS.new({:username => 'blah', :password => 'blah', :zone => 'ultrandns.com.'})
|
38
|
+
name = "a.b.biz."
|
39
|
+
ultra.fix_zone_name(name).should == name
|
40
|
+
end
|
41
|
+
|
42
|
+
## testing with the live service we use a configuration not checked in due to passwords and such
|
43
|
+
LIVE_CONFIG = File.join(File.dirname(__FILE__), '..', '..', 'config', 'live.config.yaml')
|
44
|
+
|
45
|
+
it "should check network status" do
|
46
|
+
config = UltraDNSUpdater::CLI.load_config({}, LIVE_CONFIG)
|
47
|
+
config.should_not eq(nil)
|
48
|
+
|
49
|
+
ultra = UltraDNSUpdater::UltraDNS.new(config[:ultradns])
|
50
|
+
(ultra.network_status?).should eq(true)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should create a new record and then update the record" do
|
54
|
+
config = UltraDNSUpdater::CLI.load_config({}, LIVE_CONFIG)
|
55
|
+
config.should_not eq(nil)
|
56
|
+
|
57
|
+
ultra = UltraDNSUpdater::UltraDNS.new(config[:ultradns])
|
58
|
+
guid = ultra.get_cname_guid(config[:test_cname])
|
59
|
+
if guid != nil && guid != ''
|
60
|
+
ultra.delete_record_by_guid(guid).should eq(true)
|
61
|
+
end
|
62
|
+
|
63
|
+
# create cname
|
64
|
+
|
65
|
+
result = ultra.create_or_update_cname(config[:test_cname], config[:test_public_hostname][0])
|
66
|
+
result.should eq(true)
|
67
|
+
guid_0 = ultra.get_cname_guid(config[:test_cname])
|
68
|
+
guid_0.should_not be_empty
|
69
|
+
|
70
|
+
recs = ultra.get_record_by_label_and_type(config[:test_cname],
|
71
|
+
UltraDNSUpdater::UltraDNS::TYPE::CNAME)
|
72
|
+
cname = recs[:resource_record][:info_values][:@info1_value]
|
73
|
+
cname.should == config[:test_public_hostname][0] + '.' # no trailing . in config
|
74
|
+
|
75
|
+
|
76
|
+
# update cname
|
77
|
+
|
78
|
+
result = ultra.create_or_update_cname(config[:test_cname], config[:test_public_hostname][1])
|
79
|
+
result.should eq(true)
|
80
|
+
guid_1 = ultra.get_cname_guid(config[:test_cname])
|
81
|
+
guid_1.should_not be_empty
|
82
|
+
guid_0.should == guid_1
|
83
|
+
|
84
|
+
recs = ultra.get_record_by_label_and_type(config[:test_cname],
|
85
|
+
UltraDNSUpdater::UltraDNS::TYPE::CNAME)
|
86
|
+
cname = recs[:resource_record][:info_values][:@info1_value]
|
87
|
+
cname.should == config[:test_public_hostname][1] + '.' # no trailing . in config
|
88
|
+
|
89
|
+
|
90
|
+
# remove the CNAME record
|
91
|
+
if guid_0 != nil && guid_0 != ''
|
92
|
+
ultra.delete_record_by_guid(guid_0).should eq(true)
|
93
|
+
end
|
94
|
+
|
95
|
+
# create A record
|
96
|
+
IP = '1.2.3.4'
|
97
|
+
result = ultra.create_or_update_a(config[:test_cname], IP)
|
98
|
+
result.should eq(true)
|
99
|
+
guid_2 = ultra.get_a_guid(config[:test_cname])
|
100
|
+
recs = ultra.get_record_by_label_and_type(config[:test_cname],
|
101
|
+
UltraDNSUpdater::UltraDNS::TYPE::A)
|
102
|
+
|
103
|
+
ip = recs[:resource_record][:info_values][:@info1_value]
|
104
|
+
ip.should == IP
|
105
|
+
|
106
|
+
guid_2.should_not be_empty
|
107
|
+
guid_0.should_not == guid_2
|
108
|
+
|
109
|
+
# remove the A record
|
110
|
+
ultra.delete_record_by_label(config[:test_cname])
|
111
|
+
|
112
|
+
guid_3 = ultra.get_a_guid(config[:test_cname])
|
113
|
+
guid_3.should == nil
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should create a new record and then create a record of a different type" do
|
117
|
+
config = UltraDNSUpdater::CLI.load_config({}, LIVE_CONFIG)
|
118
|
+
config.should_not eq(nil)
|
119
|
+
|
120
|
+
ultra = UltraDNSUpdater::UltraDNS.new(config[:ultradns])
|
121
|
+
|
122
|
+
|
123
|
+
# create cname
|
124
|
+
|
125
|
+
result = ultra.create_or_update_cname(config[:test_cname], config[:test_public_hostname][0])
|
126
|
+
result.should eq(true)
|
127
|
+
guid_0 = ultra.get_cname_guid(config[:test_cname])
|
128
|
+
guid_0.should_not be_empty
|
129
|
+
|
130
|
+
recs = ultra.get_record_by_label_and_type(config[:test_cname],
|
131
|
+
UltraDNSUpdater::UltraDNS::TYPE::CNAME)
|
132
|
+
cname = recs[:resource_record][:info_values][:@info1_value]
|
133
|
+
cname.should == config[:test_public_hostname][0] + '.' # no trailing . in config
|
134
|
+
|
135
|
+
|
136
|
+
# create A record
|
137
|
+
ip_value = '1.2.3.4'
|
138
|
+
result = ultra.create_or_update_a(config[:test_cname], ip_value)
|
139
|
+
result.should eq(true)
|
140
|
+
guid_2 = ultra.get_a_guid(config[:test_cname])
|
141
|
+
recs = ultra.get_record_by_label_and_type(config[:test_cname],
|
142
|
+
UltraDNSUpdater::UltraDNS::TYPE::A)
|
143
|
+
|
144
|
+
ip = recs[:resource_record][:info_values][:@info1_value]
|
145
|
+
ip.should == ip_value
|
146
|
+
|
147
|
+
guid_2.should_not be_empty
|
148
|
+
guid_0.should_not == guid_2
|
149
|
+
|
150
|
+
# remove the A record
|
151
|
+
ultra.delete_record_by_label(config[:test_cname])
|
152
|
+
|
153
|
+
guid_3 = ultra.get_a_guid(config[:test_cname])
|
154
|
+
guid_3.should == nil
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|
158
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright 2012 NeuStar, Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'bundler/setup'
|
16
|
+
require 'ultradns_updater'
|
17
|
+
|
18
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "ultradns_updater/version"
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "ultradns_updater"
|
9
|
+
s.version = UltraDNSUpdater::VERSION
|
10
|
+
s.authors = ["ultradns"]
|
11
|
+
s.email = ["ultradns@neustar.biz"]
|
12
|
+
s.homepage = "https://github.com/ultradns/ultradns_updater"
|
13
|
+
s.summary = %q{Update UltraDNS from an instance with EC2 support}
|
14
|
+
s.description = %q{Update your UltraDNS configured A, AAAA, or CNAMEs to point to an instance public hostnames}
|
15
|
+
|
16
|
+
s.rubyforge_project = "ultradns_updater"
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib" ,"bin"]
|
22
|
+
|
23
|
+
|
24
|
+
s.add_runtime_dependency "aws-sdk", "~> 1.5.6"
|
25
|
+
s.add_runtime_dependency "wasabi", "2.5.0"
|
26
|
+
s.add_runtime_dependency "savon", "1.1.0" # http://savonrb.com/
|
27
|
+
|
28
|
+
s.add_development_dependency "rake"
|
29
|
+
s.add_development_dependency "rspec"
|
30
|
+
s.add_development_dependency "fakeweb"
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ultradns_updater
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.15
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- ultradns
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: aws-sdk
|
16
|
+
requirement: &2152072360 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.5.6
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2152072360
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: wasabi
|
27
|
+
requirement: &2152071520 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - =
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.5.0
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2152071520
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: savon
|
38
|
+
requirement: &2152070220 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - =
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.1.0
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2152070220
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: &2152069420 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2152069420
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rspec
|
60
|
+
requirement: &2152068840 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2152068840
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: fakeweb
|
71
|
+
requirement: &2152106900 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2152106900
|
80
|
+
description: Update your UltraDNS configured A, AAAA, or CNAMEs to point to an instance
|
81
|
+
public hostnames
|
82
|
+
email:
|
83
|
+
- ultradns@neustar.biz
|
84
|
+
executables:
|
85
|
+
- ultradns_updater
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files: []
|
88
|
+
files:
|
89
|
+
- .gitignore
|
90
|
+
- Gemfile
|
91
|
+
- Gemfile.lock
|
92
|
+
- LICENSE
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- bin/ultradns_updater
|
96
|
+
- config/sample.config.yaml
|
97
|
+
- lib/ultradns_updater.rb
|
98
|
+
- lib/ultradns_updater/cli.rb
|
99
|
+
- lib/ultradns_updater/ec2.rb
|
100
|
+
- lib/ultradns_updater/ip_info.rb
|
101
|
+
- lib/ultradns_updater/preconditions.rb
|
102
|
+
- lib/ultradns_updater/strategies.rb
|
103
|
+
- lib/ultradns_updater/strategies/configured.rb
|
104
|
+
- lib/ultradns_updater/strategies/ec2.rb
|
105
|
+
- lib/ultradns_updater/strategies/hostname.rb
|
106
|
+
- lib/ultradns_updater/strategies/update_strategy.rb
|
107
|
+
- lib/ultradns_updater/ultradns.rb
|
108
|
+
- lib/ultradns_updater/version.rb
|
109
|
+
- spec/lib/configured_spec.rb
|
110
|
+
- spec/lib/ec2_spec.rb
|
111
|
+
- spec/lib/hostname_spec.rb
|
112
|
+
- spec/lib/ip_info_spec.rb
|
113
|
+
- spec/lib/ultradns_spec.rb
|
114
|
+
- spec/spec_helper.rb
|
115
|
+
- ultradns_updater.gemspec
|
116
|
+
homepage: https://github.com/ultradns/ultradns_updater
|
117
|
+
licenses: []
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
- bin
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ! '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
segments:
|
130
|
+
- 0
|
131
|
+
hash: -4111358343016132337
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
none: false
|
134
|
+
requirements:
|
135
|
+
- - ! '>='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
segments:
|
139
|
+
- 0
|
140
|
+
hash: -4111358343016132337
|
141
|
+
requirements: []
|
142
|
+
rubyforge_project: ultradns_updater
|
143
|
+
rubygems_version: 1.8.15
|
144
|
+
signing_key:
|
145
|
+
specification_version: 3
|
146
|
+
summary: Update UltraDNS from an instance with EC2 support
|
147
|
+
test_files:
|
148
|
+
- spec/lib/configured_spec.rb
|
149
|
+
- spec/lib/ec2_spec.rb
|
150
|
+
- spec/lib/hostname_spec.rb
|
151
|
+
- spec/lib/ip_info_spec.rb
|
152
|
+
- spec/lib/ultradns_spec.rb
|
153
|
+
- spec/spec_helper.rb
|