vagrant-vmware-esxi 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '097f1326323d37d401b5243a7bc5287f8310ba62'
4
- data.tar.gz: 8790e1347a0576d9f5f14deb698dc91de89f576e
3
+ metadata.gz: c220b80d1a181ae3dbe1ba7364a28813ef287021
4
+ data.tar.gz: 1372acaada64754b4ce0f69579ebb86cff807934
5
5
  SHA512:
6
- metadata.gz: 7651298f91f3cbc1c301b416ef7ea88f9f40d23f7fd8ad23b65304fbff3978f6d3b8c97406f6cfef5c9182f525512f2f93f67c632ed04b6187cd71ae5d1e8a5a
7
- data.tar.gz: 07bc3b59e29a6cf450be897ff1e1468cfdcc64edcba5ed3a8d77aa94bbd4d8d1bacf41bfa007cb00a938330914ccf00c96d58dd6b6fef33879080a00e32f540c
6
+ metadata.gz: aa6a785b4292394dc0df368d42c7134666b7f546811c8c1fbd35d9bfd7d7ab679f1cce0d762975589f218fdf98e11ee22dd2346dc87115628aac7a91de7e2a04
7
+ data.tar.gz: 549ee440d9442a31363ae3ce87e33be7d164c857b6bdeae07627ef8935a6f05a40a9e695fa24c61f376e6f629684bba14ab9baeb00bd8633ec4716788bd9189e
data/README.md CHANGED
@@ -8,7 +8,7 @@ Features and Compatibility
8
8
  --------------------------
9
9
  * Any of the vmware Box formats should be compatible.
10
10
  * vmware_desktop, vmware_fusion, vmware_workstation...
11
- * To be fully functional, you must have open-vm-tools or vmware tools installed
11
+ * To be fully functional, you must have open-vm-tools or vmware tools installed.
12
12
  * Will automatically download boxes from the web.
13
13
  * Will automatically upload the box to your ESXi host.
14
14
  * Automatic or manual VM names.
@@ -20,8 +20,10 @@ Features and Compatibility
20
20
  * rsync & NFS using built-in Vagrant synced folders.
21
21
  * Provision using built-in Vagrant provisioner.
22
22
  * package your vm's into boxes.
23
- * Set MAC addresses on network interfaces.
23
+ * Create additional network interfaces, set nic type, MAC addresses, static IPs.
24
24
  * Use Vagrants Set IP addresses on network interfaces feature. (private_network, public_network)
25
+ * Disks provisioned using thin, thick or eagerzeroedthick.
26
+ * Specify GuestOS types, virtual HW version, or any custom vmx settings.
25
27
 
26
28
  Requirements
27
29
  ------------
@@ -149,13 +151,6 @@ Vagrant.configure("2") do |config|
149
151
  # IMPORTANT! Set the ESXi password or authentication method..
150
152
  esxi.esxi_password = "prompt:"
151
153
 
152
- # ESXi ssh keys. (This is depreciated!!!)
153
- # The Default is to use system default ssh keys, However
154
- # you can specify an array of keys here...
155
- #
156
- # *** Depreciated, use esxi_password = "key:" instead. ***
157
- #esxi.esxi_private_keys = []
158
-
159
154
  # SSH port.
160
155
  # Default port 22.
161
156
  #esxi.esxi_hostport = 22
@@ -196,6 +191,11 @@ Vagrant.configure("2") do |config|
196
191
  # If it's not specified, the Default is to use the least used Disk Store.
197
192
  #esxi.vm_disk_store = "DS_001"
198
193
 
194
+ # OPTIONAL. Specify a disk type.
195
+ # If unspecified, it will be set to "thin", Otherwise, you can set to:
196
+ # 'thin', 'thick', or 'eagerzeroedthick'
197
+ #esxo.vm_disk_type = "thick"
198
+
199
199
  # OPTIONAL. Guest VM name to use.
200
200
  # The Default will be automatically generated. It will be based on
201
201
  # the vmname_prefix (see below), your hostname & username and path.
@@ -225,6 +225,36 @@ Vagrant.configure("2") do |config|
225
225
  # Vagrant will NOT create a Resource pool it for you.
226
226
  #esxi.resource_pool = "/Vagrant"
227
227
 
