vm_shepherd 1.11.0 → 1.11.1
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.rb +3 -3
- data/lib/vm_shepherd/aws_manager.rb +29 -26
- data/lib/vm_shepherd/openstack_manager.rb +30 -30
- data/lib/vm_shepherd/retry_helper.rb +2 -2
- data/lib/vm_shepherd/shepherd.rb +43 -43
- data/lib/vm_shepherd/vcloud/deployer.rb +3 -3
- data/lib/vm_shepherd/vcloud/destroyer.rb +1 -1
- data/lib/vm_shepherd/vcloud/vapp_config.rb +40 -40
- data/lib/vm_shepherd/vcloud_manager.rb +5 -5
- data/lib/vm_shepherd/version.rb +1 -1
- data/lib/vm_shepherd/vsphere_manager.rb +34 -34
- data/spec/vm_shepherd/aws_manager_spec.rb +74 -57
- data/spec/vm_shepherd/data_object_spec.rb +2 -2
- data/spec/vm_shepherd/openstack_manager_spec.rb +43 -43
- data/spec/vm_shepherd/shepherd_spec.rb +120 -120
- data/spec/vm_shepherd/vcloud/deployer_spec.rb +4 -4
- data/spec/vm_shepherd/vcloud/vapp_config_spec.rb +4 -4
- data/spec/vm_shepherd/vcloud_manager_spec.rb +43 -43
- data/spec/vm_shepherd/vsphere_manager_spec.rb +5 -5
- data/vm_shepherd.gemspec +11 -11
- metadata +3 -3
@@ -5,12 +5,12 @@ module VmShepherd
|
|
5
5
|
attr_reader :name, :gateway, :dns, :ntp, :ip, :netmask, :catalog, :network
|
6
6
|
|
7
7
|
def initialize(name:, ip:, gateway:, netmask:, dns:, ntp:, catalog:, network:)
|
8
|
-
@name
|
9
|
-
@ip
|
8
|
+
@name = name
|
9
|
+
@ip = ip
|
10
10
|
@gateway = gateway
|
11
11
|
@netmask = netmask
|
12
|
-
@dns
|
13
|
-
@ntp
|
12
|
+
@dns = dns
|
13
|
+
@ntp = ntp
|
14
14
|
@catalog = catalog
|
15
15
|
@network = network
|
16
16
|
end
|
@@ -18,58 +18,58 @@ module VmShepherd
|
|
18
18
|
def build_properties
|
19
19
|
[
|
20
20
|
{
|
21
|
-
'type'
|
22
|
-
'key'
|
23
|
-
'value'
|
24
|
-
'password'
|
21
|
+
'type' => 'string',
|
22
|
+
'key' => 'gateway',
|
23
|
+
'value' => gateway,
|
24
|
+
'password' => 'false',
|
25
25
|
'userConfigurable' => 'true',
|
26
|
-
'Label'
|
27
|
-
'Description'
|
26
|
+
'Label' => 'Default Gateway',
|
27
|
+
'Description' => 'The default gateway address for the VM network. Leave blank if DHCP is desired.'
|
28
28
|
},
|
29
29
|
{
|
30
|
-
'type'
|
31
|
-
'key'
|
32
|
-
'value'
|
33
|
-
'password'
|
30
|
+
'type' => 'string',
|
31
|
+
'key' => 'DNS',
|
32
|
+
'value' => dns,
|
33
|
+
'password' => 'false',
|
34
34
|
'userConfigurable' => 'true',
|
35
|
-
'Label'
|
36
|
-
'Description'
|
35
|
+
'Label' => 'DNS',
|
36
|
+
'Description' => 'The domain name servers for the VM (comma separated). Leave blank if DHCP is desired.',
|
37
37
|
},
|
38
38
|
{
|
39
|
-
'type'
|
40
|
-
'key'
|
41
|
-
'value'
|
42
|
-
'password'
|
39
|
+
'type' => 'string',
|
40
|
+
'key' => 'ntp_servers',
|
41
|
+
'value' => ntp,
|
42
|
+
'password' => 'false',
|
43
43
|
'userConfigurable' => 'true',
|
44
|
-
'Label'
|
45
|
-
'Description'
|
44
|
+
'Label' => 'NTP Servers',
|
45
|
+
'Description' => 'Comma-delimited list of NTP servers'
|
46
46
|
},
|
47
47
|
{
|
48
|
-
'type'
|
49
|
-
'key'
|
50
|
-
'value'
|
51
|
-
'password'
|
48
|
+
'type' => 'string',
|
49
|
+
'key' => 'admin_password',
|
50
|
+
'value' => 'tempest',
|
51
|
+
'password' => 'true',
|
52
52
|
'userConfigurable' => 'true',
|
53
|
-
'Label'
|
54
|
-
'Description'
|
53
|
+
'Label' => 'Admin Password',
|
54
|
+
'Description' => 'This password is used to SSH into the VM. The username is "tempest".',
|
55
55
|
},
|
56
56
|
{
|
57
|
-
'type'
|
58
|
-
'key'
|
59
|
-
'value'
|
60
|
-
'password'
|
57
|
+
'type' => 'string',
|
58
|
+
'key' => 'ip0',
|
59
|
+
'value' => ip,
|
60
|
+
'password' => 'false',
|
61
61
|
'userConfigurable' => 'true',
|
62
|
-
'Label'
|
63
|
-
'Description'
|
62
|
+
'Label' => 'IP Address',
|
63
|
+
'Description' => 'The IP address for the VM. Leave blank if DHCP is desired.',
|
64
64
|
},
|
65
65
|
{
|
66
|
-
'type'
|
67
|
-
'key'
|
68
|
-
'value'
|
69
|
-
'password'
|
66
|
+
'type' => 'string',
|
67
|
+
'key' => 'netmask0',
|
68
|
+
'value' => netmask,
|
69
|
+
'password' => 'false',
|
70
70
|
'userConfigurable' => 'true',
|
71
|
-
'Label'
|
72
|
-
'Description'
|
71
|
+
'Label' => 'Netmask',
|
72
|
+
'Description' => 'The netmask for the VM network. Leave blank if DHCP is desired.'
|
73
73
|
}
|
74
74
|
]
|
75
75
|
end
|
@@ -6,8 +6,8 @@ module VmShepherd
|
|
6
6
|
class VcloudManager
|
7
7
|
def initialize(login_info, vdc_name, logger)
|
8
8
|
@login_info = login_info
|
9
|
-
@vdc_name
|
10
|
-
@logger
|
9
|
+
@vdc_name = vdc_name
|
10
|
+
@logger = logger
|
11
11
|
end
|
12
12
|
|
13
13
|
def deploy(vapp_template_tar_path, vapp_config)
|
@@ -18,10 +18,10 @@ module VmShepherd
|
|
18
18
|
untar_vapp_template_tar(File.expand_path(vapp_template_tar_path), tmpdir)
|
19
19
|
|
20
20
|
VmShepherd::Vcloud::Deployer.deploy_and_power_on_vapp(
|
21
|
-
client:
|
22
|
-
ovf_dir:
|
21
|
+
client: client,
|
22
|
+
ovf_dir: tmpdir,
|
23
23
|
vapp_config: vapp_config,
|
24
|
-
vdc_name:
|
24
|
+
vdc_name: @vdc_name,
|
25
25
|
)
|
26
26
|
rescue => e
|
27
27
|
logger.error(e.http_body) if e.respond_to?(:http_body)
|
data/lib/vm_shepherd/version.rb
CHANGED
@@ -3,16 +3,16 @@ require 'rbvmomi'
|
|
3
3
|
|
4
4
|
module VmShepherd
|
5
5
|
class VsphereManager
|
6
|
-
TEMPLATE_PREFIX
|
7
|
-
VALID_FOLDER_REGEX
|
6
|
+
TEMPLATE_PREFIX = 'tpl'.freeze
|
7
|
+
VALID_FOLDER_REGEX = /\A([\w-]{1,80}\/)*[\w-]{1,80}\/?\z/
|
8
8
|
VALID_DISK_FOLDER_REGEX = /\A[\w-]{1,80}\z/
|
9
9
|
|
10
10
|
def initialize(host, username, password, datacenter_name, logger)
|
11
|
-
@host
|
12
|
-
@username
|
13
|
-
@password
|
11
|
+
@host = host
|
12
|
+
@username = username
|
13
|
+
@password = password
|
14
14
|
@datacenter_name = datacenter_name
|
15
|
-
@logger
|
15
|
+
@logger = logger
|
16
16
|
end
|
17
17
|
|
18
18
|
def deploy(ova_path, vm_config, vsphere_config)
|
@@ -43,7 +43,7 @@ module VmShepherd
|
|
43
43
|
|
44
44
|
file_manager.DeleteDatastoreFile_Task(
|
45
45
|
datacenter: datacenter,
|
46
|
-
name:
|
46
|
+
name: "[#{datastore}] #{folder_name}"
|
47
47
|
).wait_for_completion
|
48
48
|
|
49
49
|
logger.info("END datastore_folder.destroy_task folder=#{folder_name}")
|
@@ -114,7 +114,7 @@ module VmShepherd
|
|
114
114
|
def boot_vm(ovf_file_path, vm_config, vsphere_config)
|
115
115
|
datacenter.vmFolder.traverse(vsphere_config[:folder], RbVmomi::VIM::Folder, true)
|
116
116
|
template = deploy_ovf_template(ovf_file_path, vsphere_config)
|
117
|
-
vm
|
117
|
+
vm = create_vm_from_template(template, vsphere_config)
|
118
118
|
|
119
119
|
reconfigure_vm(vm, vm_config)
|
120
120
|
power_on_vm(vm)
|
@@ -168,13 +168,13 @@ module VmShepherd
|
|
168
168
|
template_name = [TEMPLATE_PREFIX, Time.new.strftime('%F-%H-%M'), cluster(vsphere_config).name].join('-')
|
169
169
|
logger.info("BEGIN deploy_ovf ovf_file=#{ovf_file_path} template_name=#{template_name}")
|
170
170
|
connection.serviceContent.ovfManager.deployOVF(
|
171
|
-
uri:
|
172
|
-
vmName:
|
173
|
-
vmFolder:
|
174
|
-
host:
|
175
|
-
resourcePool:
|
176
|
-
datastore:
|
177
|
-
networkMappings:
|
171
|
+
uri: ovf_file_path,
|
172
|
+
vmName: template_name,
|
173
|
+
vmFolder: target_folder(vsphere_config),
|
174
|
+
host: find_deploy_host(vsphere_config),
|
175
|
+
resourcePool: resource_pool(vsphere_config),
|
176
|
+
datastore: datastore(vsphere_config),
|
177
|
+
networkMappings: create_network_mappings(ovf_file_path, vsphere_config),
|
178
178
|
propertyMappings: {},
|
179
179
|
).tap do |ovf_template|
|
180
180
|
ovf_template.add_delta_disk_layer_on_all_disks
|
@@ -185,7 +185,7 @@ module VmShepherd
|
|
185
185
|
def find_deploy_host(vsphere_config)
|
186
186
|
property_collector = connection.serviceContent.propertyCollector
|
187
187
|
|
188
|
-
hosts
|
188
|
+
hosts = cluster(vsphere_config).host
|
189
189
|
host_properties_by_host =
|
190
190
|
property_collector.collectMultiple(
|
191
191
|
hosts,
|
@@ -206,16 +206,16 @@ module VmShepherd
|
|
206
206
|
logger.info("BEGIN clone_vm_task tempalte=#{template.name}")
|
207
207
|
template.CloneVM_Task(
|
208
208
|
folder: target_folder(vsphere_config),
|
209
|
-
name:
|
210
|
-
spec:
|
209
|
+
name: "#{template.name}-vm",
|
210
|
+
spec: {
|
211
211
|
location: {
|
212
|
-
pool:
|
213
|
-
datastore:
|
212
|
+
pool: resource_pool(vsphere_config),
|
213
|
+
datastore: datastore(vsphere_config),
|
214
214
|
diskMoveType: :moveChildMostDiskBacking,
|
215
215
|
},
|
216
|
-
powerOn:
|
216
|
+
powerOn: false,
|
217
217
|
template: false,
|
218
|
-
config:
|
218
|
+
config: {numCPUs: 2, memoryMB: 2048},
|
219
219
|
}
|
220
220
|
).wait_for_completion.tap {
|
221
221
|
logger.info("END clone_vm_task tempalte=#{template.name}")
|
@@ -237,7 +237,7 @@ module VmShepherd
|
|
237
237
|
vm_config_spec =
|
238
238
|
RbVmomi::VIM::VmConfigSpec.new.tap do |vcs|
|
239
239
|
vcs.ovfEnvironmentTransport = ['com.vmware.guestInfo']
|
240
|
-
vcs.property
|
240
|
+
vcs.property = create_vapp_property_specs(vm_config)
|
241
241
|
end
|
242
242
|
logger.info("END VmConfigSpec creation: #{vm_config_spec.inspect}")
|
243
243
|
|
@@ -250,10 +250,10 @@ module VmShepherd
|
|
250
250
|
|
251
251
|
def create_vapp_property_specs(vm_config)
|
252
252
|
ip_configuration = {
|
253
|
-
'ip0'
|
254
|
-
'netmask0'
|
255
|
-
'gateway'
|
256
|
-
'DNS'
|
253
|
+
'ip0' => vm_config[:ip],
|
254
|
+
'netmask0' => vm_config[:netmask],
|
255
|
+
'gateway' => vm_config[:gateway],
|
256
|
+
'DNS' => vm_config[:dns],
|
257
257
|
'ntp_servers' => vm_config[:ntp_servers],
|
258
258
|
}
|
259
259
|
|
@@ -264,8 +264,8 @@ module VmShepherd
|
|
264
264
|
ip_configuration.each_with_index do |(key, value), i|
|
265
265
|
vapp_property_specs << RbVmomi::VIM::VAppPropertySpec.new.tap do |spec|
|
266
266
|
spec.operation = 'edit'
|
267
|
-
spec.info
|
268
|
-
p.key
|
267
|
+
spec.info = RbVmomi::VIM::VAppPropertyInfo.new.tap do |p|
|
268
|
+
p.key = i
|
269
269
|
p.label = key
|
270
270
|
p.value = value
|
271
271
|
end
|
@@ -274,8 +274,8 @@ module VmShepherd
|
|
274
274
|
|
275
275
|
vapp_property_specs << RbVmomi::VIM::VAppPropertySpec.new.tap do |spec|
|
276
276
|
spec.operation = 'edit'
|
277
|
-
spec.info
|
278
|
-
p.key
|
277
|
+
spec.info = RbVmomi::VIM::VAppPropertyInfo.new.tap do |p|
|
278
|
+
p.key = ip_configuration.length
|
279
279
|
p.label = 'admin_password'
|
280
280
|
p.value = vm_config[:vm_password]
|
281
281
|
end
|
@@ -300,10 +300,10 @@ module VmShepherd
|
|
300
300
|
|
301
301
|
def connection
|
302
302
|
RbVmomi::VIM.connect(
|
303
|
-
host:
|
304
|
-
user:
|
303
|
+
host: host,
|
304
|
+
user: username,
|
305
305
|
password: password,
|
306
|
-
ssl:
|
306
|
+
ssl: true,
|
307
307
|
insecure: true,
|
308
308
|
)
|
309
309
|
end
|
@@ -16,20 +16,20 @@ module VmShepherd
|
|
16
16
|
|
17
17
|
let(:env_config) do
|
18
18
|
{
|
19
|
-
stack_name:
|
19
|
+
stack_name: 'aws-stack-name',
|
20
20
|
aws_access_key: 'aws-access-key',
|
21
21
|
aws_secret_key: 'aws-secret-key',
|
22
|
-
region:
|
23
|
-
json_file:
|
24
|
-
parameters:
|
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
|
|
@@ -47,9 +47,9 @@ module VmShepherd
|
|
47
47
|
|
48
48
|
before do
|
49
49
|
expect(AWS).to receive(:config).with(
|
50
|
-
access_key_id:
|
50
|
+
access_key_id: env_config.fetch(:aws_access_key),
|
51
51
|
secret_access_key: env_config.fetch(:aws_secret_key),
|
52
|
-
region:
|
52
|
+
region: env_config.fetch(:region),
|
53
53
|
)
|
54
54
|
|
55
55
|
allow(AWS).to receive(:ec2).and_return(ec2)
|
@@ -75,7 +75,7 @@ module VmShepherd
|
|
75
75
|
expect(stack_collection).to receive(:create).with(
|
76
76
|
'aws-stack-name',
|
77
77
|
'{}',
|
78
|
-
parameters:
|
78
|
+
parameters: {
|
79
79
|
'some_parameter' => 'some-answer',
|
80
80
|
},
|
81
81
|
capabilities: ['CAPABILITY_IAM']
|
@@ -110,18 +110,18 @@ module VmShepherd
|
|
110
110
|
{
|
111
111
|
elbs: [
|
112
112
|
{
|
113
|
-
name:
|
114
|
-
port_mappings:
|
113
|
+
name: 'elb-1-name',
|
114
|
+
port_mappings: [[1111, 11]],
|
115
115
|
stack_output_keys: {
|
116
|
-
vpc_id:
|
116
|
+
vpc_id: 'vpc_id',
|
117
117
|
subnet_id: 'private_subnet',
|
118
118
|
},
|
119
119
|
},
|
120
120
|
{
|
121
|
-
name:
|
122
|
-
port_mappings:
|
121
|
+
name: 'elb-2-name',
|
122
|
+
port_mappings: [[2222, 22]],
|
123
123
|
stack_output_keys: {
|
124
|
-
vpc_id:
|
124
|
+
vpc_id: 'vpc_id',
|
125
125
|
subnet_id: 'private_subnet',
|
126
126
|
},
|
127
127
|
}
|
@@ -130,10 +130,10 @@ module VmShepherd
|
|
130
130
|
end
|
131
131
|
let(:stack) do
|
132
132
|
instance_double(AWS::CloudFormation::Stack,
|
133
|
-
name:
|
133
|
+
name: 'fake-stack-name',
|
134
134
|
creation_time: Time.utc(2015, 5, 29),
|
135
|
-
status:
|
136
|
-
outputs:
|
135
|
+
status: 'CREATE_COMPLETE',
|
136
|
+
outputs: stack_outputs
|
137
137
|
)
|
138
138
|
end
|
139
139
|
let(:stack_outputs) do
|
@@ -172,17 +172,17 @@ module VmShepherd
|
|
172
172
|
|
173
173
|
it 'creates and attaches a security group for the ELBs' do
|
174
174
|
elb_1_security_group_args = {
|
175
|
-
group_name:
|
175
|
+
group_name: 'fake-stack-name_elb-1-name',
|
176
176
|
description: 'ELB Security Group',
|
177
|
-
vpc_id:
|
177
|
+
vpc_id: 'fake-vpc-id',
|
178
178
|
}
|
179
179
|
expect(ec2_client).to receive(:create_security_group).with(elb_1_security_group_args).and_return(create_security_group_response_1)
|
180
180
|
expect(elb_1_security_group).to receive(:authorize_ingress).with(:tcp, 1111, '0.0.0.0/0')
|
181
181
|
|
182
182
|
elb_2_security_group_args = {
|
183
|
-
group_name:
|
183
|
+
group_name: 'fake-stack-name_elb-2-name',
|
184
184
|
description: 'ELB Security Group',
|
185
|
-
vpc_id:
|
185
|
+
vpc_id: 'fake-vpc-id',
|
186
186
|
}
|
187
187
|
expect(ec2_client).to receive(:create_security_group).with(elb_2_security_group_args).and_return(create_security_group_response_2)
|
188
188
|
expect(elb_2_security_group).to receive(:authorize_ingress).with(:tcp, 2222, '0.0.0.0/0')
|
@@ -193,16 +193,16 @@ module VmShepherd
|
|
193
193
|
it 'attaches an elb with the name of the stack for the ELBs' do
|
194
194
|
elb_1_params = {
|
195
195
|
load_balancer_name: 'elb-1-name',
|
196
|
-
listeners:
|
197
|
-
subnets:
|
198
|
-
security_groups:
|
196
|
+
listeners: [{protocol: 'TCP', load_balancer_port: 1111, instance_protocol: 'TCP', instance_port: 11}],
|
197
|
+
subnets: ['fake-subnet-id'],
|
198
|
+
security_groups: ['elb-1-security-group-id']
|
199
199
|
}
|
200
200
|
expect(elb_client).to receive(:create_load_balancer).with(elb_1_params)
|
201
201
|
elb_2_params = {
|
202
202
|
load_balancer_name: 'elb-2-name',
|
203
|
-
listeners:
|
204
|
-
subnets:
|
205
|
-
security_groups:
|
203
|
+
listeners: [{protocol: 'TCP', load_balancer_port: 2222, instance_protocol: 'TCP', instance_port: 22}],
|
204
|
+
subnets: ['fake-subnet-id'],
|
205
|
+
security_groups: ['elb-2-security-group-id']
|
206
206
|
}
|
207
207
|
expect(elb_client).to receive(:create_load_balancer).with(elb_2_params)
|
208
208
|
|
@@ -220,15 +220,16 @@ module VmShepherd
|
|
220
220
|
before do
|
221
221
|
allow(ec2).to receive(:instances).and_return(instances)
|
222
222
|
allow(ec2).to receive(:elastic_ips).and_return(elastic_ips)
|
223
|
+
allow(elastic_ip).to receive(:exists?).and_return(true)
|
223
224
|
end
|
224
225
|
|
225
226
|
it 'creates an instance using AWS SDK v1' do
|
226
227
|
expect(ec2).to receive_message_chain(:instances, :create).with(
|
227
|
-
image_id:
|
228
|
-
key_name:
|
228
|
+
image_id: ami_id,
|
229
|
+
key_name: 'ssh-key-name',
|
229
230
|
security_group_ids: ['security-group-id'],
|
230
|
-
subnet:
|
231
|
-
instance_type:
|
231
|
+
subnet: 'public-subnet-id',
|
232
|
+
instance_type: 'm3.medium').and_return(instance)
|
232
233
|
|
233
234
|
ami_manager.deploy(ami_file_path: ami_file_path, vm_config: vm_config)
|
234
235
|
end
|
@@ -271,9 +272,25 @@ module VmShepherd
|
|
271
272
|
end
|
272
273
|
|
273
274
|
context 'vm configuration does not contain an elastic IP' do
|
275
|
+
before do
|
276
|
+
allow(ec2).to receive_message_chain(:elastic_ips, :create).and_return(elastic_ip)
|
277
|
+
end
|
278
|
+
|
279
|
+
it 'waits for the Elastic IP to be created' do
|
280
|
+
expect(elastic_ip).to receive(:exists?).exactly(AwsManager::RETRY_LIMIT - 1).times.and_return(false)
|
281
|
+
expect(elastic_ip).to receive(:exists?).exactly(1).times.and_return(true)
|
282
|
+
|
283
|
+
ami_manager.deploy(ami_file_path: ami_file_path, vm_config: vm_config)
|
284
|
+
end
|
285
|
+
|
286
|
+
it 'fails if the Elastic IP is not created in time' do
|
287
|
+
expect(elastic_ip).to receive(:exists?).exactly(AwsManager::RETRY_LIMIT).times.and_return(false)
|
288
|
+
|
289
|
+
expect { ami_manager.deploy(ami_file_path: ami_file_path, vm_config: vm_config) }.to raise_error(AwsManager::RetryLimitExceeded)
|
290
|
+
end
|
291
|
+
|
274
292
|
it 'creates and attaches an elastic IP' do
|
275
|
-
expect(ec2).to receive_message_chain(:elastic_ips, :create).with(
|
276
|
-
vpc: true).and_return(elastic_ip)
|
293
|
+
expect(ec2).to receive_message_chain(:elastic_ips, :create).with(vpc: true).and_return(elastic_ip)
|
277
294
|
|
278
295
|
expect(instance).to receive(:associate_elastic_ip).with(elastic_ip)
|
279
296
|
|
@@ -284,7 +301,7 @@ module VmShepherd
|
|
284
301
|
context 'vm configuration contains an elastic IP' do
|
285
302
|
let(:vm_config) do
|
286
303
|
{
|
287
|
-
vm_name:
|
304
|
+
vm_name: 'some-vm-name',
|
288
305
|
vm_ip_address: 'some-ip-address'
|
289
306
|
}
|
290
307
|
end
|
@@ -424,18 +441,18 @@ module VmShepherd
|
|
424
441
|
{
|
425
442
|
elbs: [
|
426
443
|
{
|
427
|
-
name:
|
428
|
-
port_mappings:
|
444
|
+
name: 'elb-1-name',
|
445
|
+
port_mappings: [[1111, 11]],
|
429
446
|
stack_output_keys: {
|
430
|
-
vpc_id:
|
447
|
+
vpc_id: 'vpc_id',
|
431
448
|
subnet_id: 'private_subnet',
|
432
449
|
},
|
433
450
|
},
|
434
451
|
{
|
435
|
-
name:
|
436
|
-
port_mappings:
|
452
|
+
name: 'elb-2-name',
|
453
|
+
port_mappings: [[2222, 22]],
|
437
454
|
stack_output_keys: {
|
438
|
-
vpc_id:
|
455
|
+
vpc_id: 'vpc_id',
|
439
456
|
subnet_id: 'private_subnet',
|
440
457
|
},
|
441
458
|
}
|
@@ -446,16 +463,16 @@ module VmShepherd
|
|
446
463
|
let(:elb) { instance_double(AWS::ELB, load_balancers: [load_balancer_1_to_delete, load_balancer_2_to_delete, other_load_balancer]) }
|
447
464
|
let(:load_balancer_1_to_delete) do
|
448
465
|
instance_double(AWS::ELB::LoadBalancer,
|
449
|
-
name:
|
466
|
+
name: 'elb-1-name',
|
450
467
|
security_groups: [elb_1_security_group],
|
451
|
-
exists?:
|
468
|
+
exists?: false,
|
452
469
|
)
|
453
470
|
end
|
454
471
|
let(:load_balancer_2_to_delete) do
|
455
472
|
instance_double(AWS::ELB::LoadBalancer,
|
456
|
-
name:
|
473
|
+
name: 'elb-2-name',
|
457
474
|
security_groups: [elb_2_security_group],
|
458
|
-
exists?:
|
475
|
+
exists?: false,
|
459
476
|
)
|
460
477
|
end
|
461
478
|
let(:other_load_balancer) { instance_double(AWS::ELB::LoadBalancer, name: 'other-elb-name') }
|
@@ -464,25 +481,25 @@ module VmShepherd
|
|
464
481
|
let(:network_interface_1_elb_1) do
|
465
482
|
instance_double(AWS::EC2::NetworkInterface,
|
466
483
|
security_groups: [elb_1_security_group],
|
467
|
-
exists?:
|
484
|
+
exists?: false,
|
468
485
|
)
|
469
486
|
end
|
470
487
|
let(:network_interface_2_elb_1) do
|
471
488
|
instance_double(AWS::EC2::NetworkInterface,
|
472
489
|
security_groups: [elb_1_security_group],
|
473
|
-
exists?:
|
490
|
+
exists?: false,
|
474
491
|
)
|
475
492
|
end
|
476
493
|
let(:network_interface_1_elb_2) do
|
477
494
|
instance_double(AWS::EC2::NetworkInterface,
|
478
495
|
security_groups: [elb_2_security_group],
|
479
|
-
exists?:
|
496
|
+
exists?: false,
|
480
497
|
)
|
481
498
|
end
|
482
499
|
let(:network_interface_2_elb_2) do
|
483
500
|
instance_double(AWS::EC2::NetworkInterface,
|
484
501
|
security_groups: [elb_2_security_group],
|
485
|
-
exists?:
|
502
|
+
exists?: false,
|
486
503
|
)
|
487
504
|
end
|
488
505
|
|
@@ -596,7 +613,7 @@ module VmShepherd
|
|
596
613
|
context 'when there is an s3 bucket configuration' do
|
597
614
|
let(:bucket_1) { instance_double(AWS::S3::Bucket) }
|
598
615
|
let(:bucket_2) { instance_double(AWS::S3::Bucket) }
|
599
|
-
let(:extra_outputs) { {
|
616
|
+
let(:extra_outputs) { {s3_bucket_names: [bucket_name_1, bucket_name_2]} }
|
600
617
|
let(:bucket_name_1) { 'bucket-name-1' }
|
601
618
|
let(:bucket_name_2) { 'bucket-name-2' }
|
602
619
|
|
@@ -646,7 +663,7 @@ module VmShepherd
|
|
646
663
|
|
647
664
|
context 'and the bucket name is empty' do
|
648
665
|
let(:bucket_name_3) { '' }
|
649
|
-
let(:extra_outputs) { {
|
666
|
+
let(:extra_outputs) { {s3_bucket_names: [bucket_name_3, bucket_name_1, bucket_name_2]} }
|
650
667
|
|
651
668
|
before do
|
652
669
|
allow(bucket_1).to receive(:exists?).and_return(true)
|
@@ -663,7 +680,7 @@ module VmShepherd
|
|
663
680
|
|
664
681
|
context 'and the bucket name is null' do
|
665
682
|
let(:bucket_name_3) { nil }
|
666
|
-
let(:extra_outputs) { {
|
683
|
+
let(:extra_outputs) { {s3_bucket_names: [bucket_name_3, bucket_name_1, bucket_name_2]} }
|
667
684
|
|
668
685
|
before do
|
669
686
|
allow(bucket_1).to receive(:exists?).and_return(true)
|
@@ -725,7 +742,7 @@ module VmShepherd
|
|
725
742
|
let(:elastic_ip) { instance_double(AWS::EC2::ElasticIp) }
|
726
743
|
let(:vm_config) do
|
727
744
|
{
|
728
|
-
vm_name:
|
745
|
+
vm_name: 'some-vm-name',
|
729
746
|
vm_ip_address: 'some-ip-address'
|
730
747
|
}
|
731
748
|
end
|