vm_shepherd 1.12.7 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +0 -2
- data/Rakefile +7 -1
- data/lib/vm_shepherd/shepherd.rb +111 -116
- data/lib/vm_shepherd/vcloud/deployer.rb +1 -8
- data/lib/vm_shepherd/version.rb +1 -1
- data/spec/vm_shepherd/shepherd_spec.rb +226 -229
- data/spec/vm_shepherd/vcloud/deployer_spec.rb +1 -1
- data/spec/vm_shepherd/vcloud_manager_spec.rb +1 -1
- data/vm_shepherd.gemspec +2 -3
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ee2d52da3a902973a504843ace3b5e3ba0fed26
|
4
|
+
data.tar.gz: ce189c0987c686de0d6b923356d1b315dc14551a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45b5e0127208360ed18d086bfe233433bcad2c2dd80308cce95b9500ce6f34b9bbc37ea01be4cf90b4c65c8ebe8368b9cc5d632c2cc68ad541c6051bbc231887
|
7
|
+
data.tar.gz: b883adadd20c3441b98cf0873bbb6060df5093725dcb572ad6c0ea1022bc1dc6f6b6adf86fdeddf165158cf8ad9867f777a94109aa2b906a9771f5b936ca3b3a
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.0
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
3
4
|
|
4
5
|
RSpec::Core::RakeTask.new(:spec)
|
5
6
|
|
6
|
-
|
7
|
+
RuboCop::RakeTask.new(:rubocop) do |t|
|
8
|
+
t.options << '--lint'
|
9
|
+
t.options << '--display-cop-names'
|
10
|
+
end
|
11
|
+
|
12
|
+
task default: [:rubocop, :spec]
|
data/lib/vm_shepherd/shepherd.rb
CHANGED
@@ -4,28 +4,29 @@ module VmShepherd
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def initialize(settings:)
|
7
|
-
@
|
7
|
+
@iaas_type = settings.dig('iaas_type')
|
8
|
+
@configs = settings.dig('vm_shepherd', 'vm_configs') || []
|
9
|
+
@env_config = settings.dig('vm_shepherd', 'env_config')
|
8
10
|
end
|
9
11
|
|
10
12
|
def deploy(paths:)
|
11
|
-
unless valid_iaas_types.include?(
|
12
|
-
fail(InvalidIaas, "Unknown IaaS type: #{
|
13
|
+
unless valid_iaas_types.include?(@iaas_type)
|
14
|
+
fail(InvalidIaas, "Unknown IaaS type: #{@iaas_type.inspect}")
|
13
15
|
end
|
14
|
-
configs
|
15
|
-
|
16
|
-
fail(ArgumentError, "mismatch in available images to deploy (needed #{configs.size}, got #{paths.size})")
|
16
|
+
unless @configs.size == paths.size
|
17
|
+
fail(ArgumentError, "mismatch in available images to deploy (needed #{@configs.size}, got #{paths.size})")
|
17
18
|
end
|
18
|
-
configs.zip(paths).each do |vm_shepherd_config, path|
|
19
|
-
case
|
19
|
+
@configs.zip(paths).each do |vm_shepherd_config, path|
|
20
|
+
case @iaas_type
|
20
21
|
when VmShepherd::VCLOUD_IAAS_TYPE then
|
21
22
|
VmShepherd::VcloudManager.new(
|
22
23
|
{
|
23
|
-
url: vm_shepherd_config.creds
|
24
|
-
organization: vm_shepherd_config.creds
|
25
|
-
user: vm_shepherd_config.creds
|
26
|
-
password: vm_shepherd_config.creds
|
24
|
+
url: vm_shepherd_config.dig('creds', 'url'),
|
25
|
+
organization: vm_shepherd_config.dig('creds', 'organization'),
|
26
|
+
user: vm_shepherd_config.dig('creds', 'user'),
|
27
|
+
password: vm_shepherd_config.dig('creds', 'password'),
|
27
28
|
},
|
28
|
-
vm_shepherd_config.vdc
|
29
|
+
vm_shepherd_config.dig('vdc', 'name'),
|
29
30
|
stdout_logger
|
30
31
|
).deploy(
|
31
32
|
path,
|
@@ -33,30 +34,30 @@ module VmShepherd
|
|
33
34
|
)
|
34
35
|
when VmShepherd::VSPHERE_IAAS_TYPE then
|
35
36
|
VmShepherd::VsphereManager.new(
|
36
|
-
vm_shepherd_config.vcenter_creds
|
37
|
-
vm_shepherd_config.vcenter_creds
|
38
|
-
vm_shepherd_config.vcenter_creds
|
39
|
-
vm_shepherd_config.vsphere
|
37
|
+
vm_shepherd_config.dig('vcenter_creds', 'ip'),
|
38
|
+
vm_shepherd_config.dig('vcenter_creds', 'username'),
|
39
|
+
vm_shepherd_config.dig('vcenter_creds', 'password'),
|
40
|
+
vm_shepherd_config.dig('vsphere', 'datacenter'),
|
40
41
|
stdout_logger,
|
41
42
|
).deploy(
|
42
43
|
path,
|
43
44
|
{
|
44
|
-
ip: vm_shepherd_config.vm
|
45
|
-
gateway: vm_shepherd_config.vm
|
46
|
-
netmask: vm_shepherd_config.vm
|
47
|
-
dns: vm_shepherd_config.vm
|
48
|
-
ntp_servers: vm_shepherd_config.vm
|
45
|
+
ip: vm_shepherd_config.dig('vm', 'ip'),
|
46
|
+
gateway: vm_shepherd_config.dig('vm', 'gateway'),
|
47
|
+
netmask: vm_shepherd_config.dig('vm', 'netmask'),
|
48
|
+
dns: vm_shepherd_config.dig('vm', 'dns'),
|
49
|
+
ntp_servers: vm_shepherd_config.dig('vm', 'ntp_servers'),
|
49
50
|
},
|
50
51
|
{
|
51
|
-
cluster: vm_shepherd_config.vsphere
|
52
|
-
resource_pool: vm_shepherd_config.vsphere
|
53
|
-
datastore: vm_shepherd_config.vsphere
|
54
|
-
network: vm_shepherd_config.vsphere
|
55
|
-
folder: vm_shepherd_config.vsphere
|
52
|
+
cluster: vm_shepherd_config.dig('vsphere', 'cluster'),
|
53
|
+
resource_pool: vm_shepherd_config.dig('vsphere', 'resource_pool'),
|
54
|
+
datastore: vm_shepherd_config.dig('vsphere', 'datastore'),
|
55
|
+
network: vm_shepherd_config.dig('vsphere', 'network'),
|
56
|
+
folder: vm_shepherd_config.dig('vsphere', 'folder'),
|
56
57
|
}
|
57
58
|
)
|
58
59
|
when VmShepherd::AWS_IAAS_TYPE then
|
59
|
-
ami_manager.deploy(ami_file_path: path, vm_config: vm_shepherd_config
|
60
|
+
ami_manager.deploy(ami_file_path: path, vm_config: vm_shepherd_config)
|
60
61
|
when VmShepherd::OPENSTACK_IAAS_TYPE then
|
61
62
|
openstack_vm_manager(vm_shepherd_config).deploy(path, openstack_vm_options(vm_shepherd_config))
|
62
63
|
end
|
@@ -64,69 +65,69 @@ module VmShepherd
|
|
64
65
|
end
|
65
66
|
|
66
67
|
def prepare_environment
|
67
|
-
unless valid_iaas_types.include?(
|
68
|
-
fail(InvalidIaas, "Unknown IaaS type: #{
|
68
|
+
unless valid_iaas_types.include?(@iaas_type)
|
69
|
+
fail(InvalidIaas, "Unknown IaaS type: #{@iaas_type.inspect}")
|
69
70
|
end
|
70
|
-
case
|
71
|
+
case @iaas_type
|
71
72
|
when VmShepherd::VCLOUD_IAAS_TYPE then
|
72
|
-
|
73
|
+
@configs.each do |vm_shepherd_config|
|
73
74
|
VmShepherd::VcloudManager.new(
|
74
75
|
{
|
75
|
-
url: vm_shepherd_config.creds
|
76
|
-
organization: vm_shepherd_config.creds
|
77
|
-
user: vm_shepherd_config.creds
|
78
|
-
password: vm_shepherd_config.creds
|
76
|
+
url: vm_shepherd_config.dig('creds', 'url'),
|
77
|
+
organization: vm_shepherd_config.dig('creds', 'organization'),
|
78
|
+
user: vm_shepherd_config.dig('creds', 'user'),
|
79
|
+
password: vm_shepherd_config.dig('creds', 'password'),
|
79
80
|
},
|
80
|
-
vm_shepherd_config.vdc
|
81
|
+
vm_shepherd_config.dig('vdc', 'name'),
|
81
82
|
stdout_logger
|
82
83
|
).prepare_environment
|
83
84
|
end
|
84
85
|
when VmShepherd::VSPHERE_IAAS_TYPE then
|
85
|
-
|
86
|
+
@configs.each do |vm_shepherd_config|
|
86
87
|
VmShepherd::VsphereManager.new(
|
87
|
-
vm_shepherd_config.vcenter_creds
|
88
|
-
vm_shepherd_config.vcenter_creds
|
89
|
-
vm_shepherd_config.vcenter_creds
|
90
|
-
vm_shepherd_config.vsphere
|
88
|
+
vm_shepherd_config.dig('vcenter_creds', 'ip'),
|
89
|
+
vm_shepherd_config.dig('vcenter_creds', 'username'),
|
90
|
+
vm_shepherd_config.dig('vcenter_creds', 'password'),
|
91
|
+
vm_shepherd_config.dig('vsphere', 'datacenter'),
|
91
92
|
stdout_logger,
|
92
93
|
).prepare_environment
|
93
94
|
end
|
94
95
|
when VmShepherd::AWS_IAAS_TYPE then
|
95
|
-
ami_manager.prepare_environment(
|
96
|
+
ami_manager.prepare_environment(@env_config.dig('json_file'))
|
96
97
|
when VmShepherd::OPENSTACK_IAAS_TYPE then
|
97
|
-
|
98
|
+
@configs.each do |vm_shepherd_config|
|
98
99
|
openstack_vm_manager(vm_shepherd_config).prepare_environment
|
99
100
|
end
|
100
101
|
end
|
101
102
|
end
|
102
103
|
|
103
104
|
def destroy
|
104
|
-
unless valid_iaas_types.include?(
|
105
|
-
fail(InvalidIaas, "Unknown IaaS type: #{
|
105
|
+
unless valid_iaas_types.include?(@iaas_type)
|
106
|
+
fail(InvalidIaas, "Unknown IaaS type: #{@iaas_type.inspect}")
|
106
107
|
end
|
107
|
-
|
108
|
-
case
|
108
|
+
@configs.each do |vm_shepherd_config|
|
109
|
+
case @iaas_type
|
109
110
|
when VmShepherd::VCLOUD_IAAS_TYPE then
|
110
111
|
VmShepherd::VcloudManager.new(
|
111
112
|
{
|
112
|
-
url: vm_shepherd_config.creds
|
113
|
-
organization: vm_shepherd_config.creds
|
114
|
-
user: vm_shepherd_config.creds
|
115
|
-
password: vm_shepherd_config.creds
|
113
|
+
url: vm_shepherd_config.dig('creds', 'url'),
|
114
|
+
organization: vm_shepherd_config.dig('creds', 'organization'),
|
115
|
+
user: vm_shepherd_config.dig('creds', 'user'),
|
116
|
+
password: vm_shepherd_config.dig('creds', 'password'),
|
116
117
|
},
|
117
|
-
vm_shepherd_config.vdc
|
118
|
+
vm_shepherd_config.dig('vdc', 'name'),
|
118
119
|
stdout_logger
|
119
|
-
).destroy([vm_shepherd_config.vapp
|
120
|
+
).destroy([vm_shepherd_config.dig('vapp', 'ops_manager_name')], vm_shepherd_config.dig('vdc', 'catalog'))
|
120
121
|
when VmShepherd::VSPHERE_IAAS_TYPE then
|
121
122
|
VmShepherd::VsphereManager.new(
|
122
|
-
vm_shepherd_config.vcenter_creds
|
123
|
-
vm_shepherd_config.vcenter_creds
|
124
|
-
vm_shepherd_config.vcenter_creds
|
125
|
-
vm_shepherd_config.vsphere
|
123
|
+
vm_shepherd_config.dig('vcenter_creds', 'ip'),
|
124
|
+
vm_shepherd_config.dig('vcenter_creds', 'username'),
|
125
|
+
vm_shepherd_config.dig('vcenter_creds', 'password'),
|
126
|
+
vm_shepherd_config.dig('vsphere', 'datacenter'),
|
126
127
|
stdout_logger,
|
127
|
-
).destroy(vm_shepherd_config.vm
|
128
|
+
).destroy(vm_shepherd_config.dig('vm', 'ip'), vm_shepherd_config.dig('vsphere', 'resource_pool'))
|
128
129
|
when VmShepherd::AWS_IAAS_TYPE then
|
129
|
-
ami_manager.destroy(vm_shepherd_config
|
130
|
+
ami_manager.destroy(vm_shepherd_config)
|
130
131
|
when VmShepherd::OPENSTACK_IAAS_TYPE then
|
131
132
|
openstack_vm_manager(vm_shepherd_config).destroy(openstack_vm_options(vm_shepherd_config))
|
132
133
|
end
|
@@ -134,41 +135,41 @@ module VmShepherd
|
|
134
135
|
end
|
135
136
|
|
136
137
|
def clean_environment
|
137
|
-
unless valid_iaas_types.include?(
|
138
|
-
fail(InvalidIaas, "Unknown IaaS type: #{
|
138
|
+
unless valid_iaas_types.include?(@iaas_type)
|
139
|
+
fail(InvalidIaas, "Unknown IaaS type: #{@iaas_type.inspect}")
|
139
140
|
end
|
140
|
-
case
|
141
|
+
case @iaas_type
|
141
142
|
when VmShepherd::VCLOUD_IAAS_TYPE then
|
142
|
-
|
143
|
+
@configs.each do |vm_shepherd_config|
|
143
144
|
VmShepherd::VcloudManager.new(
|
144
145
|
{
|
145
|
-
url: vm_shepherd_config.creds
|
146
|
-
organization: vm_shepherd_config.creds
|
147
|
-
user: vm_shepherd_config.creds
|
148
|
-
password: vm_shepherd_config.creds
|
146
|
+
url: vm_shepherd_config.dig('creds', 'url'),
|
147
|
+
organization: vm_shepherd_config.dig('creds', 'organization'),
|
148
|
+
user: vm_shepherd_config.dig('creds', 'user'),
|
149
|
+
password: vm_shepherd_config.dig('creds', 'password'),
|
149
150
|
},
|
150
|
-
vm_shepherd_config.vdc
|
151
|
+
vm_shepherd_config.dig('vdc', 'name'),
|
151
152
|
stdout_logger,
|
152
|
-
).clean_environment(vm_shepherd_config.vapp
|
153
|
+
).clean_environment(vm_shepherd_config.dig('vapp', 'product_names')|| [], vm_shepherd_config.dig('vapp', 'product_catalog'))
|
153
154
|
end
|
154
155
|
when VmShepherd::VSPHERE_IAAS_TYPE then
|
155
|
-
|
156
|
+
@configs.each do |vm_shepherd_config|
|
156
157
|
VmShepherd::VsphereManager.new(
|
157
|
-
vm_shepherd_config.vcenter_creds
|
158
|
-
vm_shepherd_config.vcenter_creds
|
159
|
-
vm_shepherd_config.vcenter_creds
|
160
|
-
vm_shepherd_config.cleanup
|
158
|
+
vm_shepherd_config.dig('vcenter_creds', 'ip'),
|
159
|
+
vm_shepherd_config.dig('vcenter_creds', 'username'),
|
160
|
+
vm_shepherd_config.dig('vcenter_creds', 'password'),
|
161
|
+
vm_shepherd_config.dig('cleanup', 'datacenter'),
|
161
162
|
stdout_logger,
|
162
163
|
).clean_environment(
|
163
|
-
datacenter_folders_to_clean: vm_shepherd_config.cleanup
|
164
|
-
datastores: vm_shepherd_config.cleanup
|
165
|
-
datastore_folders_to_clean: vm_shepherd_config.cleanup
|
164
|
+
datacenter_folders_to_clean: vm_shepherd_config.dig('cleanup', 'datacenter_folders_to_clean'),
|
165
|
+
datastores: vm_shepherd_config.dig('cleanup', 'datastores'),
|
166
|
+
datastore_folders_to_clean: vm_shepherd_config.dig('cleanup', 'datastore_folders_to_clean'),
|
166
167
|
)
|
167
168
|
end
|
168
169
|
when VmShepherd::AWS_IAAS_TYPE then
|
169
170
|
ami_manager.clean_environment
|
170
171
|
when VmShepherd::OPENSTACK_IAAS_TYPE then
|
171
|
-
|
172
|
+
@configs.each do |vm_shepherd_config|
|
172
173
|
openstack_vm_manager(vm_shepherd_config).clean_environment
|
173
174
|
end
|
174
175
|
end
|
@@ -176,23 +177,21 @@ module VmShepherd
|
|
176
177
|
|
177
178
|
private
|
178
179
|
|
179
|
-
attr_reader :settings
|
180
180
|
|
181
181
|
def stdout_logger
|
182
182
|
Logger.new(STDOUT)
|
183
183
|
end
|
184
184
|
|
185
185
|
def vcloud_deploy_options(vm_shepherd_config)
|
186
|
-
vm = vm_shepherd_config.vapp
|
187
186
|
VmShepherd::Vcloud::VappConfig.new(
|
188
|
-
name:
|
189
|
-
ip:
|
190
|
-
gateway:
|
191
|
-
netmask:
|
192
|
-
dns:
|
193
|
-
ntp:
|
194
|
-
catalog: vm_shepherd_config.vdc
|
195
|
-
network: vm_shepherd_config.vdc
|
187
|
+
name: vm_shepherd_config.dig('vapp', 'ops_manager_name'),
|
188
|
+
ip: vm_shepherd_config.dig('vapp', 'ip'),
|
189
|
+
gateway: vm_shepherd_config.dig('vapp', 'gateway'),
|
190
|
+
netmask: vm_shepherd_config.dig('vapp', 'netmask'),
|
191
|
+
dns: vm_shepherd_config.dig('vapp', 'dns'),
|
192
|
+
ntp: vm_shepherd_config.dig('vapp', 'ntp'),
|
193
|
+
catalog: vm_shepherd_config.dig('vdc', 'catalog'),
|
194
|
+
network: vm_shepherd_config.dig('vdc', 'network'),
|
196
195
|
)
|
197
196
|
end
|
198
197
|
|
@@ -200,26 +199,26 @@ module VmShepherd
|
|
200
199
|
@ami_manager ||=
|
201
200
|
VmShepherd::AwsManager.new(
|
202
201
|
env_config: {
|
203
|
-
stack_name
|
204
|
-
aws_access_key
|
205
|
-
aws_secret_key
|
206
|
-
region
|
207
|
-
json_file
|
208
|
-
parameters
|
209
|
-
outputs
|
202
|
+
'stack_name' => @env_config.dig('stack_name'),
|
203
|
+
'aws_access_key' => @env_config.dig('aws_access_key'),
|
204
|
+
'aws_secret_key' => @env_config.dig('aws_secret_key'),
|
205
|
+
'region' => @env_config.dig('region'),
|
206
|
+
'json_file' => @env_config.dig('json_file'),
|
207
|
+
'parameters' => @env_config.dig('parameters'),
|
208
|
+
'outputs' => @env_config.dig('outputs'),
|
210
209
|
}.merge(ami_elb_config),
|
211
210
|
logger: stdout_logger,
|
212
211
|
)
|
213
212
|
end
|
214
213
|
|
215
214
|
def ami_elb_config
|
216
|
-
if
|
215
|
+
if @env_config.dig('elbs')
|
217
216
|
{
|
218
|
-
elbs
|
217
|
+
'elbs' => @env_config.dig('elbs').map do |elb|
|
219
218
|
{
|
220
|
-
name
|
221
|
-
port_mappings
|
222
|
-
stack_output_keys
|
219
|
+
'name' => elb.dig('name'),
|
220
|
+
'port_mappings' => elb.dig('port_mappings'),
|
221
|
+
'stack_output_keys' => elb.dig('stack_output_keys'),
|
223
222
|
}
|
224
223
|
end
|
225
224
|
}
|
@@ -230,29 +229,25 @@ module VmShepherd
|
|
230
229
|
|
231
230
|
def openstack_vm_manager(vm_shepherd_config)
|
232
231
|
OpenstackManager.new(
|
233
|
-
auth_url: vm_shepherd_config.creds
|
234
|
-
username: vm_shepherd_config.creds
|
235
|
-
api_key: vm_shepherd_config.creds
|
236
|
-
tenant: vm_shepherd_config.creds
|
232
|
+
auth_url: vm_shepherd_config.dig('creds', 'auth_url'),
|
233
|
+
username: vm_shepherd_config.dig('creds', 'username'),
|
234
|
+
api_key: vm_shepherd_config.dig('creds', 'api_key'),
|
235
|
+
tenant: vm_shepherd_config.dig('creds', 'tenant'),
|
237
236
|
)
|
238
237
|
end
|
239
238
|
|
240
239
|
def openstack_vm_options(vm_shepherd_config)
|
241
240
|
{
|
242
|
-
name: vm_shepherd_config.vm
|
243
|
-
flavor_name: vm_shepherd_config.vm
|
244
|
-
network_name: vm_shepherd_config.vm
|
245
|
-
key_name: vm_shepherd_config.vm
|
246
|
-
security_group_names: vm_shepherd_config.vm
|
247
|
-
public_ip: vm_shepherd_config.vm
|
248
|
-
private_ip: vm_shepherd_config.vm
|
241
|
+
name: vm_shepherd_config.dig('vm', 'name'),
|
242
|
+
flavor_name: vm_shepherd_config.dig('vm', 'flavor_name'),
|
243
|
+
network_name: vm_shepherd_config.dig('vm', 'network_name'),
|
244
|
+
key_name: vm_shepherd_config.dig('vm', 'key_name'),
|
245
|
+
security_group_names: vm_shepherd_config.dig('vm', 'security_group_names'),
|
246
|
+
public_ip: vm_shepherd_config.dig('vm', 'public_ip'),
|
247
|
+
private_ip: vm_shepherd_config.dig('vm', 'private_ip'),
|
249
248
|
}
|
250
249
|
end
|
251
250
|
|
252
|
-
def vm_shepherd_configs(settings)
|
253
|
-
settings.vm_shepherd.vm_configs || []
|
254
|
-
end
|
255
|
-
|
256
251
|
def valid_iaas_types
|
257
252
|
[
|
258
253
|
VmShepherd::VCLOUD_IAAS_TYPE,
|
@@ -1,10 +1,6 @@
|
|
1
|
-
require 'vm_shepherd/retry_helper'
|
2
|
-
|
3
1
|
module VmShepherd
|
4
2
|
module Vcloud
|
5
3
|
class Deployer
|
6
|
-
extend RetryHelper
|
7
|
-
|
8
4
|
def self.deploy_and_power_on_vapp(client:, ovf_dir:, vapp_config:, vdc_name:)
|
9
5
|
catalog = client.create_catalog(vapp_config.catalog)
|
10
6
|
|
@@ -16,10 +12,7 @@ module VmShepherd
|
|
16
12
|
vapp = catalog.instantiate_vapp_template(vapp_config.name, vdc_name, vapp_config.name, nil, nil, network_config)
|
17
13
|
|
18
14
|
# reconfigure vm
|
19
|
-
vm
|
20
|
-
vapp.vms.first
|
21
|
-
end
|
22
|
-
|
15
|
+
vm = vapp.find_vm_by_name(vapp_config.name)
|
23
16
|
vm.product_section_properties = vapp_config.build_properties
|
24
17
|
|
25
18
|
# power on vapp
|
data/lib/vm_shepherd/version.rb
CHANGED
@@ -1,50 +1,47 @@
|
|
1
1
|
require 'vm_shepherd'
|
2
|
-
require 'recursive_open_struct'
|
3
2
|
|
4
3
|
module VmShepherd
|
5
4
|
RSpec.describe Shepherd do
|
6
5
|
subject(:manager) { Shepherd.new(settings: settings) }
|
7
|
-
let(:first_config) { settings.vm_shepherd
|
8
|
-
let(:last_config) { settings.vm_shepherd
|
9
|
-
let(:settings)
|
10
|
-
RecursiveOpenStruct.new(YAML.load_file(File.join(SPEC_ROOT, 'fixtures', 'shepherd', settings_fixture_name)), recurse_over_arrays: true)
|
11
|
-
end
|
6
|
+
let(:first_config) { settings.dig('vm_shepherd', 'vm_configs').first }
|
7
|
+
let(:last_config) { settings.dig('vm_shepherd', 'vm_configs').last }
|
8
|
+
let(:settings) { YAML.load_file(File.join(SPEC_ROOT, 'fixtures', 'shepherd', settings_fixture_name)) }
|
12
9
|
let(:aws_env_config) do
|
13
10
|
{
|
14
|
-
stack_name
|
15
|
-
aws_access_key
|
16
|
-
aws_secret_key
|
17
|
-
region
|
18
|
-
json_file
|
19
|
-
parameters
|
11
|
+
'stack_name' => 'aws-stack-name',
|
12
|
+
'aws_access_key' => 'aws-access-key',
|
13
|
+
'aws_secret_key' => 'aws-secret-key',
|
14
|
+
'region' => 'aws-region',
|
15
|
+
'json_file' => 'cloudformation.json',
|
16
|
+
'parameters' => {
|
20
17
|
'key_pair_name' => 'key_pair_name'
|
21
18
|
},
|
22
|
-
outputs
|
23
|
-
ssh_key_name
|
24
|
-
security_group
|
25
|
-
public_subnet_id
|
26
|
-
private_subnet_id
|
27
|
-
s3_bucket_name
|
19
|
+
'outputs' => {
|
20
|
+
'ssh_key_name' => 'ssh-key-name',
|
21
|
+
'security_group' => 'security-group-id',
|
22
|
+
'public_subnet_id' => 'public-subnet-id',
|
23
|
+
'private_subnet_id' => 'private-subnet-id',
|
24
|
+
's3_bucket_name' => 'bucket-name',
|
28
25
|
},
|
29
26
|
}.merge(aws_elb_config)
|
30
27
|
end
|
31
28
|
let(:aws_elb_config) do
|
32
29
|
{
|
33
|
-
elbs
|
30
|
+
'elbs' => [
|
34
31
|
{
|
35
|
-
name
|
36
|
-
port_mappings
|
37
|
-
stack_output_keys
|
38
|
-
vpc_id
|
39
|
-
subnet_id
|
32
|
+
'name' => 'elb-1-name',
|
33
|
+
'port_mappings' => [[1111, 11]],
|
34
|
+
'stack_output_keys' => {
|
35
|
+
'vpc_id' => 'CloudFormationVpcIdOutputKey',
|
36
|
+
'subnet_id' => 'CloudFormationSubnetIdOutputKey',
|
40
37
|
},
|
41
38
|
},
|
42
39
|
{
|
43
|
-
name
|
44
|
-
port_mappings
|
45
|
-
stack_output_keys
|
46
|
-
vpc_id
|
47
|
-
subnet_id
|
40
|
+
'name' => 'elb-2-name',
|
41
|
+
'port_mappings' => [[2222, 22]],
|
42
|
+
'stack_output_keys' => {
|
43
|
+
'vpc_id' => 'CloudFormationVpcIdOutputKey',
|
44
|
+
'subnet_id' => 'CloudFormationSubnetIdOutputKey',
|
48
45
|
},
|
49
46
|
}
|
50
47
|
],
|
@@ -59,56 +56,56 @@ module VmShepherd
|
|
59
56
|
|
60
57
|
it 'uses VcloudManager to launch a vm' do
|
61
58
|
expect(VcloudManager).to receive(:new).
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
59
|
+
with(
|
60
|
+
{
|
61
|
+
url: first_config.dig('creds', 'url'),
|
62
|
+
organization: first_config.dig('creds', 'organization'),
|
63
|
+
user: first_config.dig('creds', 'user'),
|
64
|
+
password: first_config.dig('creds', 'password'),
|
65
|
+
},
|
66
|
+
first_config.dig('vdc', 'name'),
|
67
|
+
instance_of(Logger)
|
68
|
+
).and_return(first_vcloud_manager)
|
72
69
|
|
73
70
|
expect(VcloudManager).to receive(:new).
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
71
|
+
with(
|
72
|
+
{
|
73
|
+
url: last_config.dig('creds', 'url'),
|
74
|
+
organization: last_config.dig('creds', 'organization'),
|
75
|
+
user: last_config.dig('creds', 'user'),
|
76
|
+
password: last_config.dig('creds', 'password'),
|
77
|
+
},
|
78
|
+
last_config.dig('vdc', 'name'),
|
79
|
+
instance_of(Logger)
|
80
|
+
).and_return(last_vcloud_manager)
|
84
81
|
|
85
82
|
expect(first_vcloud_manager).to receive(:deploy).with(
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
)
|
83
|
+
'FIRST_FAKE_PATH',
|
84
|
+
Vcloud::VappConfig.new(
|
85
|
+
name: first_config.dig('vapp', 'ops_manager_name'),
|
86
|
+
ip: first_config.dig('vapp', 'ip'),
|
87
|
+
gateway: first_config.dig('vapp', 'gateway'),
|
88
|
+
netmask: first_config.dig('vapp', 'netmask'),
|
89
|
+
dns: first_config.dig('vapp', 'dns'),
|
90
|
+
ntp: first_config.dig('vapp', 'ntp'),
|
91
|
+
catalog: first_config.dig('vdc', 'catalog'),
|
92
|
+
network: first_config.dig('vdc', 'network'),
|
97
93
|
)
|
94
|
+
)
|
98
95
|
|
99
96
|
expect(last_vcloud_manager).to receive(:deploy).with(
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
)
|
97
|
+
'LAST_FAKE_PATH',
|
98
|
+
Vcloud::VappConfig.new(
|
99
|
+
name: last_config.dig('vapp', 'ops_manager_name'),
|
100
|
+
ip: last_config.dig('vapp', 'ip'),
|
101
|
+
gateway: last_config.dig('vapp', 'gateway'),
|
102
|
+
netmask: last_config.dig('vapp', 'netmask'),
|
103
|
+
dns: last_config.dig('vapp', 'dns'),
|
104
|
+
ntp: last_config.dig('vapp', 'ntp'),
|
105
|
+
catalog: last_config.dig('vdc', 'catalog'),
|
106
|
+
network: last_config.dig('vdc', 'network'),
|
111
107
|
)
|
108
|
+
)
|
112
109
|
|
113
110
|
manager.deploy(paths: ['FIRST_FAKE_PATH', 'LAST_FAKE_PATH'])
|
114
111
|
end
|
@@ -125,56 +122,56 @@ module VmShepherd
|
|
125
122
|
|
126
123
|
it 'uses VsphereManager to launch a vm' do
|
127
124
|
expect(VsphereManager).to receive(:new).with(
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
125
|
+
first_config.dig('vcenter_creds', 'ip'),
|
126
|
+
first_config.dig('vcenter_creds', 'username'),
|
127
|
+
first_config.dig('vcenter_creds', 'password'),
|
128
|
+
first_config.dig('vsphere', 'datacenter'),
|
129
|
+
instance_of(Logger),
|
130
|
+
).and_return(first_ova_manager)
|
134
131
|
|
135
132
|
expect(VsphereManager).to receive(:new).with(
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
133
|
+
last_config.dig('vcenter_creds', 'ip'),
|
134
|
+
last_config.dig('vcenter_creds', 'username'),
|
135
|
+
last_config.dig('vcenter_creds', 'password'),
|
136
|
+
last_config.dig('vsphere', 'datacenter'),
|
137
|
+
instance_of(Logger),
|
138
|
+
).and_return(last_ova_manager)
|
142
139
|
|
143
140
|
expect(first_ova_manager).to receive(:deploy).with(
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
141
|
+
'FIRST_FAKE_PATH',
|
142
|
+
{
|
143
|
+
ip: first_config.dig('vm', 'ip'),
|
144
|
+
gateway: first_config.dig('vm', 'gateway'),
|
145
|
+
netmask: first_config.dig('vm', 'netmask'),
|
146
|
+
dns: first_config.dig('vm', 'dns'),
|
147
|
+
ntp_servers: first_config.dig('vm', 'ntp_servers'),
|
148
|
+
},
|
149
|
+
{
|
150
|
+
cluster: first_config.dig('vsphere', 'cluster'),
|
151
|
+
resource_pool: first_config.dig('vsphere', 'resource_pool'),
|
152
|
+
datastore: first_config.dig('vsphere', 'datastore'),
|
153
|
+
network: first_config.dig('vsphere', 'network'),
|
154
|
+
folder: first_config.dig('vsphere', 'folder'),
|
155
|
+
},
|
156
|
+
)
|
160
157
|
|
161
158
|
expect(last_ova_manager).to receive(:deploy).with(
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
159
|
+
'LAST_FAKE_PATH',
|
160
|
+
{
|
161
|
+
ip: last_config.dig('vm', 'ip'),
|
162
|
+
gateway: last_config.dig('vm', 'gateway'),
|
163
|
+
netmask: last_config.dig('vm', 'netmask'),
|
164
|
+
dns: last_config.dig('vm', 'dns'),
|
165
|
+
ntp_servers: last_config.dig('vm', 'ntp_servers'),
|
166
|
+
},
|
167
|
+
{
|
168
|
+
cluster: last_config.dig('vsphere', 'cluster'),
|
169
|
+
resource_pool: last_config.dig('vsphere', 'resource_pool'),
|
170
|
+
datastore: last_config.dig('vsphere', 'datastore'),
|
171
|
+
network: last_config.dig('vsphere', 'network'),
|
172
|
+
folder: last_config.dig('vsphere', 'folder'),
|
173
|
+
},
|
174
|
+
)
|
178
175
|
|
179
176
|
manager.deploy(paths: ['FIRST_FAKE_PATH', 'LAST_FAKE_PATH'])
|
180
177
|
end
|
@@ -189,8 +186,8 @@ module VmShepherd
|
|
189
186
|
let(:aws_manager) { instance_double(AwsManager) }
|
190
187
|
let(:first_ami_file_path) { 'PATH_TO_AMI_FILE' }
|
191
188
|
let(:last_ami_file_path) { 'PATH_TO_AMI_FILE-2' }
|
192
|
-
let(:first_aws_options) { {vm_name
|
193
|
-
let(:last_aws_options) { {vm_name
|
189
|
+
let(:first_aws_options) { {'vm_name' => 'vm-name'} }
|
190
|
+
let(:last_aws_options) { {'vm_name' => 'vm-name-2'} }
|
194
191
|
|
195
192
|
it 'uses AwsManager to launch a VM' do
|
196
193
|
expect(AwsManager).to receive(:new).with(env_config: aws_env_config, logger: instance_of(Logger)).and_return(aws_manager)
|
@@ -303,36 +300,36 @@ module VmShepherd
|
|
303
300
|
|
304
301
|
it 'uses VcloudManager to destroy a vm' do
|
305
302
|
expect(VcloudManager).to receive(:new).with(
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
303
|
+
{
|
304
|
+
url: first_config.dig('creds', 'url'),
|
305
|
+
organization: first_config.dig('creds', 'organization'),
|
306
|
+
user: first_config.dig('creds', 'user'),
|
307
|
+
password: first_config.dig('creds', 'password'),
|
308
|
+
},
|
309
|
+
first_config.dig('vdc', 'name'),
|
310
|
+
instance_of(Logger)
|
311
|
+
).and_return(first_vcloud_manager)
|
315
312
|
|
316
313
|
expect(first_vcloud_manager).to receive(:destroy).with(
|
317
|
-
|
318
|
-
|
319
|
-
|
314
|
+
[first_config.dig('vapp', 'ops_manager_name')],
|
315
|
+
first_config.dig('vdc', 'catalog'),
|
316
|
+
)
|
320
317
|
|
321
318
|
expect(VcloudManager).to receive(:new).with(
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
319
|
+
{
|
320
|
+
url: last_config.dig('creds', 'url'),
|
321
|
+
organization: last_config.dig('creds', 'organization'),
|
322
|
+
user: last_config.dig('creds', 'user'),
|
323
|
+
password: last_config.dig('creds', 'password'),
|
324
|
+
},
|
325
|
+
last_config.dig('vdc', 'name'),
|
326
|
+
instance_of(Logger)
|
327
|
+
).and_return(last_vcloud_manager)
|
331
328
|
|
332
329
|
expect(last_vcloud_manager).to receive(:destroy).with(
|
333
|
-
|
334
|
-
|
335
|
-
|
330
|
+
[last_config.dig('vapp', 'ops_manager_name')],
|
331
|
+
last_config.dig('vdc', 'catalog'),
|
332
|
+
)
|
336
333
|
|
337
334
|
manager.destroy
|
338
335
|
end
|
@@ -345,22 +342,22 @@ module VmShepherd
|
|
345
342
|
|
346
343
|
it 'uses VsphereManager to destroy a vm' do
|
347
344
|
expect(VsphereManager).to receive(:new).with(
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
expect(first_ova_manager).to receive(:destroy).with(first_config.vm
|
345
|
+
first_config.dig('vcenter_creds', 'ip'),
|
346
|
+
first_config.dig('vcenter_creds', 'username'),
|
347
|
+
first_config.dig('vcenter_creds', 'password'),
|
348
|
+
first_config.dig('vsphere', 'datacenter'),
|
349
|
+
instance_of(Logger),
|
350
|
+
).and_return(first_ova_manager)
|
351
|
+
expect(first_ova_manager).to receive(:destroy).with(first_config.dig('vm', 'ip'), first_config.dig('vsphere', 'resource_pool'))
|
355
352
|
|
356
353
|
expect(VsphereManager).to receive(:new).with(
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
expect(last_ova_manager).to receive(:destroy).with(last_config.vm
|
354
|
+
last_config.dig('vcenter_creds', 'ip'),
|
355
|
+
last_config.dig('vcenter_creds', 'username'),
|
356
|
+
last_config.dig('vcenter_creds', 'password'),
|
357
|
+
last_config.dig('vsphere', 'datacenter'),
|
358
|
+
instance_of(Logger),
|
359
|
+
).and_return(last_ova_manager)
|
360
|
+
expect(last_ova_manager).to receive(:destroy).with(last_config.dig('vm', 'ip'), last_config.dig('vsphere', 'resource_pool'))
|
364
361
|
|
365
362
|
manager.destroy
|
366
363
|
end
|
@@ -369,8 +366,8 @@ module VmShepherd
|
|
369
366
|
context 'when IAAS is AWS' do
|
370
367
|
let(:settings_fixture_name) { 'aws.yml' }
|
371
368
|
let(:aws_manager) { instance_double(AwsManager) }
|
372
|
-
let(:first_ami_options) { {vm_name
|
373
|
-
let(:last_ami_options) { {vm_name
|
369
|
+
let(:first_ami_options) { {'vm_name' => 'vm-name'} }
|
370
|
+
let(:last_ami_options) { {'vm_name' => 'vm-name-2'} }
|
374
371
|
|
375
372
|
it 'uses AwsManager to destroy a VM' do
|
376
373
|
expect(AwsManager).to receive(:new).with(env_config: aws_env_config, logger: instance_of(Logger)).and_return(aws_manager)
|
@@ -474,36 +471,36 @@ module VmShepherd
|
|
474
471
|
|
475
472
|
it 'uses VcloudManager to destroy a vm' do
|
476
473
|
expect(VcloudManager).to receive(:new).with(
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
474
|
+
{
|
475
|
+
url: first_config.dig('creds', 'url'),
|
476
|
+
organization: first_config.dig('creds', 'organization'),
|
477
|
+
user: first_config.dig('creds', 'user'),
|
478
|
+
password: first_config.dig('creds', 'password'),
|
479
|
+
},
|
480
|
+
first_config.dig('vdc', 'name'),
|
481
|
+
instance_of(Logger)
|
482
|
+
).and_return(first_vcloud_manager)
|
486
483
|
|
487
484
|
expect(first_vcloud_manager).to receive(:clean_environment).with(
|
488
|
-
|
489
|
-
|
490
|
-
|
485
|
+
first_config.dig('vapp', 'product_names'),
|
486
|
+
first_config.dig('vapp', 'product_catalog'),
|
487
|
+
)
|
491
488
|
|
492
489
|
expect(VcloudManager).to receive(:new).with(
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
490
|
+
{
|
491
|
+
url: last_config.dig('creds', 'url'),
|
492
|
+
organization: last_config.dig('creds', 'organization'),
|
493
|
+
user: last_config.dig('creds', 'user'),
|
494
|
+
password: last_config.dig('creds', 'password'),
|
495
|
+
},
|
496
|
+
last_config.dig('vdc', 'name'),
|
497
|
+
instance_of(Logger)
|
498
|
+
).and_return(last_vcloud_manager)
|
502
499
|
|
503
500
|
expect(last_vcloud_manager).to receive(:clean_environment).with(
|
504
|
-
|
505
|
-
|
506
|
-
|
501
|
+
[],
|
502
|
+
last_config.dig('vapp', 'product_catalog'),
|
503
|
+
)
|
507
504
|
|
508
505
|
manager.clean_environment
|
509
506
|
end
|
@@ -514,36 +511,36 @@ module VmShepherd
|
|
514
511
|
let(:first_ova_manager) { instance_double(VsphereManager) }
|
515
512
|
let(:first_clean_environment_options) do
|
516
513
|
{
|
517
|
-
datacenter_folders_to_clean: first_config.cleanup
|
518
|
-
datastores: first_config.cleanup
|
519
|
-
datastore_folders_to_clean: first_config.cleanup
|
514
|
+
datacenter_folders_to_clean: first_config.dig('cleanup', 'datacenter_folders_to_clean'),
|
515
|
+
datastores: first_config.dig('cleanup', 'datastores'),
|
516
|
+
datastore_folders_to_clean: first_config.dig('cleanup', 'datastore_folders_to_clean'),
|
520
517
|
}
|
521
518
|
end
|
522
519
|
let(:last_ova_manager) { instance_double(VsphereManager) }
|
523
520
|
let(:last_clean_environment_options) do
|
524
521
|
{
|
525
|
-
datacenter_folders_to_clean: last_config.cleanup
|
526
|
-
datastores: last_config.cleanup
|
527
|
-
datastore_folders_to_clean: last_config.cleanup
|
522
|
+
datacenter_folders_to_clean: last_config.dig('cleanup', 'datacenter_folders_to_clean'),
|
523
|
+
datastores: last_config.dig('cleanup', 'datastores'),
|
524
|
+
datastore_folders_to_clean: last_config.dig('cleanup', 'datastore_folders_to_clean'),
|
528
525
|
}
|
529
526
|
end
|
530
527
|
|
531
528
|
it 'uses VsphereManager to destroy a vm' do
|
532
529
|
expect(VsphereManager).to receive(:new).with(
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
530
|
+
first_config.dig('vcenter_creds', 'ip'),
|
531
|
+
first_config.dig('vcenter_creds', 'username'),
|
532
|
+
first_config.dig('vcenter_creds', 'password'),
|
533
|
+
first_config.dig('cleanup', 'datacenter'),
|
534
|
+
instance_of(Logger),
|
535
|
+
).and_return(first_ova_manager)
|
539
536
|
expect(first_ova_manager).to receive(:clean_environment).with(first_clean_environment_options)
|
540
537
|
expect(VsphereManager).to receive(:new).with(
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
538
|
+
last_config.dig('vcenter_creds', 'ip'),
|
539
|
+
last_config.dig('vcenter_creds', 'username'),
|
540
|
+
last_config.dig('vcenter_creds', 'password'),
|
541
|
+
last_config.dig('cleanup', 'datacenter'),
|
542
|
+
instance_of(Logger),
|
543
|
+
).and_return(last_ova_manager)
|
547
544
|
expect(last_ova_manager).to receive(:clean_environment).with(last_clean_environment_options)
|
548
545
|
|
549
546
|
manager.clean_environment
|
@@ -642,28 +639,28 @@ module VmShepherd
|
|
642
639
|
|
643
640
|
it 'uses VcloudManager to destroy a vm' do
|
644
641
|
expect(VcloudManager).to receive(:new).with(
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
642
|
+
{
|
643
|
+
url: first_config.dig('creds', 'url'),
|
644
|
+
organization: first_config.dig('creds', 'organization'),
|
645
|
+
user: first_config.dig('creds', 'user'),
|
646
|
+
password: first_config.dig('creds', 'password'),
|
647
|
+
},
|
648
|
+
first_config.dig('vdc', 'name'),
|
649
|
+
instance_of(Logger)
|
650
|
+
).and_return(first_vcloud_manager)
|
654
651
|
|
655
652
|
expect(first_vcloud_manager).to receive(:prepare_environment)
|
656
653
|
|
657
654
|
expect(VcloudManager).to receive(:new).with(
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
655
|
+
{
|
656
|
+
url: last_config.dig('creds', 'url'),
|
657
|
+
organization: last_config.dig('creds', 'organization'),
|
658
|
+
user: last_config.dig('creds', 'user'),
|
659
|
+
password: last_config.dig('creds', 'password'),
|
660
|
+
},
|
661
|
+
last_config.dig('vdc', 'name'),
|
662
|
+
instance_of(Logger)
|
663
|
+
).and_return(last_vcloud_manager)
|
667
664
|
|
668
665
|
expect(last_vcloud_manager).to receive(:prepare_environment)
|
669
666
|
manager.prepare_environment
|
@@ -677,20 +674,20 @@ module VmShepherd
|
|
677
674
|
|
678
675
|
it 'uses VsphereManager to destroy a vm' do
|
679
676
|
expect(VsphereManager).to receive(:new).with(
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
677
|
+
first_config.dig('vcenter_creds', 'ip'),
|
678
|
+
first_config.dig('vcenter_creds', 'username'),
|
679
|
+
first_config.dig('vcenter_creds', 'password'),
|
680
|
+
first_config.dig('vsphere', 'datacenter'),
|
681
|
+
instance_of(Logger),
|
682
|
+
).and_return(first_ova_manager)
|
686
683
|
expect(first_ova_manager).to receive(:prepare_environment)
|
687
684
|
expect(VsphereManager).to receive(:new).with(
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
685
|
+
last_config.dig('vcenter_creds', 'ip'),
|
686
|
+
last_config.dig('vcenter_creds', 'username'),
|
687
|
+
last_config.dig('vcenter_creds', 'password'),
|
688
|
+
last_config.dig('vsphere', 'datacenter'),
|
689
|
+
instance_of(Logger),
|
690
|
+
).and_return(last_ova_manager)
|
694
691
|
expect(last_ova_manager).to receive(:prepare_environment)
|
695
692
|
|
696
693
|
manager.prepare_environment
|
@@ -30,7 +30,7 @@ module VmShepherd
|
|
30
30
|
allow(client).to receive(:create_catalog).and_return(catalog)
|
31
31
|
allow(catalog).to receive(:upload_vapp_template)
|
32
32
|
allow(catalog).to receive(:instantiate_vapp_template).and_return(vapp)
|
33
|
-
allow(vapp).to
|
33
|
+
allow(vapp).to receive(:find_vm_by_name).and_return(vm)
|
34
34
|
allow(vm).to receive(:product_section_properties=)
|
35
35
|
allow(vapp).to receive(:power_on)
|
36
36
|
|
@@ -140,7 +140,7 @@ module VmShepherd
|
|
140
140
|
|
141
141
|
allow(VCloudSdk::NetworkConfig).to receive(:new).and_return(network_config)
|
142
142
|
|
143
|
-
allow(vapp).to
|
143
|
+
allow(vapp).to receive(:find_vm_by_name).and_return(vm)
|
144
144
|
allow(vm).to receive(:product_section_properties=)
|
145
145
|
allow(vapp).to receive(:power_on)
|
146
146
|
end
|
data/vm_shepherd.gemspec
CHANGED
@@ -21,14 +21,13 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency 'fog', '1.34.0'
|
22
22
|
spec.add_dependency 'net-ssh' # because fog uses this but doesn't require it
|
23
23
|
|
24
|
-
spec.add_dependency '
|
25
|
-
|
26
|
-
spec.add_dependency 'ruby_vcloud_sdk', '0.7.4'
|
24
|
+
spec.add_dependency 'ruby_vcloud_sdk', '0.7.2'
|
27
25
|
|
28
26
|
spec.add_dependency 'rbvmomi'
|
29
27
|
|
30
28
|
spec.add_development_dependency 'bundler'
|
31
29
|
spec.add_development_dependency 'rake'
|
32
30
|
spec.add_development_dependency 'rspec'
|
31
|
+
spec.add_development_dependency 'rubocop'
|
33
32
|
spec.add_development_dependency 'codeclimate-test-reporter'
|
34
33
|
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:
|
4
|
+
version: 2.0.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-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-v1
|
@@ -53,41 +53,41 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: ruby_vcloud_sdk
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.7.2
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.7.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rbvmomi
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0
|
75
|
+
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
|
-
type: :
|
90
|
+
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: rspec
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: rubocop
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ">="
|