228
+ # RISKY. guestos
229
+ # if unspecified, the default will be generated by the OVFTool. Most
230
+ # of the time, you don't need to change this unless ovftool doesn't get
231
+ # the correct information from the box. See my page on supported guestos
232
+ # types for ESXI.
233
+ # https://github.com/josenk/vagrant-vmware-esxi/ESXi_guestos_types.md
234
+ #esxi.guestos = "centos7-64"
235
+
236
+ # OPTIONAL. virtualhw_version
237
+ # If unspecified, the default will be generated by the OVFTool. Most
238
+ # of the time, you don't need to change this unless you are using advanced
239
+ # custom vmx settings that require it.
240
+ # ESXi 6.5 supports these versions. 4,7,8,9,10,11,12 & 13.
241
+ #esxi.virtualhw_version = '11'
242
+
243
+ # RISKY. custom_vmx_settings
244
+ # You can specify an array of custom vmx settings to add (or to override
245
+ # existing settings). **** I don't do any validation, so if you
246
+ # make any errors, it will not be caught *** This is the place you would
247
+ # add any special settings you need in your vmx. (Like adding a USB, DVD
248
+ # CPU settings, etc...).
249
+ # ex vhv.enable = 'TRUE' will be appended, floppy0.presend = 'TRUE' will be modified
250
+ #esxi.custom_vmx_settings = [['vhv.enable','TRUE'], ['floppy0.present','TRUE']]
251
+
252
+ # OPTIONAL. lax
253
+ # If unspecified, the ovftool option --lax is disabled. If you are
254
+ # importing ovf boxes that generate errors, you may want to enable lax
255
+ # to convert the errors to warning. (then the import could succeed)
256
+ #esxi.lax = 'true'
257
+
228
258
  # DANGEROUS! Allow Overwrite
229
259
  # If unspecified, the default is to produce an error if overwriting
230
260
  # vm's and packages.
@@ -259,7 +289,7 @@ Basic usage
259
289
  Known issues with vmware_esxi
260
290
  -----------------------------
261
291
  * The boxes must have open-vm-tools or vmware-tools installed to properly transition to the "running" state.
262
- * Invalid settings (bad IP address, netmask, MAC address) could cause 'vagrant up' to fail. Review your ESXi logs to help debug why it failed.
292
+ * Invalid settings (bad IP address, netmask, MAC address, custom_vmx_settings) could cause 'vagrant up' to fail. Review your ESXi logs to help debug why it failed.
263
293
  * Cleanup doesn't always destroy a VM that has been partially built. Use the allow_overwrite = 'True' option if you need to force a rebuild, or delete the vm using the VSphere client.
264
294
  * ovftool installer for windows doesn't put ovftool.exe in your path. You can manually set your path, or install ovftool in the \HashiCorp\Vagrant\bin directory.
265
295
  * In general I find NFS synced folders a little "flaky"...
@@ -267,6 +297,13 @@ Known issues with vmware_esxi
267
297
 
268
298
  Version History
269
299
  ---------------
300
+ * 1.5.0 Add support for:
301
+ Specify custom_vmx_settings (to add or modify vmx settings).
302
+ Specify Virtual HW version.
303
+ Allow $ in Password.
304
+ Disk types (thick, thin, eagerzeroedthick).
305
+ Specify a guestOS type (see list above).
306
+ Relaxed ovftool setting (--lax), to allow importing strange ovf boxes.
270
307
  * 1.4.0 Add support to set MAC and IP addresses for network interfaces.
271
308
  * 1.3.2 Fix, Don't timeout ssh connection when ovftool takes a long time to upload image.
272
309
  * 1.3.0 Add support to get esxi password from env, from a file or prompt.
@@ -95,13 +95,6 @@ Vagrant.configure("2") do |config|
95
95
  # IMPORTANT! Set the ESXi password or authentication method..
96
96
  esxi.esxi_password = "prompt:"
97
97
 
98
- # ESXi ssh keys. (This is depreciated!!!)
99
- # The Default is to use system default ssh keys, However
100
- # you can specify an array of keys here...
101
- #
102
- # *** Depreciated, use esxi_password = "key:" instead. ***
103
- #esxi.esxi_private_keys = []
104
-
105
98
  # SSH port.
106
99
  # Default port 22.
107
100
  #esxi.esxi_hostport = 22
@@ -171,6 +164,36 @@ Vagrant.configure("2") do |config|
171
164
  # Vagrant will NOT create a Resource pool it for you.
172
165
  #esxi.resource_pool = "/Vagrant"
173
166
 
