chef-provisioning-vsphere 0.5.7.dev5 → 0.5.7.dev6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/provisioning/vsphere_driver/clone_spec_builder.rb +19 -12
- data/lib/chef/provisioning/vsphere_driver/driver.rb +1 -1
- data/lib/chef/provisioning/vsphere_driver/version.rb +1 -1
- data/spec/unit_tests/clone_spec_builder_spec.rb +72 -4
- data/spec/unit_tests/support/vsphere_helper_stub.rb +21 -1
- 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: 9a2f55b3a6433abfdd06aa270db00b1bed0cb8ab
|
4
|
+
data.tar.gz: 74c8800daf24128394246648b0e02540ac0485e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56b566ca067ed38e6d7b639d6a687468b1189be2693bcd608cd85753d98cba8361009f00e145bf2ee2f9dffc8c766898767787f6f1b9177b73271a5dbc3359ce
|
7
|
+
data.tar.gz: a01d8b591d62cd589569f868e3aa606c1f133f6a099caaab60534628848a56168014d3cd0a95a6722c86d61d8594ca743fe2ff0add2919ca5706ddb99da1cbcf
|
@@ -51,23 +51,30 @@ module ChefProvisioningVsphere
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def relocate_spec_for(vm_template, options)
|
54
|
+
rspec = RbVmomi::VIM.VirtualMachineRelocateSpec
|
55
|
+
host = nil
|
56
|
+
|
54
57
|
if options.has_key?(:host)
|
55
58
|
host = vsphere_helper.find_host(options[:host])
|
56
|
-
rspec =
|
57
|
-
else
|
58
|
-
if options[:resource_pool]
|
59
|
-
pool = vsphere_helper.find_pool(options[:resource_pool])
|
60
|
-
else
|
61
|
-
pool = vm_template.resourcePool
|
62
|
-
end
|
63
|
-
rspec = RbVmomi::VIM.VirtualMachineRelocateSpec(pool: pool)
|
64
|
-
raise "either :host or :resource_pool must be specified \
|
65
|
-
when cloning from a VM Template" if pool.nil?
|
59
|
+
rspec.host = host
|
66
60
|
end
|
67
61
|
|
62
|
+
if options[:resource_pool]
|
63
|
+
rspec.pool = vsphere_helper.find_pool(options[:resource_pool])
|
64
|
+
elsif vm_template.config.template && !host.nil?
|
65
|
+
rspec.pool = host.parent.resourcePool # assign to the "invisible" pool root
|
66
|
+
elsif vm_template.config.template
|
67
|
+
raise 'either :host or :resource_pool must be specified when cloning from a VM Template'
|
68
|
+
end
|
69
|
+
|
70
|
+
|
68
71
|
if options[:use_linked_clone]
|
69
|
-
|
70
|
-
|
72
|
+
if vm_template.config.template
|
73
|
+
Chef::Log.warn("Using a VM Template, ignoring use_linked_clone.")
|
74
|
+
else
|
75
|
+
vsphere_helper.create_delta_disk(vm_template)
|
76
|
+
rspec.diskMoveType = :moveChildMostDiskBacking
|
77
|
+
end
|
71
78
|
end
|
72
79
|
|
73
80
|
unless options[:datastore].to_s.empty?
|
@@ -495,7 +495,7 @@ module ChefProvisioningVsphere
|
|
495
495
|
|
496
496
|
spec_builder = CloneSpecBuilder.new(vsphere_helper, action_handler)
|
497
497
|
clone_spec = spec_builder.build(vm_template, machine_name, bootstrap_options)
|
498
|
-
Chef::Log.debug("Clone spec: #{clone_spec.pretty_inspect}")
|
498
|
+
Chef::Log.debug("Clone spec: #{clone_spec.pretty_inspect}")
|
499
499
|
|
500
500
|
vm_folder = vsphere_helper.find_folder(bootstrap_options[:vm_folder])
|
501
501
|
vm_template.CloneVM_Task(
|
@@ -3,10 +3,14 @@ require 'chef/provisioning/vsphere_driver'
|
|
3
3
|
require_relative 'support/vsphere_helper_stub'
|
4
4
|
|
5
5
|
describe ChefProvisioningVsphere::CloneSpecBuilder do
|
6
|
-
let(:options) {
|
7
|
-
let(:vm_template) { double('template'
|
6
|
+
let(:options) { Hash.new }
|
7
|
+
let(:vm_template) { double('template') }
|
8
8
|
|
9
|
-
before
|
9
|
+
before do
|
10
|
+
allow(vm_template).to receive_message_chain(:config, :guestId)
|
11
|
+
allow(vm_template).to receive_message_chain(:config, :template)
|
12
|
+
.and_return(false)
|
13
|
+
end
|
10
14
|
|
11
15
|
subject do
|
12
16
|
builder = ChefProvisioningVsphere::CloneSpecBuilder.new(
|
@@ -24,11 +28,75 @@ describe ChefProvisioningVsphere::CloneSpecBuilder do
|
|
24
28
|
end
|
25
29
|
end
|
26
30
|
|
31
|
+
context 'using linked clone on a template source' do
|
32
|
+
before do
|
33
|
+
options[:use_linked_clone] = true
|
34
|
+
options[:host] = 'host'
|
35
|
+
allow(vm_template).to receive_message_chain(:config, :template)
|
36
|
+
.and_return(true)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'does not set the disk move type of the relocation spec' do
|
40
|
+
expect(subject.location.diskMoveType).to be nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
27
44
|
context 'not using linked clones' do
|
28
45
|
before { options[:use_linked_clone] = false }
|
29
46
|
|
30
|
-
it '
|
47
|
+
it 'does not set the disk move type of the relocation spec' do
|
31
48
|
expect(subject.location.diskMoveType).to be nil
|
32
49
|
end
|
33
50
|
end
|
51
|
+
|
52
|
+
context 'specifying a host' do
|
53
|
+
before { options[:host] = 'host' }
|
54
|
+
|
55
|
+
it 'sets the host' do
|
56
|
+
expect(subject.location.host).to_not be nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'not specifying a host' do
|
61
|
+
it 'does not set the host' do
|
62
|
+
expect(subject.location.host).to be nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'specifying a pool' do
|
67
|
+
before { options[:resource_pool] = 'pool' }
|
68
|
+
|
69
|
+
it 'sets the pool' do
|
70
|
+
expect(subject.location.pool).to_not be nil
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'not specifying a pool' do
|
75
|
+
it 'does not set the pool' do
|
76
|
+
expect(subject.location.pool).to be nil
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'not specifying a pool but specifying a host on a template' do
|
81
|
+
before do
|
82
|
+
options[:host] = 'host'
|
83
|
+
allow(vm_template).to receive_message_chain(:config, :template)
|
84
|
+
.and_return(true)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'sets the pool to the hosts parent root pool' do
|
88
|
+
expect(subject.location.pool).to be subject.location.host.parent.resourcePool
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'not specifying a pool or host when cloning from a template' do
|
93
|
+
before do
|
94
|
+
allow(vm_template).to receive_message_chain(:config, :template)
|
95
|
+
.and_return(true)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'raises an error' do
|
99
|
+
expect { subject.to raise_error }
|
100
|
+
end
|
101
|
+
end
|
34
102
|
end
|
@@ -11,7 +11,7 @@ module ChefProvisioningVsphereStubs
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def find_host(host_name)
|
14
|
-
RbVmomi::VIM::HostSystem.new
|
14
|
+
RbVmomi::VIM::HostSystem.new
|
15
15
|
end
|
16
16
|
|
17
17
|
def find_pool(pool_name)
|
@@ -30,3 +30,23 @@ module ChefProvisioningVsphereStubs
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
module RbVmomi
|
35
|
+
class VIM::HostSystem
|
36
|
+
attr_reader :parent
|
37
|
+
|
38
|
+
def parent
|
39
|
+
@parent ||= RbVmomi::VIM::ComputeResource.new
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
module RbVmomi
|
45
|
+
class VIM::ComputeResource
|
46
|
+
attr_reader :resourcePool
|
47
|
+
|
48
|
+
def resourcePool
|
49
|
+
@resourcePool ||= RbVmomi::VIM::ResourcePool.new(nil, nil)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-provisioning-vsphere
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.7.
|
4
|
+
version: 0.5.7.dev6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CenturyLink Cloud
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbvmomi
|