ec2_ultradns_updater 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/ec2_ultradns_updater/ec2.rb +3 -2
- data/lib/ec2_ultradns_updater/ultradns.rb +2 -1
- data/lib/ec2_ultradns_updater/version.rb +1 -1
- data/lib/ec2_ultradns_updater.rb +6 -7
- data/spec/lib/ec2_spec.rb +4 -4
- metadata +12 -12
data/Gemfile.lock
CHANGED
@@ -14,6 +14,7 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
class Ec2UltraDNSUpdater::Ec2
|
17
|
+
EC2_META_DATA_URL = "http://169.254.169.254/latest/meta-data"
|
17
18
|
|
18
19
|
def initialize(opts = {})
|
19
20
|
AWS.config(
|
@@ -25,13 +26,13 @@ class Ec2UltraDNSUpdater::Ec2
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def get_instance_id
|
28
|
-
@instance_id ||= Net::HTTP.get(URI("#{
|
29
|
+
@instance_id ||= Net::HTTP.get(URI("#{EC2_META_DATA_URL}/instance-id"))
|
29
30
|
@logger.debug("Instance ID = #{@instance_id}")
|
30
31
|
@instance_id
|
31
32
|
end
|
32
33
|
|
33
34
|
def get_instance_public_hostname
|
34
|
-
@public_hostname ||= Net::HTTP.get(URI("#{
|
35
|
+
@public_hostname ||= Net::HTTP.get(URI("#{EC2_META_DATA_URL}/public-hostname"))
|
35
36
|
@logger.debug("Public Hostname = #{@public_hostname}")
|
36
37
|
@public_hostname
|
37
38
|
end
|
@@ -18,6 +18,7 @@ class Ec2UltraDNSUpdater::UltraDNS
|
|
18
18
|
|
19
19
|
ULTRADNS_WSDL_URL = "http://ultra-api.ultradns.com:8008/UltraDNS_WS/v01?wsdl"
|
20
20
|
CNAME_TYPE = 5
|
21
|
+
DEFAULT_TTL = 60
|
21
22
|
|
22
23
|
def initialize(opts = {})
|
23
24
|
@logger = opts['logger'] || Logger.new(STDOUT)
|
@@ -71,7 +72,7 @@ class Ec2UltraDNSUpdater::UltraDNS
|
|
71
72
|
guid = get_cname_guid(cname)
|
72
73
|
|
73
74
|
change_method = 'createResourceRecord'
|
74
|
-
record_opts = {'Type' => CNAME_TYPE, 'DName' => fixed_cname, 'TTL' =>
|
75
|
+
record_opts = {'Type' => CNAME_TYPE, 'DName' => fixed_cname, 'TTL' => DEFAULT_TTL}
|
75
76
|
|
76
77
|
if guid != nil && guid != ''
|
77
78
|
@logger.info "Updating Record Mapping: #{fixed_cname} => #{fixed_to_hostname}"
|
data/lib/ec2_ultradns_updater.rb
CHANGED
@@ -19,15 +19,14 @@ require 'aws-sdk'
|
|
19
19
|
require 'savon'
|
20
20
|
require 'net/http'
|
21
21
|
|
22
|
+
|
23
|
+
module Ec2UltraDNSUpdater
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
|
22
28
|
require "ec2_ultradns_updater/cli"
|
23
29
|
require "ec2_ultradns_updater/ec2"
|
24
30
|
require "ec2_ultradns_updater/preconditions"
|
25
31
|
require "ec2_ultradns_updater/ultradns"
|
26
32
|
require "ec2_ultradns_updater/version"
|
27
|
-
|
28
|
-
module Ec2UltraDNSUpdater
|
29
|
-
EC2_META_DATA_URL = "http://169.254.169.254/latest/meta-data"
|
30
|
-
DEFAULT_TTL = 60
|
31
|
-
|
32
|
-
end
|
33
|
-
|
data/spec/lib/ec2_spec.rb
CHANGED
@@ -21,7 +21,7 @@ describe Ec2UltraDNSUpdater::Ec2 do
|
|
21
21
|
it "should return the instance id" do
|
22
22
|
begin
|
23
23
|
fake_id = "i-ffffffff"
|
24
|
-
FakeWeb.register_uri(:get, Ec2UltraDNSUpdater::EC2_META_DATA_URL + "/instance-id", :body => fake_id)
|
24
|
+
FakeWeb.register_uri(:get, Ec2UltraDNSUpdater::Ec2::EC2_META_DATA_URL + "/instance-id", :body => fake_id)
|
25
25
|
ec2 = Ec2UltraDNSUpdater::Ec2.new
|
26
26
|
ec2.get_instance_id.should == fake_id
|
27
27
|
ec2.get_instance_id.should == fake_id # check memoize
|
@@ -33,7 +33,7 @@ describe Ec2UltraDNSUpdater::Ec2 do
|
|
33
33
|
it "should return the public hostname" do
|
34
34
|
begin
|
35
35
|
fake_name = "ec2-111-111-111-111.compute-1.amazonaws.com"
|
36
|
-
FakeWeb.register_uri(:get, Ec2UltraDNSUpdater::EC2_META_DATA_URL + "/public-hostname", :body => fake_name)
|
36
|
+
FakeWeb.register_uri(:get, Ec2UltraDNSUpdater::Ec2::EC2_META_DATA_URL + "/public-hostname", :body => fake_name)
|
37
37
|
ec2 = Ec2UltraDNSUpdater::Ec2.new
|
38
38
|
ec2.get_instance_public_hostname.should == fake_name
|
39
39
|
ec2.get_instance_public_hostname.should == fake_name # check memoize
|
@@ -54,8 +54,8 @@ describe Ec2UltraDNSUpdater::Ec2 do
|
|
54
54
|
|
55
55
|
AWS::EC2.any_instance.stub(:tags).and_return(tags)
|
56
56
|
fake_name = "ec2-111-111-111-111.compute-1.amazonaws.com"
|
57
|
-
FakeWeb.register_uri(:get, Ec2UltraDNSUpdater::EC2_META_DATA_URL + "/public-hostname", :body => fake_name)
|
58
|
-
FakeWeb.register_uri(:get, Ec2UltraDNSUpdater::EC2_META_DATA_URL + "/instance-id", :body => tag.resource)
|
57
|
+
FakeWeb.register_uri(:get, Ec2UltraDNSUpdater::Ec2::EC2_META_DATA_URL + "/public-hostname", :body => fake_name)
|
58
|
+
FakeWeb.register_uri(:get, Ec2UltraDNSUpdater::Ec2::EC2_META_DATA_URL + "/instance-id", :body => tag.resource)
|
59
59
|
|
60
60
|
ec2 = Ec2UltraDNSUpdater::Ec2.new({'access_key_id' => 123, 'secret_access_key' => 'abc', 'name_tag' => 'Testname'})
|
61
61
|
ec2.get_name_tag.should == tag.value
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ec2_ultradns_updater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-02 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
16
|
-
requirement: &
|
16
|
+
requirement: &2153113180 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2153113180
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: savon
|
27
|
-
requirement: &
|
27
|
+
requirement: &2153112760 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2153112760
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &2153112340 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2153112340
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &2153111920 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2153111920
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: fakeweb
|
60
|
-
requirement: &
|
60
|
+
requirement: &2153111500 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2153111500
|
69
69
|
description: Update your UltraDNS configured CNAMEs to point to EC2 instance public
|
70
70
|
hostnames
|
71
71
|
email:
|