167
+ # RISKY. guestos
168
+ # if unspecified, the default will be generated by the OVFTool. Most
169
+ # of the time, you don't need to change this unless ovftool doesn't get
170
+ # the correct information from the box. See my page on supported guestos
171
+ # types for ESXI.
172
+ # https://github.com/josenk/vagrant-vmware-esxi/ESXi_guestos_types.md
173
+ #esxi.guestos = "centos7-64"
174
+
175
+ # OPTIONAL. virtualhw_version
176
+ # If unspecified, the default will be generated by the OVFTool. Most
177
+ # of the time, you don't need to change this unless you are using advanced
178
+ # custom vmx settings that require it.
179
+ # ESXi 6.5 supports these versions. 4,7,8,9,10,11,12 & 13.
180
+ #esxi.virtualhw_version = '11'
181
+
182
+ # RISKY. custom_vmx_settings
183
+ # You can specify an array of custom vmx settings to add (or to override
184
+ # existing settings). **** I don't do any validation, so if you
185
+ # make any errors, it will not be caught *** This is the place you would
186
+ # add any special settings you need in your vmx. (Like adding a USB, DVD
187
+ # CPU settings, etc...).
188
+ # ex vhv.enable = 'TRUE' will be appended, floppy0.presend = 'TRUE' will be modified
189
+ #esxi.custom_vmx_settings = [['vhv.enable','TRUE'], ['floppy0.present','TRUE']]
190
+
191
+ # OPTIONAL. lax
192
+ # If unspecified, the ovftool option --lax is disabled. If you are
193
+ # importing ovf boxes that generate errors, you may want to enable lax
194
+ # to convert the errors to warning. (then the import could succeed)
195
+ #esxi.lax = 'true'
196
+
174
197
  # DANGEROUS! Allow Overwrite
175
198
  # If unspecified, the default is to produce an error if overwriting
176
199
  # vm's and packages.
@@ -107,7 +107,7 @@ module VagrantPlugins
107
107
  !config.vm_disk_store.nil?
108
108
  env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
109
109
  message: 'WARNING : '\
110
- "#{config.vm_disk_store} not "\
110
+ "Disk Store \"#{config.vm_disk_store}\" not "\
111
111
  "found, using #{@guestvm_dsname}")
112
112
  end
113
113
 
@@ -176,22 +176,46 @@ module VagrantPlugins
176
176
  new_vmx_contents = ''
177
177
  File.readlines(vmx_file).each do |line|
178
178
 
179
- if line.match(/^displayname =/i)
179
+ case line
180
+ when /^displayname =/i
180
181
  new_vmx_contents << "displayname = \"#{guestvm_vmname}\"\n"
181
- elsif line.match(/^memsize =/i) && (!desired_memsize.nil?)
182
- new_vmx_contents << "memsize = \"#{desired_memsize}\"\n"
183
- elsif line.match(/^numvcpus =/i) && (!desired_numvcpus.nil?)
184
- new_vmx_contents << "numvcpus = \"#{desired_numvcpus}\"\n"
185
- elsif line.match(/^ethernet[0-9].networkName =/i) ||
186
- line.match(/^ethernet[0-9].addressType =/i) ||
187
- line.match(/^ethernet[0-9].present =/i) ||
188
- line.match(/^ethernet[0-9].address =/i) ||
189
- line.match(/^ethernet[0-9].generatedAddress =/i) ||
190
- line.match(/^ethernet[0-9].generatedAddressOffset =/i)
191
- # Do nothing, delete these lines
182
+ when /^memsize =/i
183
+ if desired_memsize.nil?
184
+ new_vmx_contents << line
185
+ else
186
+ new_vmx_contents << "memsize = \"#{desired_memsize}\"\n"
187
+ end
188
+ when /^numvcpus =/i
189
+ if desired_numvcpus.nil?
190
+ new_vmx_contents << line
191
+ else
192
+ new_vmx_contents << "numvcpus = \"#{desired_numvcpus}\"\n"
193
+ end
194
+ when /^ethernet[0-9]/i
195
+ # Do nothing, delete these lines, we'll fix it later.
196
+ when /^guestOS = /i
197
+
198
+ in_vmx_guestos = line.gsub(/^guestOS = /i, '').gsub(/\"/, '').strip
199
+ if config.guestos.nil?
200
+ config.guestos = in_vmx_guestos
201
+ new_vmx_contents << line
202
+ else
203
+ if config.supported_guestos.include? config.guestos.downcase
204
+ config.guestos = config.guestos.downcase.strip
205
+ new_vmx_contents << "guestOS = \"#{config.guestos}\"\n"
206
+ else
207
+ env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
208
+ message: 'WARNING : '\
209
+ "GuestOS: #{config.guestos} not "\
210
+ "supported, using box/ovftool defaults")
211
+ config.guestos = in_vmx_guestos
212
+ new_vmx_contents << line
213
+ end
214
+ end
192
215
  else
193
216
  new_vmx_contents << line
194
217
  end
218
+
195
219
  end
196
220
 
197
221
  # finalize vmx.
@@ -220,7 +244,7 @@ module VagrantPlugins
220
244
  end
221
245
  end
222
246
 
223
- # Write new vmx file
247
+ # Write new vmx file on local filesystem
224
248
  filename_only = File.basename vmx_file, '.vmx'
