vm_shepherd 2.0.0 → 2.0.1
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/lib/vm_shepherd/aws_manager.rb +26 -26
- data/lib/vm_shepherd/version.rb +1 -1
- data/spec/vm_shepherd/aws_manager_spec.rb +108 -109
- 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: f2ec2812d65de401f4a75e0231500740b2e4a876
|
4
|
+
data.tar.gz: 51537e8fc0e866193160819e8341f151168a7619
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e1b8e82805557390405832ba23f2cbfa803b897deff275f1810963688e3b28964a37860b53a9a7e5c796a6b20ec479d902f5d3cd495bc6cec0c1e6b7b13b6c3
|
7
|
+
data.tar.gz: c31158a2e130412af7b96bcab1d3240fe235ce69686b58a7981ffb6f5b198d0f0b6200e5454b8b3c1634a37ca73cfbd88382e8fb1e01798f5a3b2bd33e1786fa
|
@@ -18,9 +18,9 @@ module VmShepherd
|
|
18
18
|
|
19
19
|
def initialize(env_config:, logger:)
|
20
20
|
AWS.config(
|
21
|
-
access_key_id: env_config.fetch(
|
22
|
-
secret_access_key: env_config.fetch(
|
23
|
-
region: env_config.fetch(
|
21
|
+
access_key_id: env_config.fetch('aws_access_key'),
|
22
|
+
secret_access_key: env_config.fetch('aws_secret_key'),
|
23
|
+
region: env_config.fetch('region'),
|
24
24
|
)
|
25
25
|
@env_config = env_config
|
26
26
|
@logger = logger
|
@@ -31,7 +31,7 @@ module VmShepherd
|
|
31
31
|
|
32
32
|
cfm = AWS::CloudFormation.new
|
33
33
|
logger.info('Starting CloudFormation Stack Creation')
|
34
|
-
stack = cfm.stacks.create(env_config.fetch(
|
34
|
+
stack = cfm.stacks.create(env_config.fetch('stack_name'), template, parameters: env_config.fetch('parameters'), capabilities: ['CAPABILITY_IAM'])
|
35
35
|
|
36
36
|
logger.info("Waiting for status: #{CREATE_COMPLETE}")
|
37
37
|
retry_until(retry_limit: 60, retry_interval: 30) do
|
@@ -46,11 +46,11 @@ module VmShepherd
|
|
46
46
|
false
|
47
47
|
else
|
48
48
|
stack.delete if status == ROLLBACK_COMPLETE
|
49
|
-
raise "Unexpected status for stack #{env_config.fetch(
|
49
|
+
raise "Unexpected status for stack #{env_config.fetch('stack_name')} : #{status}"
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
env_config.fetch(
|
53
|
+
env_config.fetch('elbs', []).each do |elb_config|
|
54
54
|
create_elb(stack, elb_config)
|
55
55
|
end
|
56
56
|
end
|
@@ -64,9 +64,9 @@ module VmShepherd
|
|
64
64
|
begin
|
65
65
|
AWS.ec2.instances.create(
|
66
66
|
image_id: image_id,
|
67
|
-
key_name: env_config.fetch(
|
68
|
-
security_group_ids: [env_config.fetch(
|
69
|
-
subnet: env_config.fetch(
|
67
|
+
key_name: env_config.fetch('outputs').fetch('ssh_key_name'),
|
68
|
+
security_group_ids: [env_config.fetch('outputs').fetch('security_group')],
|
69
|
+
subnet: env_config.fetch('outputs').fetch('public_subnet_id'),
|
70
70
|
instance_type: OPS_MANAGER_INSTANCE_TYPE
|
71
71
|
)
|
72
72
|
rescue AWS::EC2::Errors::InvalidIPAddress::InUse
|
@@ -85,7 +85,7 @@ module VmShepherd
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
vm_ip_address = vm_config.fetch(
|
88
|
+
vm_ip_address = vm_config.fetch('vm_ip_address', nil)
|
89
89
|
if vm_ip_address
|
90
90
|
logger.info('Associating existing IP to the instance')
|
91
91
|
elastic_ip = AWS::EC2::ElasticIp.new(vm_ip_address)
|
@@ -97,20 +97,20 @@ module VmShepherd
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
instance.associate_elastic_ip(elastic_ip)
|
100
|
-
instance.add_tag('Name', value: vm_config.fetch(
|
100
|
+
instance.add_tag('Name', value: vm_config.fetch('vm_name'))
|
101
101
|
end
|
102
102
|
|
103
103
|
def clean_environment
|
104
|
-
[
|
105
|
-
aws_subnet_id = env_config.fetch(
|
104
|
+
['public_subnet_id', 'private_subnet_id'].each do |subnet_id|
|
105
|
+
aws_subnet_id = env_config.fetch('outputs').fetch(subnet_id)
|
106
106
|
clear_subnet(aws_subnet_id) if aws_subnet_id
|
107
107
|
end
|
108
108
|
|
109
|
-
env_config.fetch(
|
110
|
-
delete_elb(elb_config[
|
109
|
+
env_config.fetch('elbs', []).each do |elb_config|
|
110
|
+
delete_elb(elb_config['name'])
|
111
111
|
end
|
112
112
|
|
113
|
-
bucket_names = env_config.fetch(
|
113
|
+
bucket_names = env_config.fetch('outputs', {}).fetch('s3_bucket_names', []).compact
|
114
114
|
bucket_names.each do |bucket_name|
|
115
115
|
next if bucket_name.empty?
|
116
116
|
bucket = AWS::S3.new.buckets[bucket_name]
|
@@ -120,13 +120,13 @@ module VmShepherd
|
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
|
-
delete_stack(env_config.fetch(
|
123
|
+
delete_stack(env_config.fetch('stack_name'))
|
124
124
|
end
|
125
125
|
|
126
126
|
def destroy(vm_config)
|
127
127
|
AWS.ec2.instances.each do |instance|
|
128
|
-
if instance.tags.to_h['Name'] == vm_config.fetch(
|
129
|
-
vm_ip_address = vm_config.fetch(
|
128
|
+
if instance.tags.to_h['Name'] == vm_config.fetch('vm_name')
|
129
|
+
vm_ip_address = vm_config.fetch('vm_ip_address', nil)
|
130
130
|
elastic_ip = instance.elastic_ip unless vm_ip_address
|
131
131
|
if elastic_ip
|
132
132
|
elastic_ip.disassociate
|
@@ -141,11 +141,11 @@ module VmShepherd
|
|
141
141
|
attr_reader :env_config, :logger
|
142
142
|
|
143
143
|
def subnet_id(stack, elb_config)
|
144
|
-
stack.outputs.detect { |o| o.key == elb_config
|
144
|
+
stack.outputs.detect { |o| o.key == elb_config.dig('stack_output_keys', 'subnet_id') }.value
|
145
145
|
end
|
146
146
|
|
147
147
|
def vpc_id(stack, elb_config)
|
148
|
-
stack.outputs.detect { |o| o.key == elb_config
|
148
|
+
stack.outputs.detect { |o| o.key == elb_config.dig('stack_output_keys', 'vpc_id') }.value
|
149
149
|
end
|
150
150
|
|
151
151
|
def clear_subnet(subnet_id)
|
@@ -198,13 +198,13 @@ module VmShepherd
|
|
198
198
|
def create_elb(stack, elb_config)
|
199
199
|
elb = AWS::ELB.new
|
200
200
|
elb_params = {
|
201
|
-
load_balancer_name: elb_config[
|
201
|
+
load_balancer_name: elb_config['name'],
|
202
202
|
listeners: [],
|
203
203
|
subnets: [subnet_id(stack, elb_config)],
|
204
204
|
security_groups: [create_security_group(stack, elb_config).security_group_id]
|
205
205
|
}
|
206
206
|
|
207
|
-
elb_config[
|
207
|
+
elb_config['port_mappings'].each do |port_mapping|
|
208
208
|
elb_params[:listeners] << {
|
209
209
|
protocol: 'TCP', load_balancer_port: port_mapping[0],
|
210
210
|
instance_protocol: 'TCP', instance_port: port_mapping[1]
|
@@ -218,7 +218,7 @@ module VmShepherd
|
|
218
218
|
def create_security_group(stack, elb_config)
|
219
219
|
vpc_id = vpc_id(stack, elb_config)
|
220
220
|
sg_params = {
|
221
|
-
group_name: [stack.name, elb_config[
|
221
|
+
group_name: [stack.name, elb_config['name']].join('_'),
|
222
222
|
description: 'ELB Security Group',
|
223
223
|
vpc_id: vpc_id,
|
224
224
|
}
|
@@ -227,7 +227,7 @@ module VmShepherd
|
|
227
227
|
security_group_response = AWS.ec2.client.create_security_group(sg_params)
|
228
228
|
|
229
229
|
AWS.ec2.security_groups[security_group_response[:group_id]].tap do |security_group|
|
230
|
-
elb_config[
|
230
|
+
elb_config['port_mappings'].each do |port_mapping|
|
231
231
|
security_group.authorize_ingress(:tcp, port_mapping[0], '0.0.0.0/0')
|
232
232
|
end
|
233
233
|
end
|
@@ -260,7 +260,7 @@ module VmShepherd
|
|
260
260
|
end
|
261
261
|
|
262
262
|
def read_ami_id(ami_file_path)
|
263
|
-
YAML.load_file(ami_file_path)[env_config.fetch(
|
263
|
+
YAML.load_file(ami_file_path)[env_config.fetch('region')]
|
264
264
|
end
|
265
265
|
end
|
266
266
|
end
|
data/lib/vm_shepherd/version.rb
CHANGED
@@ -16,20 +16,20 @@ module VmShepherd
|
|
16
16
|
|
17
17
|
let(:env_config) do
|
18
18
|
{
|
19
|
-
stack_name
|
20
|
-
aws_access_key
|
21
|
-
aws_secret_key
|
22
|
-
region
|
23
|
-
json_file
|
24
|
-
parameters
|
19
|
+
'stack_name' => 'aws-stack-name',
|
20
|
+
'aws_access_key' => 'aws-access-key',
|
21
|
+
'aws_secret_key' => 'aws-secret-key',
|
22
|
+
'region' => 'us-east-1',
|
23
|
+
'json_file' => 'cloudformation.json',
|
24
|
+
'parameters' => {
|
25
25
|
'some_parameter' => 'some-answer',
|
26
26
|
},
|
27
|
-
outputs
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
'outputs' => {
|
28
|
+
'ssh_key_name' => 'ssh-key-name',
|
29
|
+
'security_group' => 'security-group-id',
|
30
|
+
'public_subnet_id' => 'public-subnet-id',
|
31
|
+
'private_subnet_id' => 'private-subnet-id',
|
32
|
+
}.merge(extra_outputs),
|
33
33
|
}.merge(extra_configs)
|
34
34
|
end
|
35
35
|
|
@@ -38,7 +38,7 @@ module VmShepherd
|
|
38
38
|
|
39
39
|
let(:vm_config) do
|
40
40
|
{
|
41
|
-
vm_name
|
41
|
+
'vm_name' => 'some-vm-name',
|
42
42
|
}
|
43
43
|
end
|
44
44
|
let(:fake_logger) { instance_double(Logger).as_null_object }
|
@@ -47,10 +47,10 @@ module VmShepherd
|
|
47
47
|
|
48
48
|
before do
|
49
49
|
expect(AWS).to receive(:config).with(
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
access_key_id: env_config.fetch('aws_access_key'),
|
51
|
+
secret_access_key: env_config.fetch('aws_secret_key'),
|
52
|
+
region: env_config.fetch('region'),
|
53
|
+
)
|
54
54
|
|
55
55
|
allow(AWS).to receive(:ec2).and_return(ec2)
|
56
56
|
allow(ami_manager).to receive(:sleep) # speed up retry logic
|
@@ -79,13 +79,13 @@ module VmShepherd
|
|
79
79
|
|
80
80
|
it 'creates the stack with the correct parameters' do
|
81
81
|
expect(stack_collection).to receive(:create).with(
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
82
|
+
'aws-stack-name',
|
83
|
+
'{}',
|
84
|
+
parameters: {
|
85
|
+
'some_parameter' => 'some-answer',
|
86
|
+
},
|
87
|
+
capabilities: ['CAPABILITY_IAM']
|
88
|
+
)
|
89
89
|
ami_manager.prepare_environment(cloudformation_template_file.path)
|
90
90
|
end
|
91
91
|
|
@@ -97,7 +97,7 @@ module VmShepherd
|
|
97
97
|
|
98
98
|
it 'stops retrying after 30 times' do
|
99
99
|
expect(stack).to receive(:status).and_return('CREATE_IN_PROGRESS').
|
100
|
-
|
100
|
+
exactly(60).times
|
101
101
|
|
102
102
|
expect { ami_manager.prepare_environment(cloudformation_template_file.path) }.to raise_error(AwsManager::RetryLimitExceeded)
|
103
103
|
end
|
@@ -114,32 +114,32 @@ module VmShepherd
|
|
114
114
|
context 'when the elb setting is present' do
|
115
115
|
let(:extra_configs) do
|
116
116
|
{
|
117
|
-
elbs
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
117
|
+
'elbs' => [
|
118
|
+
{
|
119
|
+
'name' => 'elb-1-name',
|
120
|
+
'port_mappings' => [[1111, 11]],
|
121
|
+
'stack_output_keys' => {
|
122
|
+
'vpc_id' => 'vpc_id',
|
123
|
+
'subnet_id' => 'private_subnet',
|
124
|
+
},
|
125
|
+
},
|
126
|
+
{
|
127
|
+
'name' => 'elb-2-name',
|
128
|
+
'port_mappings' => [[2222, 22]],
|
129
|
+
'stack_output_keys' => {
|
130
|
+
'vpc_id' => 'vpc_id',
|
131
|
+
'subnet_id' => 'private_subnet',
|
132
|
+
},
|
133
|
+
}
|
134
|
+
],
|
135
135
|
}
|
136
136
|
end
|
137
137
|
let(:stack) do
|
138
138
|
instance_double(AWS::CloudFormation::Stack,
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
139
|
+
name: 'fake-stack-name',
|
140
|
+
creation_time: Time.utc(2015, 5, 29),
|
141
|
+
status: 'CREATE_COMPLETE',
|
142
|
+
outputs: stack_outputs
|
143
143
|
)
|
144
144
|
end
|
145
145
|
let(:stack_outputs) do
|
@@ -167,9 +167,9 @@ module VmShepherd
|
|
167
167
|
before do
|
168
168
|
allow(ec2).to receive(:client).and_return(ec2_client)
|
169
169
|
allow(ec2_client).to receive(:create_security_group).with(hash_including(group_name: 'fake-stack-name_elb-1-name')).
|
170
|
-
|
170
|
+
and_return(create_security_group_response_1)
|
171
171
|
allow(ec2_client).to receive(:create_security_group).with(hash_including(group_name: 'fake-stack-name_elb-2-name')).
|
172
|
-
|
172
|
+
and_return(create_security_group_response_2)
|
173
173
|
allow(ec2).to receive(:security_groups).and_return(security_groups)
|
174
174
|
allow(elb_1_security_group).to receive(:authorize_ingress)
|
175
175
|
allow(elb_2_security_group).to receive(:authorize_ingress)
|
@@ -231,11 +231,11 @@ module VmShepherd
|
|
231
231
|
|
232
232
|
it 'creates an instance using AWS SDK v1' do
|
233
233
|
expect(ec2).to receive_message_chain(:instances, :create).with(
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
234
|
+
image_id: ami_id,
|
235
|
+
key_name: 'ssh-key-name',
|
236
|
+
security_group_ids: ['security-group-id'],
|
237
|
+
subnet: 'public-subnet-id',
|
238
|
+
instance_type: 'm3.medium').and_return(instance)
|
239
239
|
|
240
240
|
ami_manager.deploy(ami_file_path: ami_file_path, vm_config: vm_config)
|
241
241
|
end
|
@@ -250,7 +250,7 @@ module VmShepherd
|
|
250
250
|
|
251
251
|
it 'stops retrying after 60 times' do
|
252
252
|
expect(instances).to receive(:create).and_raise(AWS::EC2::Errors::InvalidIPAddress::InUse).
|
253
|
-
|
253
|
+
exactly(AwsManager::RETRY_LIMIT).times
|
254
254
|
|
255
255
|
expect { ami_manager.deploy(ami_file_path: ami_file_path, vm_config: vm_config) }.to raise_error(AwsManager::RetryLimitExceeded)
|
256
256
|
end
|
@@ -264,7 +264,7 @@ module VmShepherd
|
|
264
264
|
|
265
265
|
it 'handles API endpoints not knowing (right away) about the instance created' do
|
266
266
|
expect(instance).to receive(:status).and_raise(AWS::EC2::Errors::InvalidInstanceID::NotFound).
|
267
|
-
|
267
|
+
exactly(AwsManager::RETRY_LIMIT - 1).times
|
268
268
|
expect(instance).to receive(:status).and_return(:running).once
|
269
269
|
|
270
270
|
ami_manager.deploy(ami_file_path: ami_file_path, vm_config: vm_config)
|
@@ -272,7 +272,7 @@ module VmShepherd
|
|
272
272
|
|
273
273
|
it 'stops retrying after 60 times' do
|
274
274
|
expect(instance).to receive(:status).and_return(:pending).
|
275
|
-
|
275
|
+
exactly(AwsManager::RETRY_LIMIT).times
|
276
276
|
|
277
277
|
expect { ami_manager.deploy(ami_file_path: ami_file_path, vm_config: vm_config) }.to raise_error(AwsManager::RetryLimitExceeded)
|
278
278
|
end
|
@@ -307,8 +307,8 @@ module VmShepherd
|
|
307
307
|
context 'vm configuration contains an elastic IP' do
|
308
308
|
let(:vm_config) do
|
309
309
|
{
|
310
|
-
vm_name
|
311
|
-
vm_ip_address
|
310
|
+
'vm_name' => 'some-vm-name',
|
311
|
+
'vm_ip_address' => 'some-ip-address'
|
312
312
|
}
|
313
313
|
end
|
314
314
|
|
@@ -392,13 +392,12 @@ module VmShepherd
|
|
392
392
|
|
393
393
|
it 'stops retrying after 60 times' do
|
394
394
|
expect(stack).to receive(:status).and_return('DELETE_IN_PROGRESS').
|
395
|
-
|
395
|
+
exactly(60).times
|
396
396
|
|
397
397
|
expect { ami_manager.clean_environment }.to raise_error(AwsManager::RetryLimitExceeded)
|
398
398
|
end
|
399
399
|
|
400
400
|
|
401
|
-
|
402
401
|
it 'aborts if stack reports unexpected status' do
|
403
402
|
expect(stack).to receive(:status).and_return('DELETE_IN_PROGRESS', 'UNEXPECTED_STATUS').ordered
|
404
403
|
expect {
|
@@ -439,7 +438,7 @@ module VmShepherd
|
|
439
438
|
|
440
439
|
context 'when a subnet is not provided' do
|
441
440
|
before do
|
442
|
-
env_config[
|
441
|
+
env_config['outputs']['private_subnet_id'] = nil
|
443
442
|
end
|
444
443
|
|
445
444
|
it 'only deletes instance 1' do
|
@@ -453,40 +452,40 @@ module VmShepherd
|
|
453
452
|
context 'when an elb is configured' do
|
454
453
|
let(:extra_configs) do
|
455
454
|
{
|
456
|
-
elbs
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
455
|
+
'elbs' => [
|
456
|
+
{
|
457
|
+
'name' => 'elb-1-name',
|
458
|
+
'port_mappings' => [[1111, 11]],
|
459
|
+
'stack_output_keys' => {
|
460
|
+
'vpc_id' => 'vpc_id',
|
461
|
+
'subnet_id' => 'private_subnet',
|
462
|
+
},
|
463
|
+
},
|
464
|
+
{
|
465
|
+
'name' => 'elb-2-name',
|
466
|
+
'port_mappings' => [[2222, 22]],
|
467
|
+
'stack_output_keys' => {
|
468
|
+
'vpc_id' => 'vpc_id',
|
469
|
+
'subnet_id' => 'private_subnet',
|
470
|
+
},
|
471
|
+
}
|
472
|
+
],
|
474
473
|
}
|
475
474
|
end
|
476
475
|
|
477
476
|
let(:elb) { instance_double(AWS::ELB, load_balancers: [load_balancer_1_to_delete, load_balancer_2_to_delete, other_load_balancer]) }
|
478
477
|
let(:load_balancer_1_to_delete) do
|
479
478
|
instance_double(AWS::ELB::LoadBalancer,
|
480
|
-
|
481
|
-
|
482
|
-
|
479
|
+
name: 'elb-1-name',
|
480
|
+
security_groups: [elb_1_security_group],
|
481
|
+
exists?: false,
|
483
482
|
)
|
484
483
|
end
|
485
484
|
let(:load_balancer_2_to_delete) do
|
486
485
|
instance_double(AWS::ELB::LoadBalancer,
|
487
|
-
|
488
|
-
|
489
|
-
|
486
|
+
name: 'elb-2-name',
|
487
|
+
security_groups: [elb_2_security_group],
|
488
|
+
exists?: false,
|
490
489
|
)
|
491
490
|
end
|
492
491
|
let(:other_load_balancer) { instance_double(AWS::ELB::LoadBalancer, name: 'other-elb-name') }
|
@@ -494,39 +493,39 @@ module VmShepherd
|
|
494
493
|
let(:elb_2_security_group) { instance_double(AWS::EC2::SecurityGroup, name: 'elb-2-security-group', id: 'sg-elb-2-id') }
|
495
494
|
let(:network_interface_1_elb_1) do
|
496
495
|
instance_double(AWS::EC2::NetworkInterface,
|
497
|
-
|
498
|
-
|
496
|
+
security_groups: [elb_1_security_group],
|
497
|
+
exists?: false,
|
499
498
|
)
|
500
499
|
end
|
501
500
|
let(:network_interface_2_elb_1) do
|
502
501
|
instance_double(AWS::EC2::NetworkInterface,
|
503
|
-
|
504
|
-
|
502
|
+
security_groups: [elb_1_security_group],
|
503
|
+
exists?: false,
|
505
504
|
)
|
506
505
|
end
|
507
506
|
let(:network_interface_1_elb_2) do
|
508
507
|
instance_double(AWS::EC2::NetworkInterface,
|
509
|
-
|
510
|
-
|
508
|
+
security_groups: [elb_2_security_group],
|
509
|
+
exists?: false,
|
511
510
|
)
|
512
511
|
end
|
513
512
|
let(:network_interface_2_elb_2) do
|
514
513
|
instance_double(AWS::EC2::NetworkInterface,
|
515
|
-
|
516
|
-
|
514
|
+
security_groups: [elb_2_security_group],
|
515
|
+
exists?: false,
|
517
516
|
)
|
518
517
|
end
|
519
518
|
|
520
519
|
before do
|
521
520
|
allow(AWS::ELB).to receive(:new).and_return(elb)
|
522
521
|
allow(ec2).to receive(:network_interfaces).and_return(
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
522
|
+
[
|
523
|
+
network_interface_1_elb_1,
|
524
|
+
network_interface_2_elb_1,
|
525
|
+
network_interface_1_elb_2,
|
526
|
+
network_interface_2_elb_2,
|
527
|
+
]
|
528
|
+
)
|
530
529
|
allow(load_balancer_1_to_delete).to receive(:delete)
|
531
530
|
allow(load_balancer_2_to_delete).to receive(:delete)
|
532
531
|
allow(elb_1_security_group).to receive(:delete)
|
@@ -535,7 +534,7 @@ module VmShepherd
|
|
535
534
|
|
536
535
|
it 'waits for the ELBs to be deleted' do
|
537
536
|
expect(load_balancer_1_to_delete).to receive(:exists?).and_return(true).
|
538
|
-
|
537
|
+
exactly(30).times
|
539
538
|
expect(load_balancer_2_to_delete).not_to receive(:exists?)
|
540
539
|
|
541
540
|
expect(elb_1_security_group).not_to receive(:delete).ordered
|
@@ -548,9 +547,9 @@ module VmShepherd
|
|
548
547
|
allow(load_balancer_2_to_delete).to receive(:exists?).and_return(false)
|
549
548
|
|
550
549
|
expect(network_interface_1_elb_1).to receive(:exists?).and_return(false).
|
551
|
-
|
550
|
+
exactly(30).times
|
552
551
|
expect(network_interface_2_elb_1).to receive(:exists?).and_return(true).
|
553
|
-
|
552
|
+
exactly(30).times
|
554
553
|
expect(network_interface_1_elb_2).not_to receive(:exists?)
|
555
554
|
expect(network_interface_2_elb_2).not_to receive(:exists?)
|
556
555
|
|
@@ -627,7 +626,7 @@ module VmShepherd
|
|
627
626
|
context 'when there is an s3 bucket configuration' do
|
628
627
|
let(:bucket_1) { instance_double(AWS::S3::Bucket) }
|
629
628
|
let(:bucket_2) { instance_double(AWS::S3::Bucket) }
|
630
|
-
let(:extra_outputs) { {s3_bucket_names
|
629
|
+
let(:extra_outputs) { {'s3_bucket_names' => [bucket_name_1, bucket_name_2]} }
|
631
630
|
let(:bucket_name_1) { 'bucket-name-1' }
|
632
631
|
let(:bucket_name_2) { 'bucket-name-2' }
|
633
632
|
|
@@ -677,7 +676,7 @@ module VmShepherd
|
|
677
676
|
|
678
677
|
context 'and the bucket name is empty' do
|
679
678
|
let(:bucket_name_3) { '' }
|
680
|
-
let(:extra_outputs) { {s3_bucket_names
|
679
|
+
let(:extra_outputs) { {'s3_bucket_names' => [bucket_name_3, bucket_name_1, bucket_name_2]} }
|
681
680
|
|
682
681
|
before do
|
683
682
|
allow(bucket_1).to receive(:exists?).and_return(true)
|
@@ -694,7 +693,7 @@ module VmShepherd
|
|
694
693
|
|
695
694
|
context 'and the bucket name is null' do
|
696
695
|
let(:bucket_name_3) { nil }
|
697
|
-
let(:extra_outputs) { {s3_bucket_names
|
696
|
+
let(:extra_outputs) { {'s3_bucket_names' => [bucket_name_3, bucket_name_1, bucket_name_2]} }
|
698
697
|
|
699
698
|
before do
|
700
699
|
allow(bucket_1).to receive(:exists?).and_return(true)
|
@@ -756,8 +755,8 @@ module VmShepherd
|
|
756
755
|
let(:elastic_ip) { instance_double(AWS::EC2::ElasticIp) }
|
757
756
|
let(:vm_config) do
|
758
757
|
{
|
759
|
-
vm_name
|
760
|
-
vm_ip_address
|
758
|
+
'vm_name' => 'some-vm-name',
|
759
|
+
'vm_ip_address' => 'some-ip-address'
|
761
760
|
}
|
762
761
|
end
|
763
762
|
|
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: 2.0.
|
4
|
+
version: 2.0.1
|
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-01-
|
11
|
+
date: 2016-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-v1
|