vagrant-vmware-esxi 1.5.1 → 2.0.1
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/README.md +98 -145
- data/example_box/Vagrantfile +61 -55
- data/example_box/Vagrantfile-multimachine +5 -5
- data/lib/vagrant-vmware-esxi/action/boot.rb +1 -1
- data/lib/vagrant-vmware-esxi/action/createvm.rb +157 -161
- data/lib/vagrant-vmware-esxi/action/destroy.rb +1 -1
- data/lib/vagrant-vmware-esxi/action/esxi_password.rb +6 -6
- data/lib/vagrant-vmware-esxi/action/halt.rb +1 -1
- data/lib/vagrant-vmware-esxi/action/package.rb +3 -3
- data/lib/vagrant-vmware-esxi/action/read_ssh_info.rb +1 -1
- data/lib/vagrant-vmware-esxi/action/read_state.rb +1 -1
- data/lib/vagrant-vmware-esxi/action/resume.rb +1 -1
- data/lib/vagrant-vmware-esxi/action/set_network_ip.rb +5 -5
- data/lib/vagrant-vmware-esxi/action/snapshot_delete.rb +1 -1
- data/lib/vagrant-vmware-esxi/action/snapshot_info.rb +1 -1
- data/lib/vagrant-vmware-esxi/action/snapshot_list.rb +1 -1
- data/lib/vagrant-vmware-esxi/action/snapshot_restore.rb +1 -1
- data/lib/vagrant-vmware-esxi/action/snapshot_save.rb +28 -3
- data/lib/vagrant-vmware-esxi/action/suspend.rb +1 -1
- data/lib/vagrant-vmware-esxi/config.rb +186 -57
- data/lib/vagrant-vmware-esxi/version.rb +1 -1
- data/vagrant-vmware-esxi.gemspec +1 -1
- metadata +2 -2
@@ -24,10 +24,10 @@ Vagrant.configure('2') do |config|
|
|
24
24
|
esxi.esxi_username = 'root'
|
25
25
|
esxi.esxi_password = 'file:'
|
26
26
|
#esxi.esxi_hostport = 22
|
27
|
-
#esxi.
|
28
|
-
#esxi.
|
29
|
-
#esxi.
|
30
|
-
#esxi.
|
31
|
-
#esxi.
|
27
|
+
#esxi.esxi_virtual_network = 'vmnet_example'
|
28
|
+
#esxi.esxi_disk_store = 'DS_001'
|
29
|
+
#esxi.esxi_resource_pool = '/Vagrant'
|
30
|
+
#esxi.guest_memsize = '2048'
|
31
|
+
#esxi.guest_numvcpus = '2'
|
32
32
|
end
|
33
33
|
end
|
@@ -37,7 +37,7 @@ module VagrantPlugins
|
|
37
37
|
Net::SSH.start(config.esxi_hostname, config.esxi_username,
|
38
38
|
password: $esxi_password,
|
39
39
|
port: config.esxi_hostport,
|
40
|
-
keys: config.
|
40
|
+
keys: config.local_private_keys,
|
41
41
|
timeout: 20,
|
42
42
|
number_of_password_prompts: 0,
|
43
43
|
non_interactive: true
|
@@ -31,25 +31,25 @@ module VagrantPlugins
|
|
31
31
|
return
|
32
32
|
end
|
33
33
|
|
34
|
-
# Set
|
34
|
+
# Set desired_guest_name
|
35
35
|
if !env[:machine].config.vm.hostname.nil?
|
36
36
|
# A hostname has been set, so use it.
|
37
|
-
|
38
|
-
elsif config.
|
37
|
+
desired_guest_name = env[:machine].config.vm.hostname.dup
|
38
|
+
elsif config.guest_name.nil?
|
39
39
|
# Nothing set, so generate our own
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
desired_guest_name = config.guest_name_prefix.strip
|
41
|
+
desired_guest_name << `hostname`.partition('.').first.strip
|
42
|
+
desired_guest_name << '-'
|
43
|
+
desired_guest_name << `whoami`.gsub!(/[^0-9A-Za-z]/, '').strip
|
44
|
+
desired_guest_name << '-'
|
45
45
|
base = File.basename machine.env.cwd.to_s
|
46
|
-
|
47
|
-
config.
|
46
|
+
desired_guest_name << base
|
47
|
+
config.guest_name = desired_guest_name
|
48
48
|
else
|
49
|
-
# A
|
50
|
-
|
49
|
+
# A guest_name has been set, so use it.
|
50
|
+
desired_guest_name = config.guest_name.strip
|
51
51
|
end
|
52
|
-
@logger.info("vagrant-vmware-esxi, createvm: config.
|
52
|
+
@logger.info("vagrant-vmware-esxi, createvm: config.guest_name: #{config.guest_name}")
|
53
53
|
|
54
54
|
#
|
55
55
|
# Source vmx / vmdk files
|
@@ -67,7 +67,7 @@ module VagrantPlugins
|
|
67
67
|
Net::SSH.start( config.esxi_hostname, config.esxi_username,
|
68
68
|
password: $esxi_password,
|
69
69
|
port: config.esxi_hostport,
|
70
|
-
keys: config.
|
70
|
+
keys: config.local_private_keys,
|
71
71
|
timeout: 20,
|
72
72
|
number_of_password_prompts: 0,
|
73
73
|
non_interactive: true
|
@@ -91,15 +91,15 @@ module VagrantPlugins
|
|
91
91
|
message: 'Unable to get list of Disk Stores:'
|
92
92
|
end
|
93
93
|
|
94
|
-
# Use least-used if
|
95
|
-
if config.
|
94
|
+
# Use least-used if esxi_disk_store is not set (or not found)
|
95
|
+
if config.esxi_disk_store.nil?
|
96
96
|
desired_ds = '--- Least Used ---'
|
97
97
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
98
98
|
message: 'WARNING : '\
|
99
|
-
"
|
99
|
+
"esxi_disk_store not set, using "\
|
100
100
|
"\"--- Least Used ---\"")
|
101
101
|
else
|
102
|
-
desired_ds = config.
|
102
|
+
desired_ds = config.esxi_disk_store.to_s
|
103
103
|
end
|
104
104
|
|
105
105
|
if availvolumes.include? desired_ds
|
@@ -109,10 +109,10 @@ module VagrantPlugins
|
|
109
109
|
end
|
110
110
|
|
111
111
|
if (@guestvm_dsname != desired_ds) &&
|
112
|
-
!config.
|
112
|
+
!config.esxi_disk_store.nil?
|
113
113
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
114
114
|
message: 'WARNING : '\
|
115
|
-
"Disk Store \"#{config.
|
115
|
+
"Disk Store \"#{config.esxi_disk_store}\" not "\
|
116
116
|
"found, using #{@guestvm_dsname}")
|
117
117
|
end
|
118
118
|
|
@@ -145,33 +145,28 @@ module VagrantPlugins
|
|
145
145
|
vm_network_index += 1
|
146
146
|
end
|
147
147
|
|
148
|
-
|
149
|
-
|
150
|
-
message: "virtual_network : #{config.virtual_network}")
|
151
|
-
end
|
152
|
-
|
153
|
-
# If there is more vm.network than virtual_network's configured
|
154
|
-
# I need to add more virtual_networks. Setting each to ---NotSet---
|
148
|
+
# If there is more vm.network than esxi_virtual_network's configured
|
149
|
+
# I need to add more esxi_virtual_networks. Setting each to ---NotSet---
|
155
150
|
# to give a warning below...
|
156
|
-
if vm_network_index >= config.
|
157
|
-
config.
|
158
|
-
config.
|
151
|
+
if vm_network_index >= config.esxi_virtual_network.count
|
152
|
+
config.esxi_virtual_network.count.upto(vm_network_index) do |index|
|
153
|
+
config.esxi_virtual_network << '--NotSet--'
|
159
154
|
end
|
160
155
|
end
|
161
156
|
|
162
|
-
# Go through each
|
157
|
+
# Go through each esxi_virtual_network and make sure it's good. If not
|
163
158
|
# display a WARNING that we are choosing the first found.
|
164
159
|
@guestvm_network = []
|
165
160
|
networkID = 0
|
166
|
-
for aVirtNet in Array(config.
|
167
|
-
if config.
|
168
|
-
config.
|
161
|
+
for aVirtNet in Array(config.esxi_virtual_network) do
|
162
|
+
if config.esxi_virtual_network == [''] ||
|
163
|
+
config.esxi_virtual_network[0] == '--NotSet--'
|
169
164
|
# First (and only ) interface is not configure or not set
|
170
165
|
@guestvm_network = [availnetworks.first]
|
171
|
-
config.
|
166
|
+
config.esxi_virtual_network = [availnetworks.first]
|
172
167
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
173
168
|
message: 'WARNING : '\
|
174
|
-
"
|
169
|
+
"esxi_virtual_network[#{networkID}] not "\
|
175
170
|
"set, using #{availnetworks.first}")
|
176
171
|
elsif availnetworks.include? aVirtNet
|
177
172
|
# Network interface is good
|
@@ -179,9 +174,9 @@ module VagrantPlugins
|
|
179
174
|
else
|
180
175
|
# Network interface is NOT good.
|
181
176
|
@guestvm_network[networkID] = availnetworks.first
|
182
|
-
config.
|
177
|
+
config.esxi_virtual_network[networkID] = availnetworks.first
|
183
178
|
if aVirtNet == '--NotSet--'
|
184
|
-
aVirtNet_msg = "
|
179
|
+
aVirtNet_msg = "esxi_virtual_network[#{networkID}]"
|
185
180
|
else
|
186
181
|
aVirtNet_msg = aVirtNet
|
187
182
|
end
|
@@ -198,15 +193,17 @@ module VagrantPlugins
|
|
198
193
|
end
|
199
194
|
|
200
195
|
@logger.info('vagrant-vmware-esxi, createvm: '\
|
201
|
-
"
|
196
|
+
"esxi_virtual_network: #{@guestvm_network}")
|
202
197
|
|
203
198
|
# finalize some paramaters
|
204
|
-
if (config.
|
205
|
-
|
206
|
-
end
|
207
|
-
if (config.
|
208
|
-
|
209
|
-
end
|
199
|
+
#if (config.guest_memsize.is_a? String) || (config.guest_memsize.is_a? Integer)
|
200
|
+
# desired_guest_memsize = config.guest_memsize.to_s.to_i
|
201
|
+
#end
|
202
|
+
#if (config.guest_numvcpus.is_a? String) || (config.guest_numvcpus.is_a? Integer)
|
203
|
+
# desired_guest_numvcpus = config.guest_numvcpus.to_s.to_i
|
204
|
+
#end
|
205
|
+
desired_guest_memsize = config.guest_memsize.to_s.to_i unless config.guest_memsize.nil?
|
206
|
+
desired_guest_numvcpus = config.guest_numvcpus.to_s.to_i unless config.guest_numvcpus.nil?
|
210
207
|
|
211
208
|
#
|
212
209
|
# Fix/clean up vmx file.
|
@@ -216,37 +213,39 @@ module VagrantPlugins
|
|
216
213
|
|
217
214
|
case line
|
218
215
|
when /^displayname =/i
|
219
|
-
new_vmx_contents << "displayname = \"#{
|
216
|
+
new_vmx_contents << "displayname = \"#{desired_guest_name}\"\n"
|
220
217
|
when /^memsize =/i
|
221
|
-
if
|
218
|
+
if desired_guest_memsize.nil?
|
222
219
|
new_vmx_contents << line
|
220
|
+
desired_guest_memsize = line.gsub(/^memsize = /i, '').gsub(/\"/, '').to_i
|
223
221
|
else
|
224
|
-
new_vmx_contents << "memsize = \"#{
|
222
|
+
new_vmx_contents << "memsize = \"#{desired_guest_memsize}\"\n"
|
225
223
|
end
|
226
224
|
when /^numvcpus =/i
|
227
|
-
if
|
225
|
+
if desired_guest_numvcpus.nil?
|
228
226
|
new_vmx_contents << line
|
227
|
+
desired_guest_numvcpus = line.gsub(/^numvcpus = /i, '').gsub(/\"/, '').to_i
|
229
228
|
else
|
230
|
-
new_vmx_contents << "numvcpus = \"#{
|
229
|
+
new_vmx_contents << "numvcpus = \"#{desired_guest_numvcpus}\"\n"
|
231
230
|
end
|
232
231
|
when /^ethernet[0-9]/i
|
233
232
|
# Do nothing, delete these lines, we'll fix it later.
|
234
233
|
when /^guestOS = /i
|
235
234
|
|
236
|
-
|
237
|
-
if config.
|
238
|
-
config.
|
235
|
+
in_vmx_guest_guestos = line.gsub(/^guestOS = /i, '').gsub(/\"/, '').strip
|
236
|
+
if config.guest_guestos.nil?
|
237
|
+
config.guest_guestos = in_vmx_guest_guestos
|
239
238
|
new_vmx_contents << line
|
240
239
|
else
|
241
|
-
if config.
|
242
|
-
config.
|
243
|
-
new_vmx_contents << "guestOS = \"#{config.
|
240
|
+
if config.supported_guest_guestos.include? config.guest_guestos.downcase
|
241
|
+
config.guest_guestos = config.guest_guestos.downcase.strip
|
242
|
+
new_vmx_contents << "guestOS = \"#{config.guest_guestos}\"\n"
|
244
243
|
else
|
245
244
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
246
245
|
message: 'WARNING : '\
|
247
|
-
"GuestOS: #{config.
|
246
|
+
"GuestOS: #{config.guest_guestos} not "\
|
248
247
|
"supported, using box/ovftool defaults")
|
249
|
-
config.
|
248
|
+
config.guest_guestos = in_vmx_guest_guestos
|
250
249
|
new_vmx_contents << line
|
251
250
|
end
|
252
251
|
end
|
@@ -258,10 +257,10 @@ module VagrantPlugins
|
|
258
257
|
|
259
258
|
# finalize vmx.
|
260
259
|
unless new_vmx_contents =~ %r{^numvcpus =}i
|
261
|
-
if
|
260
|
+
if desired_guest_numvcpus.nil?
|
262
261
|
new_vmx_contents << "numvcpus = \"1\"\n"
|
263
262
|
else
|
264
|
-
new_vmx_contents << "numvcpus = \"#{
|
263
|
+
new_vmx_contents << "numvcpus = \"#{desired_guest_numvcpus}\"\n"
|
265
264
|
end
|
266
265
|
end
|
267
266
|
|
@@ -286,7 +285,7 @@ module VagrantPlugins
|
|
286
285
|
# Write new vmx file on local filesystem
|
287
286
|
filename_only = File.basename vmx_file, '.vmx'
|
288
287
|
path_only = File.dirname vmx_file
|
289
|
-
new_vmx_file = "#{path_only}/ZZZZ_#{
|
288
|
+
new_vmx_file = "#{path_only}/ZZZZ_#{desired_guest_name}.vmx"
|
290
289
|
|
291
290
|
File.open(new_vmx_file, 'w') { |file|
|
292
291
|
file.write(new_vmx_contents)
|
@@ -297,97 +296,90 @@ module VagrantPlugins
|
|
297
296
|
# Do some validations, set defaults...
|
298
297
|
#
|
299
298
|
# Validate if using a Resource Pool
|
300
|
-
if config.
|
301
|
-
if config.
|
302
|
-
|
299
|
+
if config.esxi_resource_pool.is_a? String
|
300
|
+
if config.esxi_resource_pool =~ %r{^\/}
|
301
|
+
esxi_resource_pool = config.esxi_resource_pool
|
303
302
|
else
|
304
|
-
|
305
|
-
resource_pool << config.resource_pool
|
303
|
+
esxi_resource_pool = '/' + config.esxi_resource_pool
|
306
304
|
end
|
307
305
|
else
|
308
|
-
|
306
|
+
esxi_resource_pool = '/'
|
309
307
|
end
|
310
308
|
|
311
|
-
if (config.
|
312
|
-
(config.
|
309
|
+
if (config.local_allow_overwrite =~ %r{true}i) ||
|
310
|
+
(config.local_allow_overwrite =~ %r{yes}i)
|
313
311
|
overwrite_opts = '--overwrite --powerOffTarget'
|
314
312
|
else
|
315
313
|
overwrite_opts = nil
|
316
314
|
end
|
317
315
|
|
318
316
|
# Validate mac addresses
|
319
|
-
unless config.
|
320
|
-
|
317
|
+
unless config.guest_mac_address.nil?
|
318
|
+
new_guest_mac_address = []
|
321
319
|
0.upto(@guestvm_network.count - 1) do |index|
|
322
|
-
unless config.
|
323
|
-
|
324
|
-
if
|
325
|
-
|
326
|
-
elsif
|
327
|
-
|
320
|
+
unless config.guest_mac_address[index].nil?
|
321
|
+
guest_mac_address = config.guest_mac_address[index].gsub(/-/,':').downcase
|
322
|
+
if guest_mac_address =~ /^([0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$/i
|
323
|
+
new_guest_mac_address[index] = guest_mac_address
|
324
|
+
elsif guest_mac_address == ''
|
325
|
+
new_guest_mac_address[index] = ''
|
328
326
|
else
|
329
|
-
|
327
|
+
new_guest_mac_address[index] = "invalid"
|
330
328
|
end
|
331
329
|
end
|
332
330
|
end
|
333
|
-
config.
|
331
|
+
config.guest_mac_address = new_guest_mac_address
|
334
332
|
end
|
335
333
|
|
336
334
|
# Validate nic types
|
337
|
-
if config.
|
338
|
-
|
335
|
+
if config.guest_nic_type.nil?
|
336
|
+
guest_nic_type = nil
|
339
337
|
else
|
340
|
-
if config.
|
341
|
-
|
338
|
+
if config.supported_guest_nic_types.include?(config.guest_nic_type.downcase)
|
339
|
+
guest_nic_type = config.guest_nic_type.downcase
|
342
340
|
else
|
343
341
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
344
342
|
message: 'WARNING : '\
|
345
|
-
"NIC type: #{config.
|
343
|
+
"NIC type: #{config.guest_nic_type} not "\
|
346
344
|
"found, using ovftool defaults.")
|
347
|
-
|
345
|
+
guest_nic_type = nil
|
348
346
|
end
|
349
347
|
end
|
350
348
|
|
351
|
-
# Validate cpus and memory
|
352
|
-
numvcpus = new_vmx_contents.match(/^numvcpus =.*/i)
|
353
|
-
.to_s.gsub(/^numvcpus =/i, '').gsub(/\"/, '')
|
354
|
-
memsize = new_vmx_contents.match(/^memsize =.*/i)
|
355
|
-
.to_s.gsub(/^memsize =/i, '').gsub(/\"/, '')
|
356
|
-
|
357
349
|
# Validate disk types (thin, thick, etc...)
|
358
|
-
if config.
|
359
|
-
|
350
|
+
if config.guest_disk_type.nil?
|
351
|
+
guest_disk_type = "thin"
|
360
352
|
else
|
361
|
-
if config.
|
362
|
-
|
353
|
+
if config.supported_guest_disk_types.include? config.guest_disk_type.downcase
|
354
|
+
guest_disk_type = config.guest_disk_type.downcase
|
363
355
|
else
|
364
356
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
365
357
|
message: 'WARNING : '\
|
366
|
-
"Disk type: #{config.
|
358
|
+
"Disk type: #{config.guest_disk_type} not "\
|
367
359
|
"found, using \"thin\"")
|
368
|
-
|
360
|
+
guest_disk_type = "thin"
|
369
361
|
end
|
370
362
|
end
|
371
363
|
|
372
364
|
# Validate virtual HW levels
|
373
|
-
unless config.
|
374
|
-
if config.
|
375
|
-
|
365
|
+
unless config.guest_virtualhw_version.nil?
|
366
|
+
if config.supported_guest_virtualhw_versions.include? config.guest_virtualhw_version.to_i
|
367
|
+
guest_virtualhw_version = config.guest_virtualhw_version.to_i.to_s
|
376
368
|
else
|
377
369
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
378
370
|
message: 'WARNING : '\
|
379
|
-
"Invalid
|
371
|
+
"Invalid guest_virtualhw_version: #{config.guest_virtualhw_version},"\
|
380
372
|
" using ovftool defaults")
|
381
|
-
|
373
|
+
guest_virtualhw_version = nil
|
382
374
|
end
|
383
375
|
end
|
384
376
|
|
385
|
-
# Validate
|
386
|
-
unless config.
|
387
|
-
if config.
|
388
|
-
|
377
|
+
# Validate local_lax setting (use relaxed (--lax) ovftool option)
|
378
|
+
unless config.local_lax.nil?
|
379
|
+
if config.local_lax == 'True'
|
380
|
+
local_laxoption = '--lax'
|
389
381
|
else
|
390
|
-
|
382
|
+
local_laxoption = ''
|
391
383
|
end
|
392
384
|
end
|
393
385
|
|
@@ -396,51 +388,55 @@ module VagrantPlugins
|
|
396
388
|
# Print summary
|
397
389
|
#
|
398
390
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
399
|
-
message: "")
|
391
|
+
message: " --- ESXi Summary ---")
|
400
392
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
401
393
|
message: "ESXi host : #{config.esxi_hostname}")
|
402
394
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
403
|
-
|
395
|
+
message: "Virtual Network : #{@guestvm_network[0..3]}")
|
396
|
+
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
397
|
+
message: "Disk Store : #{@guestvm_dsname}")
|
398
|
+
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
399
|
+
message: "Resource Pool : #{esxi_resource_pool}")
|
400
|
+
#
|
401
|
+
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
402
|
+
message: " --- Guest Summary ---")
|
403
|
+
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
404
|
+
message: "VM Name : #{desired_guest_name}")
|
404
405
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
405
406
|
message: "Box : #{env[:machine].box.name}")
|
406
407
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
407
408
|
message: "Box Ver : #{env[:machine].box.version}")
|
408
409
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
409
|
-
message: "
|
410
|
-
|
410
|
+
message: "Memsize (MB) : #{desired_guest_memsize}")
|
411
|
+
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
412
|
+
message: "CPUS : #{desired_guest_numvcpus}")
|
413
|
+
unless config.guest_mac_address[0].eql? ''
|
411
414
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
412
|
-
message: "
|
415
|
+
message: "Mac Address : #{config.guest_mac_address}")
|
413
416
|
end
|
414
|
-
|
415
|
-
message: "CPUS :#{numvcpus}")
|
416
|
-
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
417
|
-
message: "Memsize (MB) :#{memsize}")
|
418
|
-
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
419
|
-
message: "Guest OS type : #{config.guestos}")
|
420
|
-
unless config.vm_disk_type.nil?
|
417
|
+
unless guest_nic_type.nil?
|
421
418
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
422
|
-
message: "
|
419
|
+
message: "Nic Type : #{guest_nic_type}")
|
423
420
|
end
|
424
|
-
|
425
|
-
message: "Virtual Network : #{@guestvm_network[0..3]}")
|
426
|
-
unless config.mac_address[0].eql? ''
|
421
|
+
unless config.guest_disk_type.nil?
|
427
422
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
428
|
-
message: "
|
423
|
+
message: "Disk Type : #{guest_disk_type}")
|
429
424
|
end
|
430
|
-
|
425
|
+
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
426
|
+
message: "Guest OS type : #{config.guest_guestos}")
|
427
|
+
unless guest_virtualhw_version.nil?
|
431
428
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
432
|
-
message: "
|
429
|
+
message: "Virtual HW ver : #{guest_virtualhw_version}")
|
433
430
|
end
|
434
|
-
if config.
|
431
|
+
if config.local_lax == 'True'
|
435
432
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
436
|
-
message: "Relaxed (--lax) : #{config.
|
433
|
+
message: "Relaxed (--lax) : #{config.local_lax}")
|
437
434
|
end
|
438
435
|
unless overwrite_opts.nil?
|
439
436
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
440
437
|
message: 'Allow Overwrite : True')
|
441
438
|
end
|
442
|
-
|
443
|
-
message: "Resource Pool : #{resource_pool}")
|
439
|
+
|
444
440
|
|
445
441
|
#
|
446
442
|
# Using ovftool, import vmx in box folder, export to ESXi server
|
@@ -452,11 +448,11 @@ module VagrantPlugins
|
|
452
448
|
' install from http://www.vmware.com.'
|
453
449
|
end
|
454
450
|
ovf_cmd = "ovftool --noSSLVerify #{overwrite_opts} "\
|
455
|
-
"#{netOpts} -dm=#{
|
456
|
-
"-ds=\"#{@guestvm_dsname}\" --name=\"#{
|
451
|
+
"#{netOpts} -dm=#{guest_disk_type} #{local_laxoption} "\
|
452
|
+
"-ds=\"#{@guestvm_dsname}\" --name=\"#{desired_guest_name}\" "\
|
457
453
|
"\"#{new_vmx_file}\" vi://#{config.esxi_username}:"\
|
458
454
|
"#{$encoded_esxi_password}@#{config.esxi_hostname}"\
|
459
|
-
"#{
|
455
|
+
"#{esxi_resource_pool}"
|
460
456
|
|
461
457
|
#
|
462
458
|
# Security alert! If password debugging is enabled, Password will
|
@@ -486,18 +482,18 @@ module VagrantPlugins
|
|
486
482
|
Net::SSH.start(config.esxi_hostname, config.esxi_username,
|
487
483
|
password: $esxi_password,
|
488
484
|
port: config.esxi_hostport,
|
489
|
-
keys: config.
|
485
|
+
keys: config.local_private_keys,
|
490
486
|
timeout: 20,
|
491
487
|
number_of_password_prompts: 0,
|
492
488
|
non_interactive: true
|
493
489
|
) do |ssh|
|
494
490
|
r = ssh.exec!(
|
495
491
|
'vim-cmd vmsvc/getallvms |'\
|
496
|
-
"grep \" #{
|
492
|
+
"grep \" #{desired_guest_name} \"|awk '{print $1}'")
|
497
493
|
vmid = r
|
498
494
|
if (vmid == '') || (r.exitstatus != 0)
|
499
495
|
raise Errors::ESXiError,
|
500
|
-
message: "Unable to register #{
|
496
|
+
message: "Unable to register #{desired_guest_name}"
|
501
497
|
end
|
502
498
|
|
503
499
|
env[:machine].id = vmid.to_i
|
@@ -537,18 +533,18 @@ module VagrantPlugins
|
|
537
533
|
|
538
534
|
# configure virtualHW ver
|
539
535
|
when /^virtualHW.version = /i
|
540
|
-
if
|
536
|
+
if guest_virtualhw_version.nil?
|
541
537
|
new_vmx_contents << line
|
542
538
|
else
|
543
|
-
new_vmx_contents << "virtualHW.version = \"#{
|
539
|
+
new_vmx_contents << "virtualHW.version = \"#{guest_virtualhw_version}\"\n"
|
544
540
|
vmx_need_change_flag = true
|
545
541
|
end
|
546
542
|
|
547
543
|
when /^guestOS = /i
|
548
|
-
if config.
|
544
|
+
if config.guest_guestos.nil?
|
549
545
|
new_vmx_contents << line
|
550
546
|
else
|
551
|
-
new_vmx_contents << "guestOS = \"#{config.
|
547
|
+
new_vmx_contents << "guestOS = \"#{config.guest_guestos}\"\n"
|
552
548
|
vmx_need_change_flag = true
|
553
549
|
end
|
554
550
|
|
@@ -558,24 +554,24 @@ module VagrantPlugins
|
|
558
554
|
if line.match(/^ethernet[0-9].networkName = /i)
|
559
555
|
new_vmx_contents << line
|
560
556
|
elsif line.match(/^ethernet0.virtualDev = /i)
|
561
|
-
# Update
|
557
|
+
# Update guest_nic_type if it's set, otherwise, save eth0 guest_nic_type
|
562
558
|
# for the remaining nics. (ovftool doesn't set it...)
|
563
|
-
if
|
564
|
-
|
559
|
+
if guest_nic_type.nil?
|
560
|
+
guest_nic_type = line.gsub(/ethernet0.virtualDev = /i, '').gsub('"', '').strip
|
565
561
|
new_vmx_contents << line
|
566
562
|
else
|
567
|
-
new_vmx_contents << line.gsub(/ = .*$/, " = \"#{
|
563
|
+
new_vmx_contents << line.gsub(/ = .*$/, " = \"#{guest_nic_type}\"\n")
|
568
564
|
vmx_need_change_flag = true
|
569
565
|
end
|
570
566
|
elsif (line.match(/^ethernet[0-9].addressType = /i) &&
|
571
|
-
!config.
|
567
|
+
!config.guest_mac_address[nicindex].nil?)
|
572
568
|
# Update MAC address if it's set
|
573
|
-
|
574
|
-
if
|
569
|
+
guest_mac_address = config.guest_mac_address[nicindex]
|
570
|
+
if guest_mac_address =~ /^([0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$/i
|
575
571
|
new_vmx_contents << line.gsub(/ = .*$/, " = \"static\"")
|
576
|
-
new_vmx_contents << line.gsub(/Type = .*$/, " = \"#{
|
572
|
+
new_vmx_contents << line.gsub(/Type = .*$/, " = \"#{guest_mac_address}\"")
|
577
573
|
vmx_need_change_flag = true
|
578
|
-
elsif
|
574
|
+
elsif guest_mac_address == ''
|
579
575
|
new_vmx_contents << line
|
580
576
|
else
|
581
577
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
@@ -585,8 +581,8 @@ module VagrantPlugins
|
|
585
581
|
end
|
586
582
|
else
|
587
583
|
line_changed = false
|
588
|
-
if config.
|
589
|
-
env[:machine].provider_config.
|
584
|
+
if config.guest_custom_vmx_settings.is_a? Array
|
585
|
+
env[:machine].provider_config.guest_custom_vmx_settings.each do |k, v|
|
590
586
|
if line =~ /#{k} = /
|
591
587
|
new_vmx_contents << "#{k} = \"#{v}\"\n"
|
592
588
|
vmx_need_change_flag = true
|
@@ -602,20 +598,20 @@ module VagrantPlugins
|
|
602
598
|
end
|
603
599
|
end
|
604
600
|
|
605
|
-
# For all nics, configure
|
606
|
-
if
|
607
|
-
|
601
|
+
# For all nics, configure guest_nic_type and enable nics
|
602
|
+
if guest_nic_type.nil?
|
603
|
+
guest_nic_type = "e1000"
|
608
604
|
end
|
609
|
-
if config.
|
610
|
-
number_of_adapters = config.
|
605
|
+
if config.esxi_virtual_network.is_a? Array
|
606
|
+
number_of_adapters = config.esxi_virtual_network.count
|
611
607
|
else
|
612
608
|
number_of_adapters = 1
|
613
609
|
end
|
614
610
|
|
615
611
|
1.upto(number_of_adapters) do |index|
|
616
612
|
nic_index = index - 1
|
617
|
-
unless new_vmx_contents =~ /ethernet#{nic_index}.virtualDev = \"#{
|
618
|
-
new_vmx_contents << "ethernet#{nic_index}.virtualDev = \"#{
|
613
|
+
unless new_vmx_contents =~ /ethernet#{nic_index}.virtualDev = \"#{guest_nic_type}\"/i
|
614
|
+
new_vmx_contents << "ethernet#{nic_index}.virtualDev = \"#{guest_nic_type}\"\n"
|
619
615
|
vmx_need_change_flag = true
|
620
616
|
end
|
621
617
|
unless new_vmx_contents =~ /ethernet#{nic_index}.present = \"TRUE\"/i
|
@@ -624,9 +620,9 @@ module VagrantPlugins
|
|
624
620
|
end
|
625
621
|
end
|
626
622
|
|
627
|
-
# append
|
628
|
-
if config.
|
629
|
-
env[:machine].provider_config.
|
623
|
+
# append guest_custom_vmx_settings if not yet in vmx
|
624
|
+
if config.guest_custom_vmx_settings.is_a? Array
|
625
|
+
env[:machine].provider_config.guest_custom_vmx_settings.each do |k, v|
|
630
626
|
unless new_vmx_contents =~ /#{k} = /
|
631
627
|
new_vmx_contents << "#{k} = \"#{v}\"\n"
|
632
628
|
vmx_need_change_flag = true
|