225
249
  path_only = File.dirname vmx_file
226
250
  new_vmx_file = "#{path_only}/ZZZZ_#{guestvm_vmname}.vmx"
@@ -231,7 +255,9 @@ module VagrantPlugins
231
255
  }
232
256
 
233
257
  #
234
- # Check if using a Resource Pool
258
+ # Do some validations, set defaults...
259
+ #
260
+ # Validate if using a Resource Pool
235
261
  if config.resource_pool.is_a? String
236
262
  if config.resource_pool =~ %r{^\/}
237
263
  resource_pool = config.resource_pool
@@ -269,35 +295,69 @@ module VagrantPlugins
269
295
  end
270
296
 
271
297
  # Validate nic types
272
- unless config.nic_type.nil?
273
- if config.nic_type =~ /Vlance/i
274
- config.nic_type = 'Vlance'
275
- elsif config.nic_type =~ /Flexible/i
276
- config.nic_type = 'Flexible'
277
- elsif config.nic_type =~ /e1000$/i
278
- config.nic_type = 'e1000'
279
- elsif config.nic_type =~ /e1000e$/i
280
- config.nic_type = 'e1000e'
281
- elsif config.nic_type =~ /vmxnet$/i
282
- config.nic_type = 'vmxnet'
283
- elsif config.nic_type =~ /vmxnet2$/i
284
- config.nic_type = 'vmxnet2'
285
- elsif config.nic_type =~ /vmxnet3$/i
286
- config.nic_type = 'vmxnet3'
298
+ if config.nic_type.nil?
299
+ nic_type = nil
300
+ else
301
+ if config.supported_nic_types.include?(config.nic_type.downcase)
302
+ nic_type = config.nic_type.downcase
287
303
  else
288
- config.nic_type = 'e1000'
304
+ env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
305
+ message: 'WARNING : '\
306
+ "NIC type: #{config.nic_type} not "\
307
+ "found, using ovftool defaults.")
308
+ nic_type = nil
289
309
  end
290
310
  end
291
311
 
292
-
293
- #
294
- # Display build summary
312
+ # Validate cpus and memory
295
313
  numvcpus = new_vmx_contents.match(/^numvcpus =.*/i)
296
314
  .to_s.gsub(/^numvcpus =/i, '').gsub(/\"/, '')
297
315
  memsize = new_vmx_contents.match(/^memsize =.*/i)
298
316
  .to_s.gsub(/^memsize =/i, '').gsub(/\"/, '')
299
- guestOS = new_vmx_contents.match(/^guestOS =.*/i)
300
- .to_s.gsub(/^guestOS =/i, '').gsub(/\"/, '')
317
+
318
+ # Validate disk types (thin, thick, etc...)
319
+ if config.vm_disk_type.nil?
320
+ vm_disk_type = "thin"
321
+ else
322
+ if config.supported_vm_disk_types.include? config.vm_disk_type.downcase
323
+ vm_disk_type = config.vm_disk_type.downcase
324
+ else
325
+ env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
326
+ message: 'WARNING : '\
327
+ "Disk type: #{config.vm_disk_type} not "\
328
+ "found, using \"thin\"")
329
+ vm_disk_type = "thin"
330
+ end
331
+ end
332
+
333
+ # Validate virtual HW levels
334
+ unless config.virtualhw_version.nil?
335
+ if config.supported_virtualhw_versions.include? config.virtualhw_version.to_i
336
+ virtualhw_version = config.virtualhw_version.to_i.to_s
337
+ else
338
+ env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
339
+ message: 'WARNING : '\
340
+ "Invalid virtualhw_version: #{config.virtualhw_version},"\
341
+ " using ovftool defaults")
342
+ virtualhw_version = nil
343
+ end
344
+ end
345
+
346
+ # Validate lax setting (use relaxed (--lax) ovftool option)
347
+ unless config.lax.nil?
348
+ if config.lax == 'True'
349
+ laxoption = '--lax'
350
+ else
351
+ laxoption = ''
352
+ end
353
+ end
354
+
355
+
356
+ #
357
+ # Print summary
358
+ #
359
+ env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
360
+ message: "")
301
361
  env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
302
362
  message: "ESXi host : #{config.esxi_hostname}")
303
363
  env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
@@ -306,23 +366,35 @@ module VagrantPlugins
306
366
  message: "Box : #{env[:machine].box.name}")
307
367
  env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
308
368
  message: "Box Ver : #{env[:machine].box.version}")
369
+ env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
370
+ message: "Disk Store : #{@guestvm_dsname}")
371
+ unless virtualhw_version.nil?
372
+ env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
373
+ message: "Virtual HW ver : #{virtualhw_version}")
374
+ end
309
375
  env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
