chef-provisioning-vsphere 0.10.0 → 1.0.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 +4 -4
- data/.gitignore +7 -3
- data/.rubocop.yml +8 -0
- data/.rubocop_todo.yml +143 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +111 -0
- data/Gemfile +2 -3
- data/LICENSE +19 -19
- data/LICENSE-Rally +20 -20
- data/README.md +29 -19
- data/Rakefile +34 -22
- data/chef-provisioning-vsphere.gemspec +9 -7
- data/contribution-notice +7 -7
- data/lib/chef/provisioning/driver_init/vsphere.rb +4 -3
- data/lib/chef/provisioning/vsphere_driver.rb +16 -14
- data/lib/chef/provisioning/vsphere_driver/clone_spec_builder.rb +68 -53
- data/lib/chef/provisioning/vsphere_driver/driver.rb +96 -70
- data/lib/chef/provisioning/vsphere_driver/version.rb +2 -1
- data/lib/chef/provisioning/vsphere_driver/vsphere_helpers.rb +98 -99
- data/lib/chef/provisioning/vsphere_driver/vsphere_url.rb +46 -45
- data/lib/kitchen/driver/vsphere.rb +27 -27
- data/spec/integration_tests/.gitignore +1 -1
- data/spec/integration_tests/vsphere_driver_spec.rb +50 -51
- data/spec/unit_tests/VsphereDriver_spec.rb +133 -132
- data/spec/unit_tests/VsphereUrl_spec.rb +67 -66
- data/spec/unit_tests/clone_spec_builder_spec.rb +162 -161
- data/spec/unit_tests/support/fake_action_handler.rb +6 -7
- data/spec/unit_tests/support/vsphere_helper_stub.rb +51 -52
- metadata +29 -10
@@ -1,66 +1,67 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative '../../lib/chef/provisioning/vsphere_driver/vsphere_url.rb'
|
3
|
+
|
4
|
+
describe 'VsphereUrl' do
|
5
|
+
expected_host = '1.1.1.1'
|
6
|
+
expected_port = 1818
|
7
|
+
expected_path = '/path'
|
8
|
+
|
9
|
+
let(:url) { URI("vsphere://#{expected_host}:#{expected_port}#{expected_path}") }
|
10
|
+
|
11
|
+
it 'has the vsphere scheme' do
|
12
|
+
expect(url.scheme).to eq('vsphere')
|
13
|
+
end
|
14
|
+
it 'has the expected host' do
|
15
|
+
expect(url.host).to eq(expected_host)
|
16
|
+
end
|
17
|
+
it 'has the expected port' do
|
18
|
+
expect(url.port).to eq(expected_port)
|
19
|
+
end
|
20
|
+
it 'has the expected path' do
|
21
|
+
expect(url.path).to eq(expected_path)
|
22
|
+
end
|
23
|
+
it 'has the the default ssl setting' do
|
24
|
+
expect(url.use_ssl).to eq(true)
|
25
|
+
end
|
26
|
+
it 'has the the default insecure setting' do
|
27
|
+
expect(url.insecure).to eq(false)
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when setting from a hash' do
|
31
|
+
let(:url) do
|
32
|
+
URI::VsphereUrl.from_config(host: '2.2.2.2',
|
33
|
+
port: 2345,
|
34
|
+
path: '/hoooo',
|
35
|
+
use_ssl: false,
|
36
|
+
insecure: true)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'asigns the correct url' do
|
40
|
+
expect(url.to_s).to eq('vsphere://2.2.2.2:2345/hoooo?use_ssl=false&insecure=true')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
context 'when ssl is enabled' do
|
44
|
+
it 'retuns an ssl value of true' do
|
45
|
+
url = URI("vsphere://#{expected_host}:#{expected_port}#{expected_path}?use_ssl=true")
|
46
|
+
expect(url.use_ssl).to eq(true)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
context 'when ssl is disabled' do
|
50
|
+
it 'retuns an ssl value of true' do
|
51
|
+
url = URI("vsphere://#{expected_host}:#{expected_port}#{expected_path}?use_ssl=false")
|
52
|
+
expect(url.use_ssl).to eq(false)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
context 'when insecure is enabled' do
|
56
|
+
it 'retuns an insecure value of true' do
|
57
|
+
url = URI("vsphere://#{expected_host}:#{expected_port}#{expected_path}?insecure=true")
|
58
|
+
expect(url.insecure).to eq(true)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
context 'when insecure is disabled' do
|
62
|
+
it 'retuns an insecure value of true' do
|
63
|
+
url = URI("vsphere://#{expected_host}:#{expected_port}#{expected_path}?insecure=false")
|
64
|
+
expect(url.insecure).to eq(false)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -1,161 +1,162 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require_relative 'support/
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
let(:
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
ChefProvisioningVsphereStubs::
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
options[:
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'chef/provisioning/vsphere_driver'
|
3
|
+
require_relative 'support/fake_action_handler'
|
4
|
+
require_relative 'support/vsphere_helper_stub'
|
5
|
+
|
6
|
+
describe ChefProvisioningVsphere::CloneSpecBuilder do
|
7
|
+
let(:options) { Hash.new }
|
8
|
+
let(:vm_template) { double('template') }
|
9
|
+
|
10
|
+
before do
|
11
|
+
allow(vm_template).to receive_message_chain(:config, :guestId)
|
12
|
+
.and_return('guest')
|
13
|
+
allow(vm_template).to receive_message_chain(:config, :template)
|
14
|
+
.and_return(false)
|
15
|
+
end
|
16
|
+
|
17
|
+
subject do
|
18
|
+
builder = ChefProvisioningVsphere::CloneSpecBuilder.new(
|
19
|
+
ChefProvisioningVsphereStubs::VsphereHelperStub.new,
|
20
|
+
ChefProvisioningVsphereStubs::FakeActionHandler.new
|
21
|
+
)
|
22
|
+
builder.build(vm_template, 'machine_name', options)
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'using linked clones' do
|
26
|
+
before { options[:use_linked_clone] = true }
|
27
|
+
|
28
|
+
it 'sets the disk move type of the relocation spec' do
|
29
|
+
expect(subject.location.diskMoveType).to be :moveChildMostDiskBacking
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'using linked clone on a template source' do
|
34
|
+
before do
|
35
|
+
options[:use_linked_clone] = true
|
36
|
+
options[:host] = 'host'
|
37
|
+
allow(vm_template).to receive_message_chain(:config, :template)
|
38
|
+
.and_return(true)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'does not set the disk move type of the relocation spec' do
|
42
|
+
expect(subject.location.diskMoveType).to be nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'not using linked clones' do
|
47
|
+
before { options[:use_linked_clone] = false }
|
48
|
+
|
49
|
+
it 'does not set the disk move type of the relocation spec' do
|
50
|
+
expect(subject.location.diskMoveType).to be nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'specifying a host' do
|
55
|
+
before { options[:host] = 'host' }
|
56
|
+
|
57
|
+
it 'sets the host' do
|
58
|
+
expect(subject.location.host).to_not be nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'not specifying a host' do
|
63
|
+
it 'does not set the host' do
|
64
|
+
expect(subject.location.host).to be nil
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'specifying a pool' do
|
69
|
+
before { options[:resource_pool] = 'pool' }
|
70
|
+
|
71
|
+
it 'sets the pool' do
|
72
|
+
expect(subject.location.pool).to_not be nil
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'not specifying a pool' do
|
77
|
+
it 'does not set the pool' do
|
78
|
+
expect(subject.location.pool).to be nil
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'not specifying a pool but specifying a host on a template' do
|
83
|
+
before do
|
84
|
+
options[:host] = 'host'
|
85
|
+
allow(vm_template).to receive_message_chain(:config, :template)
|
86
|
+
.and_return(true)
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'sets the pool to the hosts parent root pool' do
|
90
|
+
expect(subject.location.pool).to be subject.location.host.parent.resourcePool
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'not specifying a pool or host when cloning from a template' do
|
95
|
+
before do
|
96
|
+
allow(vm_template).to receive_message_chain(:config, :template)
|
97
|
+
.and_return(true)
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'raises an error' do
|
101
|
+
expect { subject }.to raise_error
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'specifying a hostname' do
|
106
|
+
before do
|
107
|
+
options[:customization_spec] = {
|
108
|
+
ipsettings: {},
|
109
|
+
hostname: hostname,
|
110
|
+
domain: 'local'
|
111
|
+
}
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'alpha characters only' do
|
115
|
+
let(:hostname) { 'myhost' }
|
116
|
+
|
117
|
+
it 'sets the spec hostname' do
|
118
|
+
expect(subject.customization.identity.hostName.name).to eq hostname
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
context 'alpha numeric characters only' do
|
123
|
+
let(:hostname) { 'myhost01' }
|
124
|
+
|
125
|
+
it 'sets the spec hostname' do
|
126
|
+
expect(subject.customization.identity.hostName.name).to eq hostname
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'containing a dash' do
|
131
|
+
let(:hostname) { 'my-host01' }
|
132
|
+
|
133
|
+
it 'sets the spec hostname' do
|
134
|
+
expect(subject.customization.identity.hostName.name).to eq hostname
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context 'containing an underscore' do
|
139
|
+
let(:hostname) { 'my_host' }
|
140
|
+
|
141
|
+
it 'raises an error' do
|
142
|
+
expect { subject }.to raise_error
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
context 'starting with a dash' do
|
147
|
+
let(:hostname) { '-myhost' }
|
148
|
+
|
149
|
+
it 'raises an error' do
|
150
|
+
expect { subject }.to raise_error
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
context 'ending with a dash' do
|
155
|
+
let(:hostname) { 'myhost-' }
|
156
|
+
|
157
|
+
it 'raises an error' do
|
158
|
+
expect { subject }.to raise_error
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|