kelbim 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/README.md +28 -1
- data/bin/kelbim +22 -13
- data/lib/kelbim/client.rb +49 -1
- data/lib/kelbim/dsl/converter.rb +33 -8
- data/lib/kelbim/dsl/ec2.rb +2 -2
- data/lib/kelbim/dsl/load-balancer.rb +2 -1
- data/lib/kelbim/dsl.rb +5 -1
- data/lib/kelbim/exporter.rb +5 -0
- data/lib/kelbim/ext/base_text_formatter-ext.rb +25 -0
- data/lib/kelbim/tester.rb +36 -0
- data/lib/kelbim/version.rb +3 -1
- data/lib/kelbim/wrapper/listener-collection.rb +39 -21
- data/lib/kelbim/wrapper/listener.rb +1 -1
- data/lib/kelbim/wrapper/load-balancer-collection.rb +6 -29
- data/lib/kelbim/wrapper/load-balancer.rb +11 -1
- data/lib/kelbim/wrapper/policy-collection.rb +1 -1
- metadata +45 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a3aa9626f47a857cfeb39f3f20b5154099016a6
|
4
|
+
data.tar.gz: 85e9bcd93725b03f76e569c25f7beb56391d2f66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d17e5a9853ba64b82c8d8ef70032bb465ea9a1369743d921144d80f176a6e5574eb991a7ff140f1f7aac113a7ad49cf54b36f74da8e23b35555a04f6a4c8d73
|
7
|
+
data.tar.gz: 0097ad300a14b1c36d3524f0d7b9dd4305400e163e7eb86139c9f3aa93665643ae19dc4c658ea0c6c04b1de12548e46af1efd2ba0a0e5c5dcb8e6eac02be2626
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Kelbim is a tool to manage ELB.
|
|
4
4
|
|
5
5
|
It defines the state of ELB using DSL, and updates ELB according to DSL.
|
6
6
|
|
7
|
-
**Attention! This is
|
7
|
+
**Attention! This is a alpha version!**
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
@@ -100,5 +100,32 @@ ec2 "vpc-XXXXXXXXX" do
|
|
100
100
|
end
|
101
101
|
```
|
102
102
|
|
103
|
+
## Test
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
ec2 "vpc-XXXXXXXXX" do
|
107
|
+
load_balancer "my-load-balancer" do
|
108
|
+
test do
|
109
|
+
host = "my-load-balancer-XXXXXXXXXX.ap-northeast-1.elb.amazonaws.com"
|
110
|
+
|
111
|
+
expect {
|
112
|
+
timeout(3) do
|
113
|
+
socket = TCPSocket.open(host, 8080)
|
114
|
+
socket.close if socket
|
115
|
+
end
|
116
|
+
}.not_to raise_error
|
117
|
+
end
|
118
|
+
...
|
119
|
+
```
|
120
|
+
|
121
|
+
```sh
|
122
|
+
shell> kelbim -t
|
123
|
+
Test `ELBfile`
|
124
|
+
...
|
125
|
+
|
126
|
+
Finished in 3.16 seconds
|
127
|
+
3 examples, 0 failures
|
128
|
+
```
|
129
|
+
|
103
130
|
## Link
|
104
131
|
* [RubyGems.org site](http://rubygems.org/gems/kelbim)
|
data/bin/kelbim
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$: << File.expand_path("#{File.dirname __FILE__}/../lib")
|
3
3
|
require 'rubygems'
|
4
|
+
require 'json'
|
4
5
|
require 'kelbim'
|
5
6
|
require 'optparse'
|
7
|
+
require 'rspec'
|
6
8
|
|
7
9
|
DEFAULT_FILENAME = 'ELBfile'
|
8
10
|
|
@@ -23,18 +25,21 @@ ARGV.options do |opt|
|
|
23
25
|
secret_key = nil
|
24
26
|
region = nil
|
25
27
|
|
26
|
-
opt.on('-k', '--access-key ACCESS_KEY')
|
27
|
-
opt.on('-s', '--secret-key SECRET_KEY')
|
28
|
-
opt.on('-r', '--region REGION')
|
29
|
-
opt.on('-a', '--apply')
|
30
|
-
opt.on('-f', '--file FILE')
|
31
|
-
opt.on('', '--dry-run')
|
32
|
-
opt.on('
|
33
|
-
opt.on('-
|
34
|
-
opt.on('',
|
35
|
-
opt.on('
|
36
|
-
opt.on(''
|
37
|
-
opt.on(''
|
28
|
+
opt.on('-k', '--access-key ACCESS_KEY') {|v| access_key = v }
|
29
|
+
opt.on('-s', '--secret-key SECRET_KEY') {|v| secret_key = v }
|
30
|
+
opt.on('-r', '--region REGION') {|v| region = v }
|
31
|
+
opt.on('-a', '--apply') {|v| mode = :apply }
|
32
|
+
opt.on('-f', '--file FILE') {|v| file = v }
|
33
|
+
opt.on('', '--dry-run') {|v| options[:dry_run] = true }
|
34
|
+
opt.on('', '--without-deleting-policy') {|v| options[:without_deleting_policy] = true }
|
35
|
+
opt.on('-e', '--export') {|v| mode = :export }
|
36
|
+
opt.on('-o', '--output FILE') {|v| output_file = v }
|
37
|
+
opt.on('', '--split') {|v| split = true }
|
38
|
+
opt.on('-t', '--test') {|v| mode = :test }
|
39
|
+
opt.on('', '--show-load-balancers') {|v| mode = :show_load_balancers }
|
40
|
+
opt.on('', '--show-policies') {|v| mode = :show_policies }
|
41
|
+
opt.on('' , '--no-color') { options[:color] = false }
|
42
|
+
opt.on('' , '--debug') { options[:debug] = true }
|
38
43
|
opt.parse!
|
39
44
|
|
40
45
|
if access_key and secret_key
|
@@ -123,8 +128,12 @@ begin
|
|
123
128
|
end
|
124
129
|
|
125
130
|
logger.info("Test `#{file}`")
|
126
|
-
|
131
|
+
RSpec.configuration.color_enabled = options[:color]
|
127
132
|
client.test(file)
|
133
|
+
when :show_load_balancers
|
134
|
+
puts JSON.pretty_generate(client.load_balancers)
|
135
|
+
when :show_policies
|
136
|
+
puts JSON.pretty_generate(client.policies)
|
128
137
|
else
|
129
138
|
raise 'must not happen'
|
130
139
|
end
|
data/lib/kelbim/client.rb
CHANGED
@@ -4,6 +4,7 @@ require 'kelbim/exporter'
|
|
4
4
|
require 'kelbim/ext/ec2-ext'
|
5
5
|
require 'kelbim/ext/elb-load-balancer-ext'
|
6
6
|
require 'kelbim/policy-types'
|
7
|
+
require 'kelbim/tester'
|
7
8
|
require 'kelbim/wrapper/elb-wrapper'
|
8
9
|
require 'kelbim/logger'
|
9
10
|
|
@@ -23,7 +24,54 @@ module Kelbim
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def test(file)
|
26
|
-
|
27
|
+
AWS.memoize do
|
28
|
+
dsl = load_file(file)
|
29
|
+
Tester.test(dsl)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def load_balancers
|
34
|
+
exported = nil
|
35
|
+
|
36
|
+
AWS.memoize do
|
37
|
+
exported = Exporter.export(@options.elb)
|
38
|
+
end
|
39
|
+
|
40
|
+
retval = {}
|
41
|
+
|
42
|
+
exported.map do |vpc, lbs|
|
43
|
+
vpc = vpc || 'classic'
|
44
|
+
retval[vpc] = {}
|
45
|
+
|
46
|
+
lbs.map do |name, attrs|
|
47
|
+
retval[vpc][name] = attrs[:dns_name]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
return retval
|
52
|
+
end
|
53
|
+
|
54
|
+
def policies
|
55
|
+
exported = nil
|
56
|
+
|
57
|
+
AWS.memoize do
|
58
|
+
exported = Exporter.export(@options.elb)
|
59
|
+
end
|
60
|
+
|
61
|
+
retval = {}
|
62
|
+
|
63
|
+
exported.map do |vpc, lbs|
|
64
|
+
vpc = vpc || 'classic'
|
65
|
+
|
66
|
+
lbs.map do |name, attrs|
|
67
|
+
if attrs[:policies]
|
68
|
+
retval[vpc] ||= {}
|
69
|
+
retval[vpc][name] = attrs[:policies]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
return retval
|
27
75
|
end
|
28
76
|
|
29
77
|
def export
|
data/lib/kelbim/dsl/converter.rb
CHANGED
@@ -36,19 +36,16 @@ end
|
|
36
36
|
|
37
37
|
def output_load_balancer(vpc, name, load_balancer)
|
38
38
|
name = name.inspect
|
39
|
-
|
39
|
+
is_internal = (load_balancer[:scheme] == 'internal')
|
40
|
+
internal = is_internal ? ', :internal => true ' : ' '
|
40
41
|
instances = output_instances(load_balancer[:instances], vpc).strip
|
41
42
|
listeners = output_listeners(load_balancer[:listeners]).strip
|
42
43
|
health_check = output_health_check(load_balancer[:health_check]).strip
|
43
|
-
|
44
|
+
testcase = (is_internal and not load_balancer.fetch(:listeners, []).empty?) ? '' : ("\n " + output_testcase(load_balancer).strip + "\n")
|
44
45
|
|
45
46
|
out = <<-EOS
|
46
|
-
load_balancer #{name}#{internal}do
|
47
|
-
|
48
|
-
# #host = #{dns_name.inspect}
|
49
|
-
# #expect(Net::HTTP.start(host, 80).get("/")).to be_a(Net::HTTPOK)
|
50
|
-
#end
|
51
|
-
|
47
|
+
load_balancer #{name}#{internal}do#{
|
48
|
+
testcase}
|
52
49
|
#{instances}
|
53
50
|
|
54
51
|
#{listeners}
|
@@ -92,6 +89,34 @@ end
|
|
92
89
|
return out
|
93
90
|
end
|
94
91
|
|
92
|
+
def output_testcase(load_balancer)
|
93
|
+
dns_name = load_balancer[:dns_name]
|
94
|
+
ports = load_balancer[:listeners].map {|i| i[:port] }
|
95
|
+
|
96
|
+
out = <<-EOS
|
97
|
+
test do
|
98
|
+
host = #{dns_name.inspect}
|
99
|
+
EOS
|
100
|
+
|
101
|
+
ports.each do |port|
|
102
|
+
out.concat(<<-EOS)
|
103
|
+
|
104
|
+
expect {
|
105
|
+
timeout(3) do
|
106
|
+
socket = TCPSocket.open(host, #{port})
|
107
|
+
socket.close if socket
|
108
|
+
end
|
109
|
+
}.not_to raise_error
|
110
|
+
EOS
|
111
|
+
end
|
112
|
+
|
113
|
+
out.concat(<<-EOS)
|
114
|
+
end
|
115
|
+
EOS
|
116
|
+
|
117
|
+
return out
|
118
|
+
end
|
119
|
+
|
95
120
|
def output_instances(instances, vpc)
|
96
121
|
if instances.empty?
|
97
122
|
instances = '# not registered'
|
data/lib/kelbim/dsl/ec2.rb
CHANGED
@@ -7,13 +7,13 @@ module Kelbim
|
|
7
7
|
class EC2
|
8
8
|
attr_reader :result
|
9
9
|
|
10
|
-
def initialize(vpc, &block)
|
10
|
+
def initialize(vpc, load_balancers, &block)
|
11
11
|
@names = []
|
12
12
|
@error_identifier = "EC2 `#{vpc || :classic}`"
|
13
13
|
|
14
14
|
@result = OpenStruct.new({
|
15
15
|
:vpc => vpc,
|
16
|
-
:load_balancers =>
|
16
|
+
:load_balancers => load_balancers,
|
17
17
|
})
|
18
18
|
|
19
19
|
instance_eval(&block)
|
@@ -18,6 +18,7 @@ module Kelbim
|
|
18
18
|
:name => name,
|
19
19
|
:instances => [],
|
20
20
|
:internal => internal,
|
21
|
+
:scheme => internal ? 'internal' : 'internet-facing',
|
21
22
|
})
|
22
23
|
|
23
24
|
instance_eval(&block)
|
@@ -38,7 +39,7 @@ module Kelbim
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def test(&block)
|
41
|
-
call_once(:
|
42
|
+
call_once(:test)
|
42
43
|
@result.test = block
|
43
44
|
end
|
44
45
|
|
data/lib/kelbim/dsl.rb
CHANGED
@@ -38,7 +38,11 @@ module Kelbim
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def ec2(vpc = nil, &block)
|
41
|
-
@result.ec2s[vpc]
|
41
|
+
if (ec2_result = @result.ec2s[vpc])
|
42
|
+
@result.ec2s[vpc] = EC2.new(vpc, ec2_result.load_balancers, &block).result
|
43
|
+
else
|
44
|
+
@result.ec2s[vpc] = EC2.new(vpc, [], &block).result
|
45
|
+
end
|
42
46
|
end
|
43
47
|
end # DSL
|
44
48
|
end # Kelbim
|
data/lib/kelbim/exporter.rb
CHANGED
@@ -34,6 +34,11 @@ module Kelbim
|
|
34
34
|
:dns_name => load_balancer.dns_name,
|
35
35
|
}
|
36
36
|
|
37
|
+
if load_balancer.policies.first
|
38
|
+
attrs[:policies] = h = {}
|
39
|
+
load_balancer.policies.each {|i| h[i.name] = i.type }
|
40
|
+
end
|
41
|
+
|
37
42
|
if load_balancer.vpc_id
|
38
43
|
attrs[:subnets] = load_balancer.subnets.map {|i| i.id }
|
39
44
|
attrs[:security_groups] = load_balancer.security_groups.map {|i| i.name }
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'rspec/core/formatters/base_text_formatter'
|
3
|
+
|
4
|
+
module RSpec
|
5
|
+
module Core
|
6
|
+
module Formatters
|
7
|
+
class BaseTextFormatter < BaseFormatter
|
8
|
+
def dump_failure_info(example)
|
9
|
+
exception = example.execution_result[:exception]
|
10
|
+
|
11
|
+
if exception.message
|
12
|
+
line = exception.message.to_s.split("\n").first
|
13
|
+
output.puts "#{long_padding}#{failure_color(line)}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def dump_backtrace(example)
|
18
|
+
end
|
19
|
+
|
20
|
+
def dump_commands_to_rerun_failed_examples
|
21
|
+
end
|
22
|
+
end # BaseTextFormatter
|
23
|
+
end # Formatters
|
24
|
+
end # Core
|
25
|
+
end # RSpec
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'net/http'
|
3
|
+
require 'socket'
|
4
|
+
require 'timeout'
|
5
|
+
require 'kelbim/ext/base_text_formatter-ext'
|
6
|
+
require 'kelbim/logger'
|
7
|
+
|
8
|
+
module Kelbim
|
9
|
+
class Tester
|
10
|
+
class << self
|
11
|
+
def test(dsl)
|
12
|
+
self.new(dsl).test
|
13
|
+
end
|
14
|
+
end # of class methods
|
15
|
+
|
16
|
+
def initialize(dsl)
|
17
|
+
@dsl = dsl
|
18
|
+
end
|
19
|
+
|
20
|
+
def test
|
21
|
+
require 'rspec/autorun'
|
22
|
+
|
23
|
+
@dsl.ec2s.each do |vpc, ec2|
|
24
|
+
vpc ||= 'classic'
|
25
|
+
|
26
|
+
ec2.load_balancers.each do |lb|
|
27
|
+
if lb.test
|
28
|
+
RSpec.describe("#{vpc || :classic} > #{lb.name}") {
|
29
|
+
it(&lb.test)
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end # Tester
|
36
|
+
end # Kelbim
|
data/lib/kelbim/version.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'ostruct'
|
2
2
|
require 'kelbim/wrapper/listener'
|
3
|
+
require 'kelbim/wrapper/policy-collection'
|
3
4
|
require 'kelbim/logger'
|
4
5
|
|
5
6
|
module Kelbim
|
@@ -9,36 +10,25 @@ module Kelbim
|
|
9
10
|
class ListenerCollection
|
10
11
|
include Logger::ClientHelper
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
@load_balancer = load_balancer
|
15
|
-
@options = options
|
16
|
-
end
|
17
|
-
|
18
|
-
def each
|
19
|
-
@listeners.each do |lstnr|
|
20
|
-
yield(Listener.new(lstnr, @options))
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def create(dsl)
|
25
|
-
log_id = [[dsl.protocol, dsl.port], [dsl.instance_protocol, dsl.instance_port]].map {|i| i.inspect }.join(' => ')
|
26
|
-
log_id = "#{@load_balancer.vpc_id || :classic} > #{@load_balancer.name} > #{log_id}"
|
27
|
-
log(:info, 'Create Listener', :cyan, log_id)
|
28
|
-
|
29
|
-
if @options.dry_run
|
13
|
+
class << self
|
14
|
+
def create_mock_listener(dsl, load_balancer)
|
30
15
|
lstnr = OpenStruct.new({
|
31
16
|
:protocol => dsl.protocol,
|
32
17
|
:port => dsl.port,
|
33
18
|
:instance_protocol => dsl.instance_protocol,
|
34
19
|
:instance_port => dsl.instance_port,
|
35
|
-
:policies => dsl.policies.map {|i| PolicyCollection.create_mock_policy(i) },
|
20
|
+
:policies => dsl.policies.map {|i| Listener::PolicyCollection.create_mock_policy(i) },
|
21
|
+
:load_balancer => load_balancer,
|
36
22
|
})
|
37
23
|
|
38
24
|
if dsl.server_certificate
|
39
25
|
lstnr.server_certificate = OpenStruct.new(:name => dsl.server_certificate)
|
40
26
|
end
|
41
|
-
|
27
|
+
|
28
|
+
return lstnr
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_listener_options(dsl, iam)
|
42
32
|
lstnr_opts = {
|
43
33
|
:protocol => dsl.protocol,
|
44
34
|
:port => dsl.port,
|
@@ -47,7 +37,7 @@ module Kelbim
|
|
47
37
|
}
|
48
38
|
|
49
39
|
if (ss_name = dsl.server_certificate)
|
50
|
-
ss =
|
40
|
+
ss = iam.server_certificates[ss_name]
|
51
41
|
|
52
42
|
unless ss
|
53
43
|
raise "Can't find ServerCertificate: #{ss_name} in #{load_balancer.vpc_id || :classic} > #{@load_balancer.name}"
|
@@ -56,6 +46,34 @@ module Kelbim
|
|
56
46
|
lstnr_opts[:server_certificate] = ss.arn
|
57
47
|
end
|
58
48
|
|
49
|
+
return lstnr_opts
|
50
|
+
end
|
51
|
+
end # of class methods
|
52
|
+
|
53
|
+
def initialize(listeners, load_balancer, options)
|
54
|
+
@listeners = listeners
|
55
|
+
@load_balancer = load_balancer
|
56
|
+
@options = options
|
57
|
+
end
|
58
|
+
|
59
|
+
def each
|
60
|
+
@listeners.each do |lstnr|
|
61
|
+
yield(Listener.new(lstnr, @options))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def create(dsl)
|
66
|
+
log_id = [[dsl.protocol, dsl.port], [dsl.instance_protocol, dsl.instance_port]].map {|i| i.inspect }.join(' => ')
|
67
|
+
log_id = "#{@load_balancer.vpc_id || :classic} > #{@load_balancer.name} > #{log_id}"
|
68
|
+
log(:info, 'Create Listener', :cyan, log_id)
|
69
|
+
|
70
|
+
lstnr = nil
|
71
|
+
|
72
|
+
if @options.dry_run
|
73
|
+
lstnr = self.class.create_mock_listener(dsl, @load_balancer)
|
74
|
+
else
|
75
|
+
lstnr_opts = self.class.create_listener_options(dsl, @options.iam)
|
76
|
+
|
59
77
|
# lstnr_optsは破壊的に更新される
|
60
78
|
lstnr = @listeners.create(lstnr_opts.dup)
|
61
79
|
@options.updated = true
|
@@ -33,7 +33,7 @@ module Kelbim
|
|
33
33
|
log(:info, 'Update Listener', :green, log_id)
|
34
34
|
|
35
35
|
compare_server_certificate(dsl) do
|
36
|
-
log(:info, " set server_certificate=#{dsl.server_certificate}", :green)
|
36
|
+
log(:info, " set server_certificate=#{dsl.server_certificate ? dsl.server_certificate.name : nil.inspect}", :green)
|
37
37
|
|
38
38
|
unless @options.dry_run
|
39
39
|
ss = @options.iam.server_certificates[dsl.server_certificate]
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'ostruct'
|
2
2
|
require 'kelbim/wrapper/load-balancer'
|
3
|
+
require 'kelbim/wrapper/listener-collection'
|
3
4
|
require 'kelbim/logger'
|
4
5
|
|
5
6
|
module Kelbim
|
@@ -29,19 +30,11 @@ module Kelbim
|
|
29
30
|
:name => dsl.name,
|
30
31
|
:vpc_id => vpc,
|
31
32
|
:instances => dsl.instances,
|
32
|
-
:scheme =>
|
33
|
-
:listeners => listeners,
|
33
|
+
:scheme => dsl.scheme,
|
34
|
+
:listeners => dsl.listeners.map {|i| LoadBalancer::ListenerCollection.create_mock_listener(i, @load_balancer) },
|
34
35
|
:health_check => {}, # health_checkはLoadBalancerの処理で更新
|
35
36
|
})
|
36
37
|
|
37
|
-
listeners.each do |lstnr|
|
38
|
-
lstnr.load_balancer = lb
|
39
|
-
|
40
|
-
if lstnr.server_certificate
|
41
|
-
lstnr.server_certificate = OpenStruct.new(:name => lstnr.server_certificate)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
38
|
if vpc
|
46
39
|
lb.subnets = dsl.subnets.map {|i| OpenStruct.new(:id => i) }
|
47
40
|
sg_names = @options.security_group_names[vpc] || {}
|
@@ -51,30 +44,14 @@ module Kelbim
|
|
51
44
|
end
|
52
45
|
else
|
53
46
|
opts = {
|
54
|
-
:scheme
|
55
|
-
:listeners
|
47
|
+
:scheme => dsl.scheme,
|
48
|
+
:listeners => [],
|
56
49
|
}
|
57
50
|
|
58
51
|
opts[:instances] = dsl.instances unless dsl.instances.empty?
|
59
52
|
|
60
53
|
dsl.listeners.each do |lstnr|
|
61
|
-
lstnr_opts =
|
62
|
-
:port => lstnr.port,
|
63
|
-
:protocol => lstnr.protocol,
|
64
|
-
:instance_protocol => lstnr.instance_protocol,
|
65
|
-
:instance_port => lstnr.instance_port,
|
66
|
-
}
|
67
|
-
|
68
|
-
if (ss_name = lstnr.server_certificate)
|
69
|
-
ss = @options.iam.server_certificates[ss_name]
|
70
|
-
|
71
|
-
unless ss
|
72
|
-
raise "Can't find ServerCertificate: #{ss_name} in #{vpc || :classic} > #{dsl.name}"
|
73
|
-
end
|
74
|
-
|
75
|
-
lstnr_opts[:server_certificate] = ss.arn
|
76
|
-
end
|
77
|
-
|
54
|
+
lstnr_opts = LoadBalancer::ListenerCollection.create_listener_options(lstnr, @options.iam)
|
78
55
|
opts[:listeners] << lstnr_opts
|
79
56
|
end
|
80
57
|
|
@@ -23,6 +23,10 @@ module Kelbim
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def eql?(dsl)
|
26
|
+
compare_scheme(dsl) do
|
27
|
+
log(:warn, "`scheme`('internet-facing' or 'internal') cannot be updated", :yellow, "#{vpc_id || :classic} > #{name}")
|
28
|
+
end
|
29
|
+
|
26
30
|
compare_health_check(dsl) or return false
|
27
31
|
|
28
32
|
if self.vpc_id
|
@@ -65,7 +69,7 @@ module Kelbim
|
|
65
69
|
end
|
66
70
|
|
67
71
|
compare_health_check(dsl) do
|
68
|
-
|
72
|
+
log(:info, ' set health_check=' + dsl.health_check.inspect, :green)
|
69
73
|
|
70
74
|
unless @options.dry_run
|
71
75
|
@load_balancer.configure_health_check(dsl.health_check)
|
@@ -162,6 +166,12 @@ module Kelbim
|
|
162
166
|
end
|
163
167
|
|
164
168
|
private
|
169
|
+
def compare_scheme(dsl)
|
170
|
+
same = (@load_balancer.scheme == dsl.scheme)
|
171
|
+
yield if !same && block_given?
|
172
|
+
return same
|
173
|
+
end
|
174
|
+
|
165
175
|
def compare_health_check(dsl)
|
166
176
|
same = (@load_balancer.health_check.sort == dsl.health_check.sort)
|
167
177
|
yield if !same && block_given?
|
@@ -21,7 +21,7 @@ module Kelbim
|
|
21
21
|
|
22
22
|
if PolicyTypes.name?(dsl_name_or_attrs)
|
23
23
|
plcy.name = dsl_name_or_attrs
|
24
|
-
plcy.
|
24
|
+
plcy.attribute = {'<new policy attribute name>' => ['<new policy attribute value>']}
|
25
25
|
else
|
26
26
|
plcy.name = '<new policy name>'
|
27
27
|
plcy.attributes = PolicyTypes.unexpand(dsl_type, dsl_name_or_attrs)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kelbim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- winebarrel
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.14.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.14.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: bundler
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +94,20 @@ dependencies:
|
|
66
94
|
- - '>='
|
67
95
|
- !ruby/object:Gem::Version
|
68
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.14.1
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.14.1
|
69
111
|
description: Kelbim is a tool to manage ELB. It defines the state of ELB using DSL,
|
70
112
|
and updates ELB according to DSL.
|
71
113
|
email:
|
@@ -87,12 +129,14 @@ files:
|
|
87
129
|
- lib/kelbim/dsl/load-balancer.rb
|
88
130
|
- lib/kelbim/dsl.rb
|
89
131
|
- lib/kelbim/exporter.rb
|
132
|
+
- lib/kelbim/ext/base_text_formatter-ext.rb
|
90
133
|
- lib/kelbim/ext/ec2-ext.rb
|
91
134
|
- lib/kelbim/ext/elb-listener-ext.rb
|
92
135
|
- lib/kelbim/ext/elb-load-balancer-ext.rb
|
93
136
|
- lib/kelbim/ext/string-ext.rb
|
94
137
|
- lib/kelbim/logger.rb
|
95
138
|
- lib/kelbim/policy-types.rb
|
139
|
+
- lib/kelbim/tester.rb
|
96
140
|
- lib/kelbim/version.rb
|
97
141
|
- lib/kelbim/wrapper/elb-wrapper.rb
|
98
142
|
- lib/kelbim/wrapper/listener-collection.rb
|