310
376
  message: "CPUS :#{numvcpus}")
311
377
  env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
312
378
  message: "Memsize (MB) :#{memsize}")
313
379
  env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
314
- message: "Guest OS type :#{guestOS}")
315
- env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
316
- message: "Disk Store : #{@guestvm_dsname}")
380
+ message: "Guest OS type : #{config.guestos}")
381
+ unless config.vm_disk_type.nil?
382
+ env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
383
+ message: "Disk Type : #{vm_disk_type}")
384
+ end
317
385
  env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
318
386
  message: "Virtual Network : #{@guestvm_network[0..3]}")
319
387
  unless config.mac_address[0].eql? ''
320
388
  env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
321
389
  message: "Mac Address : #{config.mac_address}")
322
390
  end
323
- unless config.nic_type.nil?
391
+ unless nic_type.nil?
392
+ env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
393
+ message: "Nic Type : #{nic_type}")
394
+ end
395
+ if config.lax == 'True'
324
396
  env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
325
- message: "Nic Type : #{config.nic_type}")
397
+ message: "Relaxed (--lax) : #{config.lax}")
326
398
  end
327
399
  unless overwrite_opts.nil?
328
400
  env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
@@ -341,7 +413,7 @@ module VagrantPlugins
341
413
  ' install from http://www.vmware.com.'
342
414
  end
343
415
  ovf_cmd = "ovftool --noSSLVerify #{overwrite_opts} "\
344
- "#{netOpts} -dm=thin "\
416
+ "#{netOpts} -dm=#{vm_disk_type} #{laxoption} "\
345
417
  "-ds=\"#{@guestvm_dsname}\" --name=\"#{guestvm_vmname}\" "\
346
418
  "\"#{new_vmx_file}\" vi://#{config.esxi_username}:"\
347
419
  "#{$encoded_esxi_password}@#{config.esxi_hostname}"\
@@ -408,28 +480,50 @@ module VagrantPlugins
408
480
  esxi_orig_vmx_file = ssh.exec!("cat #{dst_vmx_file} 2>/dev/null")
409
481
  if (config.debug =~ %r{vmx}i)
410
482
  puts "orig vmx: #{esxi_orig_vmx_file}"
483
+ puts "\n\n"
411
484
  end
412
485
  if esxi_orig_vmx_file.exitstatus != 0
413
486
  raise Errors::ESXiError,
414
487
  message: "Unable to read #{dst_vmx_file}"
415
488
  end
416
489
 
417
- # read each line in vmx to configure mac and nic type.
490
+ # read each line in vmx to customize
418
491
  new_vmx_contents = ''
419
492
  vmx_need_change_flag = false
420
493
  esxi_orig_vmx_file.each_line do |line|
421
- if line.match(/^ethernet[0-9]/i)
494
+
495
+ case line
496
+
497
+ # configure virtualHW ver
498
+ when /^virtualHW.version = /i
499
+ if virtualhw_version.nil?
500
+ new_vmx_contents << line
501
+ else
502
+ new_vmx_contents << "virtualHW.version = \"#{virtualhw_version}\"\n"
503
+ vmx_need_change_flag = true
504
+ end
505
+
506
+ when /^guestOS = /i
507
+ if config.guestos.nil?
508
+ new_vmx_contents << line
509
+ else
510
+ new_vmx_contents << "guestOS = \"#{config.guestos}\"\n"
511
+ vmx_need_change_flag = true
512
+ end
513
+
514
+ # configure mac and nic type.
515
+ when /^ethernet[0-9]/i
422
516
  nicindex = line[8].to_i
423
517
  if line.match(/^ethernet[0-9].networkName = /i)
424
518
  new_vmx_contents << line
425
519
  elsif line.match(/^ethernet0.virtualDev = /i)
426
520
  # Update nic_type if it's set, otherwise, save eth0 nic_type
427
521
  # for the remaining nics. (ovftool doesn't set it...)
428
- if config.nic_type.nil?
429
- config.nic_type = line.gsub(/ethernet0.virtualDev = /i, '').gsub('"', '').strip
522
+ if nic_type.nil?
523
+ nic_type = line.gsub(/ethernet0.virtualDev = /i, '').gsub('"', '').strip
430
524
  new_vmx_contents << line
431
525
  else
432
- new_vmx_contents << line.gsub(/ = .*$/, " = \"#{config.nic_type}\"\n")
526
+ new_vmx_contents << line.gsub(/ = .*$/, " = \"#{nic_type}\"\n")
433
527
  vmx_need_change_flag = true
434
528
  end
