vm_shepherd 3.5.0 → 3.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a056d918fa69521babd0636b90a36bbc4e75a9bc
4
- data.tar.gz: 23ec4f0d83d118542fc213139604efaaa5b52fd2
3
+ metadata.gz: 756d9a70d96ccda7ec70f94f6696609f891ca919
4
+ data.tar.gz: 8de386223858e604289442480c2afc2ec13b1a2b
5
5
  SHA512:
6
- metadata.gz: ce2cf10d6f705dd3633ec9d3c537c97131568ca6d91f5692a3c887d2f42fb44ffbd28ed854814f0d953a842f4424fcad651410c0b0b436a7b8af26dba7ab3a0d
7
- data.tar.gz: be9a971752b45af0359c8bd41825ef85f545ba97a1f69b29119a96816e4821de46ee7e43aeca36705127d99551860c932da318aa5b6c89df0a81fb33b9e586f3
6
+ metadata.gz: aeca796706b5cadc48fef207c01f27025dc53d7a042caa1d2e02d5734ac41f6b179c171be2ac107262989390ab58f0f786933fa0f6ad23795686fec4718bf787
7
+ data.tar.gz: ba4b1dc89e6bf841b0081722120e39a23672e17a2c687383e283d4069ae59c9335c4afbd92a2eb82d93048e97565f653b0b380b9f29d6dd0fa6c0c491f12c166
@@ -38,7 +38,7 @@ module VmShepherd
38
38
  path,
39
39
  vcloud_deploy_options(vm_shepherd_config),
40
40
  )
