vm_shepherd 3.1.8 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vm_shepherd/aws_manager.rb +13 -5
- data/lib/vm_shepherd/shepherd.rb +2 -13
- data/lib/vm_shepherd/version.rb +1 -1
- data/spec/vm_shepherd/aws_manager_spec.rb +23 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7934b21954a88c73bdfb023a264734be53b0ce6d
|
4
|
+
data.tar.gz: 9d0c1971e9eab775684389e200f1f826827d325a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b182c70312c21509a5536e84669520c757381cf4068de1cc676ff54c77b0dde8c4fac6e188bec2a995c72d7af3c67217b45f60228aa5add9a129444ae7105e32
|
7
|
+
data.tar.gz: 918c50edb94876dc9638d9858804409a907690100136bf1b53b747617fc5d6417f3fb39cebd50f157fb131415d27ec6f25ce7de0a7bc26d60a0c06f0c6c199f3
|
@@ -50,7 +50,7 @@ module VmShepherd
|
|
50
50
|
else
|
51
51
|
if ROLLBACK_COMPLETE == status
|
52
52
|
logger.info("Rolling back stack [#{stack.name}]; events listed below")
|
53
|
-
stack.events.select{|event| event.resource_status_reason}.each do |failed_event|
|
53
|
+
stack.events.select { |event| event.resource_status_reason }.each do |failed_event|
|
54
54
|
logger.info("#{failed_event.resource_properties} #{failed_event.resource_status_reason}")
|
55
55
|
end
|
56
56
|
stack.delete
|
@@ -213,9 +213,7 @@ module VmShepherd
|
|
213
213
|
end
|
214
214
|
|
215
215
|
def create_elb(stack, elb_config)
|
216
|
-
elb = AWS::ELB.new
|
217
216
|
elb_params = {
|
218
|
-
load_balancer_name: elb_config['name'],
|
219
217
|
listeners: [],
|
220
218
|
subnets: [subnet_id(stack, elb_config)],
|
221
219
|
security_groups: [create_security_group(stack, elb_config).security_group_id]
|
@@ -228,8 +226,18 @@ module VmShepherd
|
|
228
226
|
}
|
229
227
|
end
|
230
228
|
|
231
|
-
logger.info(
|
232
|
-
elb.
|
229
|
+
logger.info("Creating #{elb_config['name']} ELB")
|
230
|
+
elb = AWS::ELB.new.load_balancers.create(elb_config['name'], elb_params)
|
231
|
+
port = elb_config.fetch('health_check', {})['ping_target'] || 'TCP:80'
|
232
|
+
elb.configure_health_check(
|
233
|
+
{
|
234
|
+
target: port,
|
235
|
+
healthy_threshold: 2,
|
236
|
+
unhealthy_threshold: 5,
|
237
|
+
interval: 5,
|
238
|
+
timeout: 2,
|
239
|
+
}
|
240
|
+
)
|
233
241
|
end
|
234
242
|
|
235
243
|
def create_security_group(stack, elb_config)
|
data/lib/vm_shepherd/shepherd.rb
CHANGED
@@ -220,19 +220,8 @@ module VmShepherd
|
|
220
220
|
end
|
221
221
|
|
222
222
|
def ami_elb_config
|
223
|
-
|
224
|
-
|
225
|
-
'elbs' => @env_config.dig('elbs').map do |elb|
|
226
|
-
{
|
227
|
-
'name' => elb.dig('name'),
|
228
|
-
'port_mappings' => elb.dig('port_mappings'),
|
229
|
-
'stack_output_keys' => elb.dig('stack_output_keys'),
|
230
|
-
}
|
231
|
-
end
|
232
|
-
}
|
233
|
-
else
|
234
|
-
{}
|
235
|
-
end
|
223
|
+
return {} unless @env_config.dig('elbs')
|
224
|
+
{'elbs' => @env_config.dig('elbs')}
|
236
225
|
end
|
237
226
|
|
238
227
|
def openstack_vm_manager(vm_shepherd_config)
|
data/lib/vm_shepherd/version.rb
CHANGED
@@ -61,8 +61,8 @@ module VmShepherd
|
|
61
61
|
let(:cfm) { instance_double(AWS::CloudFormation, stacks: stack_collection) }
|
62
62
|
let(:stack) { instance_double(AWS::CloudFormation::Stack, status: 'CREATE_COMPLETE') }
|
63
63
|
let(:stack_collection) { instance_double(AWS::CloudFormation::StackCollection) }
|
64
|
-
let(:elb) { instance_double(AWS::ELB,
|
65
|
-
let(:
|
64
|
+
let(:elb) { instance_double(AWS::ELB, load_balancers: load_balancers) }
|
65
|
+
let(:load_balancers) { instance_double(AWS::ELB::LoadBalancerCollection) }
|
66
66
|
|
67
67
|
before do
|
68
68
|
allow(AWS::CloudFormation).to receive(:new).and_return(cfm)
|
@@ -120,6 +120,9 @@ module VmShepherd
|
|
120
120
|
{
|
121
121
|
'name' => 'elb-1-name',
|
122
122
|
'port_mappings' => [[1111, 11]],
|
123
|
+
'health_check' => {
|
124
|
+
'ping_target' => 'TCP:1234',
|
125
|
+
},
|
123
126
|
'stack_output_keys' => {
|
124
127
|
'vpc_id' => 'vpc_id',
|
125
128
|
'subnet_id' => 'private_subnet',
|
@@ -166,6 +169,9 @@ module VmShepherd
|
|
166
169
|
let(:elb_1_security_group) { instance_double(AWS::EC2::SecurityGroup, security_group_id: 'elb-1-security-group-id') }
|
167
170
|
let(:elb_2_security_group) { instance_double(AWS::EC2::SecurityGroup, security_group_id: 'elb-2-security-group-id') }
|
168
171
|
|
172
|
+
let(:elb_1) { instance_double(AWS::ELB::LoadBalancer, configure_health_check: nil) }
|
173
|
+
let(:elb_2) { instance_double(AWS::ELB::LoadBalancer) }
|
174
|
+
|
169
175
|
before do
|
170
176
|
allow(ec2).to receive(:client).and_return(ec2_client)
|
171
177
|
allow(ec2_client).to receive(:create_security_group).with(hash_including(group_name: 'fake-stack-name_elb-1-name')).
|
@@ -175,7 +181,7 @@ module VmShepherd
|
|
175
181
|
allow(ec2).to receive(:security_groups).and_return(security_groups)
|
176
182
|
allow(elb_1_security_group).to receive(:authorize_ingress)
|
177
183
|
allow(elb_2_security_group).to receive(:authorize_ingress)
|
178
|
-
allow(
|
184
|
+
allow(load_balancers).to receive(:create).and_return(elb_1)
|
179
185
|
end
|
180
186
|
|
181
187
|
it 'creates and attaches a security group for the ELBs' do
|
@@ -199,21 +205,30 @@ module VmShepherd
|
|
199
205
|
end
|
200
206
|
|
201
207
|
it 'attaches an elb with the name of the stack for the ELBs' do
|
208
|
+
health_check_params = {
|
209
|
+
healthy_threshold: 2,
|
210
|
+
unhealthy_threshold: 5,
|
211
|
+
interval: 5,
|
212
|
+
timeout: 2,
|
213
|
+
}
|
202
214
|
elb_1_params = {
|
203
|
-
load_balancer_name: 'elb-1-name',
|
204
215
|
listeners: [{protocol: 'TCP', load_balancer_port: 1111, instance_protocol: 'TCP', instance_port: 11}],
|
205
216
|
subnets: ['fake-subnet-id'],
|
206
217
|
security_groups: ['elb-1-security-group-id']
|
207
218
|
}
|
208
|
-
expect(
|
219
|
+
expect(load_balancers).to receive(:create).with('elb-1-name', elb_1_params).and_return(elb_1)
|
220
|
+
expect(elb_1).to receive(:configure_health_check).with(
|
221
|
+
health_check_params.merge(target: 'TCP:1234')
|
222
|
+
)
|
209
223
|
elb_2_params = {
|
210
|
-
load_balancer_name: 'elb-2-name',
|
211
224
|
listeners: [{protocol: 'TCP', load_balancer_port: 2222, instance_protocol: 'TCP', instance_port: 22}],
|
212
225
|
subnets: ['fake-subnet-id'],
|
213
226
|
security_groups: ['elb-2-security-group-id']
|
214
227
|
}
|
215
|
-
expect(
|
216
|
-
|
228
|
+
expect(load_balancers).to receive(:create).with('elb-2-name', elb_2_params).and_return(elb_2)
|
229
|
+
expect(elb_2).to receive(:configure_health_check).with(
|
230
|
+
health_check_params.merge(target: 'TCP:80')
|
231
|
+
)
|
217
232
|
ami_manager.prepare_environment(cloudformation_template_file.path)
|
218
233
|
end
|
219
234
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vm_shepherd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ops Manager Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-v1
|