435
529
  elsif (line.match(/^ethernet[0-9].addressType = /i) &&
@@ -449,13 +543,27 @@ module VagrantPlugins
449
543
  end
450
544
  end
451
545
  else
452
- new_vmx_contents << line
546
+ line_changed = false
547
+ if config.custom_vmx_settings.is_a? Array
548
+ env[:machine].provider_config.custom_vmx_settings.each do |k, v|
549
+ if line =~ /#{k} = /
550
+ new_vmx_contents << "#{k} = \"#{v}\"\n"
551
+ vmx_need_change_flag = true
552
+ line_changed = true
553
+ env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
554
+ message: "Custom vmx : Modify #{k} = \"#{v}\"")
555
+ end
556
+ end
557
+ end
558
+ if line_changed == false
559
+ new_vmx_contents << line
560
+ end
453
561
  end
454
562
  end
455
563
 
456
564
  # For all nics, configure nic_type and enable nics
457
- if config.nic_type.nil?
458
- config.nic_type = "e1000"
565
+ if nic_type.nil?
566
+ nic_type = "e1000"
459
567
  end
460
568
  if config.virtual_network.is_a? Array
461
569
  number_of_adapters = config.virtual_network.count
@@ -465,8 +573,8 @@ module VagrantPlugins
465
573
 
466
574
  1.upto(number_of_adapters) do |index|
467
575
  nic_index = index - 1
468
- unless new_vmx_contents =~ /ethernet#{nic_index}.virtualDev = \"#{config.nic_type}\"/i
469
- new_vmx_contents << "ethernet#{nic_index}.virtualDev = \"#{config.nic_type}\"\n"
576
+ unless new_vmx_contents =~ /ethernet#{nic_index}.virtualDev = \"#{nic_type}\"/i
577
+ new_vmx_contents << "ethernet#{nic_index}.virtualDev = \"#{nic_type}\"\n"
470
578
  vmx_need_change_flag = true
471
579
  end
472
580
  unless new_vmx_contents =~ /ethernet#{nic_index}.present = \"TRUE\"/i
@@ -475,11 +583,15 @@ module VagrantPlugins
475
583
  end
476
584
  end
477
585
 
478
- # append custom_vmx_settings if exists
586
+ # append custom_vmx_settings if not yet in vmx
479
587
  if config.custom_vmx_settings.is_a? Array
480
588
  env[:machine].provider_config.custom_vmx_settings.each do |k, v|
481
- new_vmx_contents << "#{k} = \"#{v}\"\n"
482
- vmx_need_change_flag = true
589
+ unless new_vmx_contents =~ /#{k} = /
590
+ new_vmx_contents << "#{k} = \"#{v}\"\n"
591
+ vmx_need_change_flag = true
592
+ env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
593
+ message: "Custom vmx : Append #{k} = \"#{v}\"")
594
+ end
483
595
  end
484
596
  end
485
597
 
@@ -487,6 +599,7 @@ module VagrantPlugins
487
599
  if vmx_need_change_flag == true
488
600
  if (config.debug =~ %r{vmx}i)
489
601
  puts "new vmx: #{new_vmx_contents}"
602
+ puts "\n\n"
490
603
  end
491
604
  r = ''
492
605
  ssh.open_channel do |channel|
@@ -107,7 +107,8 @@ module VagrantPlugins
107
107
  '&', '%26').gsub(':', '%3a').gsub(\
108
108
  '/', '%2f').gsub('\\','%5c').gsub(\
109
109
  '"', '%22').gsub('\'','%27').gsub(\
110
- '*', '%2a').gsub('?', '%3f')
110
+ '*', '%2a').gsub('?', '%3f').gsub(\
111
+ '$', '%24')
111
112
 
112
113
  @logger.info('vagrant-vmware-esxi, connect_esxi: esxi_private_keys: '\
113
114
  "#{config.esxi_private_keys}")
@@ -67,14 +67,14 @@ module VagrantPlugins
67
67
  ssh_execute_cmd << 'grep "uptimeSeconds ="|sed "s/^.*= //g"|sed s/,//g'
68
68
  uptime = ssh.exec!(ssh_execute_cmd)
69
69
 
70
- if ( r.length == 0 && uptime.to_i > 60)
70
+ if ( r.length == 0 && uptime.to_i > 120)
71
71
  ipaddress = r2.strip
72
72
  else
73
73
  ipaddress = r.strip
74
74
  end
75
75
 
76
76
  if (config.debug =~ %r{ip}i)
77
- puts "ip1: |#{r.strip}| ip2: |#{r2.strip}| ipaddress: #{ipaddress}"
77
+ puts "ip1 (prim):#{r.strip} ip2 (alt):#{r2.strip} Final: #{ipaddress}"
78
78
  end