41
- when VmShepherd::VSPHERE_IAAS_TYPE then
41
+ when VmShepherd::VSPHERE_IAAS_TYPE then
42
42
  VmShepherd::VsphereManager.new(
43
43
  vm_shepherd_config.dig('vcenter_creds', 'ip'),
44
44
  vm_shepherd_config.dig('vcenter_creds', 'username'),
@@ -182,20 +182,31 @@ module VmShepherd
182
182
  end
183
183
 
184
184
  def vsphere_vm_options(input_config)
185
- {
185
+ vsphere_vm_options = {
186
186
  ip: input_config.dig('vm', 'ip'),
187
187
  gateway: input_config.dig('vm', 'gateway'),
188
188
  netmask: input_config.dig('vm', 'netmask'),
189
189
  dns: input_config.dig('vm', 'dns'),
190
190
  ntp_servers: input_config.dig('vm', 'ntp_servers'),
191
191
  cpus: input_config.dig('vm', 'cpus'),
192
- ram_mb: input_config.dig('vm', 'ram_mb'),
193
- vm_password: (input_config.dig('vm', 'vm_password') || 'tempest'),
194
- public_ssh_key: read_assets_home(input_config.dig('vm', 'public_ssh_key')),
192
+ ram_mb: input_config.dig('vm', 'ram_mb')
195
193
  }.tap do |result|
196
194
  hostname = input_config.dig('vm', 'custom_hostname')
197
195
  result[:custom_hostname] = hostname unless hostname.nil?
198
196
  end
197
+
198
+ vsphere_vm_options.merge!(vm_password: get_vsphere_vm_password(input_config))
199
+ vsphere_vm_options.merge!(public_ssh_key: get_vsphere_vm_public_ssh_key(input_config))
200
+
201
+ vsphere_vm_options
202
+ end
203
+
204
+ def get_vsphere_vm_password(input_config)
205
+ ENV['PROVISION_WITH_PASSWORD'] == 'false' ? nil : (input_config.dig('vm', 'vm_password') || 'tempest')
206
+ end
207
+
208
+ def get_vsphere_vm_public_ssh_key(input_config)
209
+ ENV['PROVISION_WITH_SSH_KEY'] == 'false' ? nil : (read_assets_home(input_config.dig('vm', 'public_ssh_key')))
199
210
  end
200
211
 
201
212
  def read_assets_home(path_or_value)
@@ -1,3 +1,3 @@
1
1
  module VmShepherd
2
- VERSION = '3.5.0'.freeze
2
+ VERSION = '3.6.0'.freeze
3
3
  end
@@ -0,0 +1,35 @@
1
+ iaas_type: vsphere
2
+ vm_shepherd:
3
+ vm_configs:
4
+ - vcenter_creds:
5
+ ip: OVA_URL
6
+ username: OVA_ORGANIZATION
7
+ password: OVA_PASSWORD
8
+ vsphere:
9
+ datacenter: VSPHERE_DATACENTER
10
+ cluster: VSPHERE_CLUSTER
11
+ network: VSPHERE_NETWORK
12
+ resource_pool: VSPHERE_RESOURCE_POOL
13
+ datastore: VSPHERE_DATASTORE
14
+ folder: VSPHERE_FOLDER
15
+ vm:
16
+ ip: OVA_IP
17
+ gateway: OVA_GATEWAY
18
+ netmask: OVA_NETMASK
19
+ dns: OVA_DNS
20
+ ntp_servers: OVA_NTP
21
+ public_ssh_key: OVA_SSH_KEY
22
+ cpus: OVA_CPUS
23
+ ram_mb: OVA_RAM_MB
24
+ vm_password: not-tempest
25
+ custom_hostname: not-default-hostname
26
+ cleanup:
27
+ datacenter: VSPHERE_OTHER_DATACENTER
28
+ datastores:
29
+ - VSPHERE_DATASTORE_ONE
30
+ - VSPHERE_DATASTORE_TWO
31
+ datacenter_folders_to_clean:
32
+ - DC_FOLDER_ONE
33
+ - DC_FOLDER_TWO
34
+ datastore_folders_to_clean:
35
+ - DS_DISK_FOLDER
@@ -281,6 +281,145 @@ module VmShepherd
281
281
  manager.deploy(paths: ['FIRST_FAKE_PATH', 'LAST_FAKE_PATH'])
282
282
  end
283
283
  end
284
+
285
+ context 'when provision environment variables are set' do
286
+ before do
287
+ allow(VsphereManager).to receive(:new).with(
288
+ first_config.dig('vcenter_creds', 'ip'),
289
+ first_config.dig('vcenter_creds', 'username'),
290
+ first_config.dig('vcenter_creds', 'password'),
291
+ first_config.dig('vsphere', 'datacenter'),
292
+ instance_of(Logger),
293
+ ).and_return(first_ova_manager)
294
+
295
+ allow_any_instance_of(Shepherd).to receive(:read_assets_home).and_return('A PUBLIC KEY')
296
+ end
297
+ let(:settings_fixture_name) { 'vsphere-one-vm-config.yml' }
298
+
299
+ context 'when the PROVISION_WITH_PASSWORD environment variable is set' do
300
+ context 'and it is true' do
301
+ before { stub_const('ENV', {'PROVISION_WITH_PASSWORD' => 'true'}) }
302
+
303
+ it 'deploys with the set vm password' do
304
+ expect(first_ova_manager).to receive(:deploy).with(
305
+ 'FIRST_FAKE_PATH',
306
+ {
307
+ ip: first_config.dig('vm', 'ip'),
308
+ gateway: first_config.dig('vm', 'gateway'),
309
+ netmask: first_config.dig('vm', 'netmask'),
310
+ dns: first_config.dig('vm', 'dns'),
311
+ ntp_servers: first_config.dig('vm', 'ntp_servers'),
312
+ cpus: first_config.dig('vm', 'cpus'),
313
+ ram_mb: first_config.dig('vm', 'ram_mb'),
314
+ vm_password: first_config.dig('vm', 'vm_password'),
315
+ public_ssh_key: 'A PUBLIC KEY',
316
+ custom_hostname: first_config.dig('vm', 'custom_hostname')
317
+ },
318
+ {
319
+ cluster: first_config.dig('vsphere', 'cluster'),
320
+ resource_pool: first_config.dig('vsphere', 'resource_pool'),
321
+ datastore: first_config.dig('vsphere', 'datastore'),
322
+ network: first_config.dig('vsphere', 'network'),
323
+ folder: first_config.dig('vsphere', 'folder'),
324
+ },
325
+ )
326
+ manager.deploy(paths: ['FIRST_FAKE_PATH'])
327
+ end
328
+ end
329
+
330
+ context 'and it is false' do
331
+ before { stub_const('ENV', {'PROVISION_WITH_PASSWORD' => 'false'}) }
332
+
333
+ it 'deploys with a nil vm password' do
334
+ expect(first_ova_manager).to receive(:deploy).with(
335
+ 'FIRST_FAKE_PATH',
336
+ {
337
+ ip: first_config.dig('vm', 'ip'),
338
+ gateway: first_config.dig('vm', 'gateway'),
339
+ netmask: first_config.dig('vm', 'netmask'),
340
+ dns: first_config.dig('vm', 'dns'),
341
+ ntp_servers: first_config.dig('vm', 'ntp_servers'),
342
+ cpus: first_config.dig('vm', 'cpus'),
343
+ ram_mb: first_config.dig('vm', 'ram_mb'),
344
+ vm_password: nil,
345
+ public_ssh_key: 'A PUBLIC KEY',
346
+ custom_hostname: first_config.dig('vm', 'custom_hostname')
347
+ },
348
+ {
349
+ cluster: first_config.dig('vsphere', 'cluster'),
350
+ resource_pool: first_config.dig('vsphere', 'resource_pool'),
351
+ datastore: first_config.dig('vsphere', 'datastore'),
352
+ network: first_config.dig('vsphere', 'network'),
353
+ folder: first_config.dig('vsphere', 'folder'),
354
+ },
355
+ )
356
+ manager.deploy(paths: ['FIRST_FAKE_PATH'])
357
+ end
358
+ end
359
+ end
360
+
361
+ context 'when the PROVISION_WITH_SSH_KEY environment variable is set' do
362
+ context 'and it is true' do
363
+ before { stub_const('ENV', {'PROVISION_WITH_SSH_KEY' => 'true'}) }
364
+
365
+ it 'deploys with the set public ssh key' do
366
+ expect(first_ova_manager).to receive(:deploy).with(
367
+ 'FIRST_FAKE_PATH',
368
+ {
369
+ ip: first_config.dig('vm', 'ip'),
370
+ gateway: first_config.dig('vm', 'gateway'),
371
+ netmask: first_config.dig('vm', 'netmask'),
372
+ dns: first_config.dig('vm', 'dns'),
373
+ ntp_servers: first_config.dig('vm', 'ntp_servers'),
374
+ cpus: first_config.dig('vm', 'cpus'),
375
+ ram_mb: first_config.dig('vm', 'ram_mb'),
376
+ vm_password: first_config.dig('vm', 'vm_password'),
377
+ public_ssh_key: 'A PUBLIC KEY',
378
+ custom_hostname: first_config.dig('vm', 'custom_hostname')
379
+ },
380
+ {
381
+ cluster: first_config.dig('vsphere', 'cluster'),
382
+ resource_pool: first_config.dig('vsphere', 'resource_pool'),
383
+ datastore: first_config.dig('vsphere', 'datastore'),
384
+ network: first_config.dig('vsphere', 'network'),
385
+ folder: first_config.dig('vsphere', 'folder'),
386
+ },
387
+ )
388
+ manager.deploy(paths: ['FIRST_FAKE_PATH'])
389
+ end
390
+ end
391
+
392
+ context 'and it is false' do
393
+ before { stub_const('ENV', {'PROVISION_WITH_SSH_KEY' => 'false'}) }
394
+
395
+ it 'deploys with a nil public ssh key' do
396
+ expect(first_ova_manager).to receive(:deploy).with(
397
+ 'FIRST_FAKE_PATH',
398
+ {
399
+ ip: first_config.dig('vm', 'ip'),
400
+ gateway: first_config.dig('vm', 'gateway'),
401
+ netmask: first_config.dig('vm', 'netmask'),
402
+ dns: first_config.dig('vm', 'dns'),
403
+ ntp_servers: first_config.dig('vm', 'ntp_servers'),
404
+ cpus: first_config.dig('vm', 'cpus'),
405
+ ram_mb: first_config.dig('vm', 'ram_mb'),
406
+ vm_password: first_config.dig('vm', 'vm_password'),
407
+ public_ssh_key: nil,
408
+ custom_hostname: first_config.dig('vm', 'custom_hostname')
409
+ },
410
+ {
411
+ cluster: first_config.dig('vsphere', 'cluster'),
412
+ resource_pool: first_config.dig('vsphere', 'resource_pool'),
413
+ datastore: first_config.dig('vsphere', 'datastore'),
414
+ network: first_config.dig('vsphere', 'network'),
415
+ folder: first_config.dig('vsphere', 'folder'),
416
+ },
417
+ )
418
+ manager.deploy(paths: ['FIRST_FAKE_PATH'])
419
+ end
420
+ end
421
+ end
422
+ end
284
423
  end
285
424
 
286
425
  context 'with AWS settings' do
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.5.0
4
+ version: 3.6.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: 2018-08-01 00:00:00.000000000 Z
11
+ date: 2018-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-v1
@@ -173,6 +173,7 @@ files:
173
173
  - spec/fixtures/shepherd/openstack.yml
174
174
  - spec/fixtures/shepherd/unknown.yml
175
175
  - spec/fixtures/shepherd/vcloud.yml
176
+ - spec/fixtures/shepherd/vsphere-one-vm-config.yml
176
177
  - spec/fixtures/shepherd/vsphere.yml
177
178
  - spec/spec_helper.rb
178
179
  - spec/support/patched_fog.rb
@@ -218,6 +219,7 @@ test_files:
218
219
  - spec/fixtures/shepherd/openstack.yml
219
220
  - spec/fixtures/shepherd/unknown.yml
220
221
  - spec/fixtures/shepherd/vcloud.yml
222
+ - spec/fixtures/shepherd/vsphere-one-vm-config.yml
221
223
  - spec/fixtures/shepherd/vsphere.yml
222
224
  - spec/spec_helper.rb
223
225
  - spec/support/patched_fog.rb