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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1351fbe44fd9d8e912acd128d43ae4a121d8f9a3
4
- data.tar.gz: a784a527ae399411c25cf5563784f9fc61c0adb9
3
+ metadata.gz: 0c2e09d888f693e2ff73513b1632f34cc3787a67
4
+ data.tar.gz: 13a1ab89aaa0a6364549fd21377ad4bc54f52efe
5
5
  SHA512:
6
- metadata.gz: bb29f18f62383b9dfb9157869324b0a8281c7bddf04cc6fbeebc8dd58a3a3560dff64208ca9d8cf14c48a3968c936ccbd8282d9d08233661f6d9c6dd35ca5893
7
- data.tar.gz: 7caba6ba8454074e0c909b9c1ecee939d7898d1f2f1ce2a40c1929b1836896a5746ee65082d549586bc8cca1045630470be4e4b84de95cf7f187072c1444c5da
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
- Eipmap::DSL.convert(exported, @options)
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)
@@ -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
- <<-EOS
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
@@ -1,3 +1,3 @@
1
1
  module Eipmap
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
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.0
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-13 00:00:00.000000000 Z
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.4.1
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).