79
79
 
80
80
  return nil if (ipaddress == '')
@@ -13,17 +13,26 @@ module VagrantPlugins
13
13
  attr_accessor :private_key_path
14
14
  attr_accessor :vmname
15
15
  attr_accessor :vmname_prefix
16
+ attr_accessor :guestos
16
17
  attr_accessor :vm_disk_store
18
+ attr_accessor :vm_disk_type
17
19
  attr_accessor :virtual_network
18
20
  attr_accessor :nic_type
19
21
  attr_accessor :mac_address
20
22
  attr_accessor :resource_pool
21
23
  attr_accessor :memsize
22
24
  attr_accessor :numvcpus
25
+ attr_accessor :virtualhw_version
23
26
  attr_accessor :custom_vmx_settings
24
27
  attr_accessor :allow_overwrite
25
28
  attr_accessor :debug
29
+ attr_accessor :lax
26
30
  attr_accessor :system_private_keys_path
31
+ attr_accessor :supported_virtualhw_versions
32
+ attr_accessor :supported_vm_disk_types
33
+ attr_accessor :supported_nic_types
34
+ attr_accessor :supported_guestos
35
+
27
36
  def initialize
28
37
  @esxi_hostname = nil
29
38
  @esxi_hostport = 22
@@ -34,29 +43,206 @@ module VagrantPlugins
34
43
  @private_key_path = UNSET_VALUE
35
44
  @vmname = nil
36
45
  @vmname_prefix = 'V-'
46
+ @guestos = nil
37
47
  @vm_disk_store = nil
48
+ @vm_disk_type = nil
38
49
  @virtual_network = nil
39
50
  @nic_type = nil
40
51
  @mac_address = ["","","",""]
41
52
  @resource_pool = nil
42
53
  @memsize = UNSET_VALUE
43
54
  @numvcpus = UNSET_VALUE
55
+ @virtualhw_version = nil
44
56
  @custom_vmx_settings = UNSET_VALUE
45
57
  @allow_overwrite = 'False'
46
58
  @debug = 'False'
59
+ @lax = 'False'
47
60
  @system_private_keys_path = [
48
61
  '~/.ssh/id_rsa',
49
62
  '~/.ssh/id_ecdsa',
50
63
  '~/.ssh/id_ed25519',
51
64
  '~/.ssh/id_dsa'
52
65
  ]
