eipmap 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eipmap/client.rb +7 -1
- data/lib/eipmap/driver.rb +15 -0
- data/lib/eipmap/dsl/converter.rb +9 -1
- data/lib/eipmap/version.rb +1 -1
- data/spec/eipmap_spec.rb +18 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c2e09d888f693e2ff73513b1632f34cc3787a67
|
4
|
+
data.tar.gz: 13a1ab89aaa0a6364549fd21377ad4bc54f52efe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6435276c495116ff0db70e7afdc44cf9538183e822133a552d4f742316171d8d95fb5a265598fd8db9370052d54f2d55d9f08cd6840cf5a4a258b767f11d25eb
|
7
|
+
data.tar.gz: 0db786e666503f67ac238031dcf75be58dd6cbea246eaa5e339a0155da1cceb57a2712fc9c66d69ecc58bd544cefc46256a1b34358427c88163674cbc516a192
|
data/lib/eipmap/client.rb
CHANGED
@@ -10,7 +10,13 @@ class Eipmap::Client
|
|
10
10
|
|
11
11
|
def export
|
12
12
|
exported = Eipmap::Exporter.export(@ec2, @options)
|
13
|
-
|
13
|
+
|
14
|
+
instance_ids = exported.map {|domain, ips|
|
15
|
+
ips.map {|ip, attrs| attrs[:instance_id] }
|
16
|
+
}.flatten.select {|i| i }
|
17
|
+
|
18
|
+
instance_names = @driver.describe_instance_names(instance_ids)
|
19
|
+
Eipmap::DSL.convert(exported, @options.merge(:instance_names => instance_names))
|
14
20
|
end
|
15
21
|
|
16
22
|
def apply(file)
|
data/lib/eipmap/driver.rb
CHANGED
@@ -14,6 +14,21 @@ class Eipmap::Driver
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
def describe_instance_names(instance_ids)
|
18
|
+
id_names = {}
|
19
|
+
|
20
|
+
@ec2.describe_instances(:instance_ids => instance_ids).each do |resp|
|
21
|
+
resp.reservations.each do |reservation|
|
22
|
+
reservation.instances.each do |instance|
|
23
|
+
tag = instance.tags.find {|t| t.key == 'Name' }
|
24
|
+
id_names[instance.instance_id] = tag.value if tag
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
id_names
|
30
|
+
end
|
31
|
+
|
17
32
|
private
|
18
33
|
|
19
34
|
def associate_address(domain, ip, expected_attrs, actual_attrs)
|
data/lib/eipmap/dsl/converter.rb
CHANGED
@@ -6,6 +6,7 @@ class Eipmap::DSL::Converter
|
|
6
6
|
def initialize(exported, options = {})
|
7
7
|
@exported = exported
|
8
8
|
@options = options
|
9
|
+
@instance_names = options[:instance_names] || {}
|
9
10
|
end
|
10
11
|
|
11
12
|
def convert
|
@@ -54,7 +55,14 @@ end
|
|
54
55
|
args << ip_options.inspect.sub(/\A\{/, '').sub(/\}\z/, '')
|
55
56
|
end
|
56
57
|
|
57
|
-
|
58
|
+
instance_id = attrs[:instance_id]
|
59
|
+
instance_name = @instance_names[instance_id]
|
60
|
+
|
61
|
+
comment = instance_name ? (<<-EOS) : ''
|
62
|
+
# #{instance_id} #{instance_name}
|
63
|
+
EOS
|
64
|
+
|
65
|
+
comment + (<<-EOS)
|
58
66
|
ip #{args.join(', ')}
|
59
67
|
EOS
|
60
68
|
end
|
data/lib/eipmap/version.rb
CHANGED
data/spec/eipmap_spec.rb
CHANGED
@@ -116,4 +116,22 @@ end
|
|
116
116
|
expect(describe_addresses["vpc"]).to eq swapped_eips_with_one_assoc
|
117
117
|
end
|
118
118
|
end
|
119
|
+
|
120
|
+
context "when dry-run" do
|
121
|
+
subject { client(dry_run: true) }
|
122
|
+
|
123
|
+
it do
|
124
|
+
dsl = <<-EOS
|
125
|
+
domain "vpc" do
|
126
|
+
<%- eips.each do |public_ip, attrs| -%>
|
127
|
+
ip "<%= public_ip %>", <%= attrs.inspect %>
|
128
|
+
<%- end -%>
|
129
|
+
end
|
130
|
+
EOS
|
131
|
+
|
132
|
+
result = apply(subject) { dsl }
|
133
|
+
expect(result).to be_falsey
|
134
|
+
expect(describe_addresses["vpc"].values).to match_array [{}, {}, {}]
|
135
|
+
end
|
136
|
+
end
|
119
137
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eipmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
version: '0'
|
160
160
|
requirements: []
|
161
161
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.
|
162
|
+
rubygems_version: 2.0.14
|
163
163
|
signing_key:
|
164
164
|
specification_version: 4
|
165
165
|
summary: Eipmap is a tool to manage Elastic IP Addresses (EIP).
|