66
+ @supported_virtualhw_versions = [
67
+ 4,7,8,9,10,11,12,13
68
+ ]
69
+ @supported_vm_disk_types = [
70
+ 'thin',
71
+ 'thick',
72
+ 'eagerzeroedthick'
73
+ ]
74
+ @supported_nic_types = [
75
+ 'vlance',
76
+ 'flexible',
77
+ 'e1000',
78
+ 'e1000e',
79
+ 'vmxnet',
80
+ 'vmxnet2',
81
+ 'vmxnet3'
82
+ ]
83
+ @supported_guestos = [
84
+ 'asianux3-64',
85
+ 'asianux3',
86
+ 'asianux4-64',
87
+ 'asianux4',
88
+ 'asianux5-64',
89
+ 'asianux7-64',
90
+ 'centos6-64',
91
+ 'centos-64',
92
+ 'centos6',
93
+ 'centos7-64',
94
+ 'centos7',
95
+ 'centos',
96
+ 'coreos-64',
97
+ 'darwin10-64',
98
+ 'darwin10',
99
+ 'darwin11-64',
100
+ 'darwin11',
101
+ 'darwin12-64',
102
+ 'darwin13-64',
103
+ 'darwin14-64',
104
+ 'darwin15-64',
105
+ 'darwin16-64',
106
+ 'darwin-64',
107
+ 'darwin',
108
+ 'debian10-64',
109
+ 'debian10',
110
+ 'debian4-64',
111
+ 'debian4',
112
+ 'debian5-64',
113
+ 'debian5',
114
+ 'debian6-64',
115
+ 'debian6',
116
+ 'debian7-64',
117
+ 'debian7',
118
+ 'debian8-64',
119
+ 'debian8',
120
+ 'debian9-64',
121
+ 'debian9',
122
+ 'dos',
123
+ 'eComStation2',
124
+ 'eComStation',
125
+ 'fedora-64',
126
+ 'fedora',
127
+ 'freebsd-64',
128
+ 'freebsd',
129
+ 'genericLinux',
130
+ 'mandrake',
131
+ 'mandriva-64',
132
+ 'mandriva',
133
+ 'netware4',
134
+ 'netware5',
135
+ 'netware6',
136
+ 'nld9',
137
+ 'oes',
138
+ 'openServer5',
139
+ 'openServer6',
140
+ 'opensuse-64',
141
+ 'opensuse',
142
+ 'oracleLinux6-64',
143
+ 'oracleLinux-64',
144
+ 'oracleLinux6',
145
+ 'oracleLinux7-64',
146
+ 'oracleLinux7',
147
+ 'oracleLinux',
148
+ 'os2',
149
+ 'other24xLinux-64',
150
+ 'other24xLinux',
151
+ 'other26xLinux-64',
152
+ 'other26xLinux',
153
+ 'other3xLinux-64',
154
+ 'other3xLinux',
155
+ 'other',
156
+ 'otherGuest-64',
157
+ 'otherLinux-64',
158
+ 'otherLinux',
159
+ 'redhat',
160
+ 'rhel2',
161
+ 'rhel3-64',
162
+ 'rhel3',
163
+ 'rhel4-64',
164
+ 'rhel4',
165
+ 'rhel5-64',
166
+ 'rhel5',
167
+ 'rhel6-64',
168
+ 'rhel6',
169
+ 'rhel7-64',
170
+ 'rhel7',
171
+ 'sjds',
172
+ 'sles10-64',
173
+ 'sles10',
174
+ 'sles11-64',
175
+ 'sles11',
176
+ 'sles12-64',
177
+ 'sles12',
178
+ 'sles-64',
179
+ 'sles',
180
+ 'solaris10-64',
181
+ 'solaris10',
182
+ 'solaris11-64',
183
+ 'solaris6',
184
+ 'solaris7',
185
+ 'solaris8',
186
+ 'solaris9',
187
+ 'suse-64',
188
+ 'suse',
189
+ 'turboLinux-64',
190
+ 'turboLinux',
191
+ 'ubuntu-64',
192
+ 'ubuntu',
193
+ 'unixWare7',
194
+ 'vmkernel5',
195
+ 'vmkernel65',
196
+ 'vmkernel6',
197
+ 'vmkernel',
198
+ 'vmwarePhoton-64',
199
+ 'win2000AdvServ',
200
+ 'win2000Pro',
201
+ 'win2000Serv',
202
+ 'win31',
203
+ 'win95',
204
+ 'win98',
205
+ 'windows7-64',
206
+ 'windows7',
207
+ 'windows7Server-64',
208
+ 'windows8-64',
209
+ 'windows8',
210
+ 'windows8Server-64',
211
+ 'windows9-64',
212
+ 'windows9',
213
+ 'windows9Server-64',
214
+ 'windowsHyperV',
215
+ 'winLonghorn-64',
216
+ 'winLonghorn',
217
+ 'winMe',
218
+ 'winNetBusiness',
219
+ 'winNetDatacenter-64',
220
+ 'winNetDatacenter',
221
+ 'winNetEnterprise-64',
222
+ 'winNetEnterprise',
223
+ 'winNetStandard-64',
224
+ 'winNetStandard',
225
+ 'winNetWeb',
226
+ 'winNT',
227
+ 'winVista-64',
228
+ 'winVista',
229
+ 'winXPHome',
230
+ 'winXPPro-64',
231
+ 'winXPPro'
232
+ ]
53
233
  end
54
234
 
55
235
  def finalize!
56
236
  @private_key_path = nil if @private_key_path == UNSET_VALUE
57
237
  @ssh_username = nil if @ssh_username == UNSET_VALUE
58
238
  @esxi_private_keys = @system_private_keys_path if @esxi_private_keys == UNSET_VALUE
59
- end
239
+ if @lax =~ /true/i
240
+ @lax = 'True'
241
+ else
242
+ @lax = 'False'
243
+ @virtualhw_version = @virtualhw_version.to_i unless @virtualhw_version.nil?
244
+ end
245
+ end
60
246
  end
61
247
  end
62
248
  end
@@ -1,6 +1,6 @@
1
1
  # VERSION
2
2
  module VagrantPlugins
3
3
  module ESXi
4
- VERSION = '1.4.0'
4
+ VERSION = '1.5.0'
5
5
  end
6
6
  end
@@ -3,7 +3,7 @@ require File.expand_path('../lib/vagrant-vmware-esxi/version', __FILE__)
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'vagrant-vmware-esxi'
5
5
  s.version = VagrantPlugins::ESXi::VERSION
6
- s.date = '2018-01-17'
6
+ s.date = '2018-01-23'
7
7
  s.summary = 'Vagrant ESXi provider plugin'
8
8
  s.description = 'A Vagrant plugin that adds a VMware ESXi provider support'
9
9
  s.authors = ['Jonathan Senkerik']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-vmware-esxi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Senkerik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-17 00:00:00.000000000 Z
11
+ date: 2018-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n