vagrant-vmware-esxi 2.0.1 → 2.0.2

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: d5daa11a6e5b364f38c0676918faa0b733e8dc3c
4
- data.tar.gz: dd212a04fa4836c7f187c336a9783f5975272eb1
3
+ metadata.gz: 5d0834aff046d2b6fdb5d399570a17e186db96af
4
+ data.tar.gz: 7a102b5eda42f9314a8cb80ed75caae98b286f38
5
5
  SHA512:
6
- metadata.gz: a515dc8d554fc85b8023f0414014ff966c41063adfa6ed9a9bdcae9dc14d2a289afe242ede60e89d6455afffc121ba9b851a7be7be89b6a907c6565bc0005e4b
7
- data.tar.gz: cd4f60c7d90e86e23b2ecfb210c0e7b1ece805e6072f647e364127a40af3db9be7e19d18d86b9da922698be4396391e2211d5db8fce96f9a644f177830de6c48
6
+ metadata.gz: 4319d1e60822a7fe713b5300e14f5bb7a77ef5a369eed508c41de448e1b0d20ad85c0667c8e03572a9a0a19db6375a7623e41975bfe1c3b4b10d343c594e6779
7
+ data.tar.gz: b951da71fc3e6fef1ce65f698bc18d1175f4c94f9a9638c83103df89675e228ab4db7d801cd3c55c39f42914a55dec775300a1e6d78f4ff0da2214275b3d8157
data/README.md CHANGED
@@ -21,14 +21,14 @@ Features and Compatibility
21
21
  * Automatic VM names are 'PREFIX-HOSTNAME-USERNAME-DIR'.
22
22
  * Multi machine capable.
23
23
  * Supports adding your VM to Resource Pools to partition CPU and memory usage from other VMs on your ESXi host.
24
- * suspend / resume.
25
- * snapshots.
24
+ * suspend, resume, snapshots.
26
25
  * rsync & NFS using built-in Vagrant synced folders.
27
26
  * Provision using built-in Vagrant provisioner.
28
27
  * package your vm's into boxes.
29
28
  * Create additional network interfaces, set nic type, MAC addresses, static IPs.
30
29
  * Use Vagrants private_network, public_network options to set a static IP addresses on additional network interfaces. (not the primary interface)
31
30
  * Disks provisioned using thin, thick or eagerzeroedthick.
31
+ * Create additional guest storage (upto 14 virtual disks).
32
32
  * Specify GuestOS types, virtual HW version, or any custom vmx settings.
33
33
 
34
34
  Requirements
@@ -39,7 +39,7 @@ Requirements
39
39
  3. You MUST enable ssh access on your ESXi hypervisor.
40
40
  * Google 'How to enable ssh access on esxi'
41
41
  4. The boxes must have open-vm-tools or vmware-tools installed to properly transition to the 'running' state.
42
- 5. In general, you should know how to use vagrant and esxi...
42
+ 5. In general, you should know how to use vagrant, esxi and some networking...
43
43
 
44
44
  Why this plugin?
45
45
  ----------------
@@ -172,6 +172,11 @@ Vagrant.configure('2') do |config|
172
172
  # 'thin', 'thick', or 'eagerzeroedthick'
173
173
  #esxi.guest_disk_type = 'thick'
174
174
 
175
+ # OPTIONAL. Create additional storage for guests.
176
+ # You can specify an array of upto 14 virtual disk sizes (in GB) that you
177
+ # would like the provider to create once the guest has been created.
178
+ #esxi.guest_storage = [10,20]
179
+
175
180
  # OPTIONAL. specify snapshot options.
176
181
  #esxi.guest_snapshot_includememory = 'true'
177
182
  #esxi.guest_snapshot_quiesced = 'true'
@@ -253,25 +258,28 @@ Known issues with vmware_esxi
253
258
 
254
259
  Version History
255
260
  ---------------
261
+ * 2.0.2 Add support to add additional storage to guest vms.
262
+ Fix, encode (space) in esxi passwords.
263
+
256
264
  * 2.0.1 Updated version:
257
- Most Vagrantfile options have been renamed to be consistent and for clarity.
258
- vagrant up, more organized summary by esxi/guest options.
259
- Lots of Code cleanup.
260
- Add support for snapshot options (includeMemory & quiesced)
261
- Snapshot save/push adds a description.
265
+ Most Vagrantfile options have been renamed to be consistent and for clarity.
266
+ vagrant up, more organized summary by esxi/guest options.
267
+ Lots of Code cleanup.
268
+ Add support for snapshot options (includeMemory & quiesced)
269
+ Snapshot save/push adds a description.
262
270
 
263
271
  * 1.5.1 Fix:
264
- Improve debug output.
265
- Fix password encoding for @ character.
266
- Automatically add a virtual network when configuring a public_network or private_network.
272
+ Improve debug output.
273
+ Fix password encoding for @ character.
274
+ Automatically add a virtual network when configuring a public_network or private_network.
267
275
 
268
276
  * 1.5.0 Add support for:
269
- Specify guest_custom_vmx_settings (to add or modify vmx settings).
270
- Specify Virtual HW version.
271
- Allow $ in Password.
272
- Disk types (thick, thin, eagerzeroedthick).
273
- Specify a guestOS type (see list above).
274
- Relocal_laxed ovftool setting (--local_lax), to allow importing strange ovf boxes.
277
+ Specify guest_custom_vmx_settings (to add or modify vmx settings).
278
+ Specify Virtual HW version.
279
+ Allow $ in Password.
280
+ Disk types (thick, thin, eagerzeroedthick).
281
+ Specify a guestOS type (see list above).
282
+ Relocal_laxed ovftool setting (--local_lax), to allow importing strange ovf boxes.
275
283
 
276
284
  * 1.4.0 Add support to set MAC and IP addresses for network interfaces.
277
285
  * 1.3.2 Fix, Don't timeout ssh connection when ovftool takes a long time to upload image.
@@ -153,6 +153,14 @@ Vagrant.configure('2') do |config|
153
153
  # 'thin', 'thick', or 'eagerzeroedthick'
154
154
  #esxi.guest_disk_type = 'thick'
155
155
 
156
+ # OPTIONAL. Create additional storage for guests.
157
+ # You can specify an array of upto 14 virtual disk sizes (in GB) that you
158
+ # would like the provider to create once the guest has been created. The
159
+ # virtual disks will be created and added to the guest, however you must
160
+ # provision it. The disks can be used for lvm, partitioned, raw disk
161
+ # for data bases, etc...
162
+ #esxi.guest_storage = [10,20]
163
+
156
164
  # OPTIONAL & RISKY. Specify up to 4 MAC addresses
157
165
  # The default is ovftool to automatically generate a MAC address.
158
166
  # You can specify an array of MAC addresses using upper or lower case,
@@ -325,6 +325,8 @@ module VagrantPlugins
325
325
  new_guest_mac_address[index] = ''
326
326
  else
327
327
  new_guest_mac_address[index] = "invalid"
328
+ env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
329
+ message: "WARNING : Ignored invalid mac address at index[#{index}]")
328
330
  end
329
331
  end
330
332
  end
@@ -361,6 +363,24 @@ module VagrantPlugins
361
363
  end
362
364
  end
363
365
 
366
+ # Validate guest Storage
367
+ if config.guest_storage.is_a? Array
368
+ new_guest_storage = []
369
+ 0.upto(config.guest_storage.count - 1) do |index|
370
+ store_size = config.guest_storage[index].to_i
371
+ if store_size < 1
372
+ env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
373
+ message: 'WARNING : Ignored invalid '\
374
+ "storage size #{config.guest_storage[index]} at "\
375
+ "index[#{index}]")
376
+ new_guest_storage[index] = "invalid"
377
+ else
378
+ new_guest_storage[index] = store_size
379
+ end
380
+ end
381
+ config.guest_storage = new_guest_storage
382
+ end
383
+
364
384
  # Validate virtual HW levels
365
385
  unless config.guest_virtualhw_version.nil?
366
386
  if config.supported_guest_virtualhw_versions.include? config.guest_virtualhw_version.to_i
@@ -412,7 +432,7 @@ module VagrantPlugins
412
432
  message: "CPUS : #{desired_guest_numvcpus}")
413
433
  unless config.guest_mac_address[0].eql? ''
414
434
  env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
415
- message: "Mac Address : #{config.guest_mac_address}")
435
+ message: "Mac Address : #{config.guest_mac_address[0..3]}")
416
436
  end
417
437
  unless guest_nic_type.nil?
418
438
  env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
@@ -422,6 +442,10 @@ module VagrantPlugins
422
442
  env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
423
443
  message: "Disk Type : #{guest_disk_type}")
424
444
  end
445
+ unless config.guest_storage.nil?
446
+ env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
447
+ message: "Storage (GB) : #{config.guest_storage[0..13]}")
448
+ end
425
449
  env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
426
450
  message: "Guest OS type : #{config.guest_guestos}")
427
451
  unless guest_virtualhw_version.nil?
@@ -436,7 +460,8 @@ module VagrantPlugins
436
460
  env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
437
461
  message: 'Allow Overwrite : True')
438
462
  end
439
-
463
+ env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
464
+ message: " --- Guest Build ---")
440
465
 
441
466
  #
442
467
  # Using ovftool, import vmx in box folder, export to ESXi server
@@ -477,7 +502,8 @@ module VagrantPlugins
477
502
  end
478
503
 
479
504
  #
480
- # Re-open the network connection to get VMID
505
+ # Re-open the network connection to get VMID and do final adjustments
506
+ # to vmx file.
481
507
  #
482
508
  Net::SSH.start(config.esxi_hostname, config.esxi_username,
483
509
  password: $esxi_password,
@@ -506,19 +532,81 @@ module VagrantPlugins
506
532
  dst_vmx = ssh.exec!("vim-cmd vmsvc/get.config #{env[:machine].id} |\
507
533
  grep vmPathName|awk '{print $NF}'|sed 's/[\"|,]//g'")
508
534
 
509
- dst_vmx_dir = ssh.exec!("vim-cmd vmsvc/get.config #{env[:machine].id} |"\
535
+ dst_vmx_ds = ssh.exec!("vim-cmd vmsvc/get.config #{env[:machine].id} |"\
510
536
  'grep vmPathName|grep -oE "\[.*\]"')
511
537
 
538
+ dst_vmx_dir = ssh.exec!("vim-cmd vmsvc/get.config #{env[:machine].id} |\
539
+ grep vmPathName|awk '{print $NF}'|awk -F'\/' '{print $1}'")
540
+
541
+
512
542
  dst_vmx_file = "/vmfs/volumes/"
513
- dst_vmx_file << dst_vmx_dir.gsub('[','').gsub(']','').strip + "/"
543
+ dst_vmx_file << dst_vmx_ds.gsub('[','').gsub(']','').strip + "/"
544
+ esxi_guest_dir = dst_vmx_file + dst_vmx_dir.strip
514
545
  dst_vmx_file << dst_vmx
515
546
 
547
+ # Create storage if required
548
+ if config.guest_storage.is_a? Array
549
+ index = -1
550
+ config.guest_storage.each do |store|
551
+ store_size = store.to_i
552
+ index += 1
553
+ if store_size == 0
554
+ env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
555
+ message: "Creating Storage: Skipping --invalid-- at storage[#{index}]")
556
+ elsif index > 14
557
+ env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
558
+ message: "Creating Storage: Skipping storage[#{index}], Maximum 14 devices exceeded...")
559
+ else
560
+ env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
561
+ message: "Creating Storage: disk_#{index}.vmdk (#{store_size}GB)")
562
+
563
+ # Figure out what SCSI slots are used.
564
+ r = ssh.exec!("vim-cmd vmsvc/device.getdevices #{machine.id}|"\
565
+ "grep -A 30 vim.vm.device.VirtualDisk|"\
566
+ "grep -e controllerKey -e unitNumber|grep -A 1 'controllerKey = 1000,'|"\
567
+ "grep unitNumber|awk '{print $3}'|sed 's/,//g'")
568
+
569
+ if r.length < 2
570
+ raise Errors::ESXiError,
571
+ message: "Unable to get guest storage configuration:\n"\
572
+ " #{r}"\
573
+ ' Review ESXi logs for additional information!'
574
+ end
575
+ 0.upto(15) do |slot|
576
+ next if slot == 7
577
+ if r !~ %r{^#{slot.to_s}$}i
578
+ puts "Avail slot: #{slot}" if config.debug =~ %r{true}i
579
+ guest_disk_type = 'zeroedthick' if guest_disk_type == 'thick'
580
+
581
+ cmd = "/bin/vmkfstools -c #{store_size}G -d #{guest_disk_type} #{esxi_guest_dir}/disk_#{index}.vmdk"
582
+ puts "cmd: #{cmd}" if config.debug =~ %r{true}i
583
+ r = ssh.exec!(cmd)
584
+ if r.exitstatus != 0
585
+ raise Errors::ESXiError,
586
+ message: "Unable to create guest storage (vmkfstools failed):\n"\
587
+ " #{r}"\
588
+ ' Review ESXi logs for additional information!'
589
+ end
590
+ r = ssh.exec!("vim-cmd vmsvc/device.diskaddexisting #{env[:machine].id} "\
591
+ "#{esxi_guest_dir}/disk_#{index}.vmdk 0 #{slot}")
592
+ if r.exitstatus != 0
593
+ raise Errors::ESXiError,
594
+ message: "Unable to create guest storage (vmkfstools failed):\n"\
595
+ " #{r}"\
596
+ ' Review ESXi logs for additional information!'
597
+ end
598
+ break
599
+ end
600
+ end
601
+ end
602
+ end
603
+ end
604
+
516
605
  # Get vmx file in memory
517
606
  esxi_orig_vmx_file = ssh.exec!("cat #{dst_vmx_file} 2>/dev/null")
518
- if config.debug =~ %r{vmx}i
519
- puts "orig vmx: #{esxi_orig_vmx_file}"
520
- puts "\n\n"
521
- end
607
+
608
+ puts "orig vmx: #{esxi_orig_vmx_file}\n\n" if config.debug =~ %r{vmx}i
609
+
522
610
  if esxi_orig_vmx_file.exitstatus != 0
523
611
  raise Errors::ESXiError,
524
612
  message: "Unable to read #{dst_vmx_file}"
@@ -574,8 +662,6 @@ module VagrantPlugins
574
662
  elsif guest_mac_address == ''
575
663
  new_vmx_contents << line
576
664
  else
577
- env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
578
- message: "Ignored invalid mac address at index: #{nicindex}")
579
665
  new_vmx_contents << line
580
666
  end
581
667
  end
@@ -656,6 +742,10 @@ module VagrantPlugins
656
742
  message: 'ESXi vmx file : Unmodified')
657
743
  end
658
744
  end
745
+
746
+
747
+
748
+ # Done
659
749
  end
660
750
  end
661
751
  end
@@ -107,7 +107,7 @@ module VagrantPlugins
107
107
  '/', '%2f').gsub('\\','%5c').gsub(\
108
108
  '"', '%22').gsub('\'','%27').gsub(\
109
109
  '*', '%2a').gsub('?', '%3f').gsub(\
110
- '$', '%24')
110
+ '$', '%24').gsub(' ', '%20')
111
111
 
112
112
  @logger.info('vagrant-vmware-esxi, connect_esxi: local_private_keys: '\
113
113
  "#{config.local_private_keys}")
@@ -16,6 +16,7 @@ module VagrantPlugins
16
16
  attr_accessor :guest_name_prefix
17
17
  attr_accessor :guest_guestos
18
18
  attr_accessor :guest_disk_type
19
+ attr_accessor :guest_storage
19
20
  attr_accessor :guest_nic_type
20
21
  attr_accessor :guest_mac_address
21
22
  attr_accessor :guest_memsize
@@ -67,6 +68,7 @@ module VagrantPlugins
67
68
  @guest_name_prefix = 'V-'
68
69
  @guest_guestos = nil
69
70
  @guest_disk_type = nil
71
+ @guest_storage = nil
70
72
  @guest_nic_type = nil
71
73
  @guest_mac_address = ["","","",""]
72
74
  @guest_memsize = nil
@@ -352,6 +354,9 @@ module VagrantPlugins
352
354
 
353
355
  @guest_username = nil if @guest_username == UNSET_VALUE
354
356
 
357
+ @guest_storage = [@guest_storage.to_i] if @guest_storage.is_a? String
358
+ @guest_storage = [@guest_storage] if @guest_storage.is_a? Integer
359
+
355
360
  @esxi_virtual_network = [@esxi_virtual_network] if @esxi_virtual_network.is_a? String
356
361
 
357
362
  @esxi_virtual_network = ['--NotSet--'] if @esxi_virtual_network.nil?
@@ -1,7 +1,7 @@
1
1
  # VERSION
2
2
  module VagrantPlugins
3
3
  module ESXi
4
- VERSION = '2.0.1'
4
+ VERSION = '2.0.2'
5
5
  $vagrant_vmware_esxi_version = VERSION
6
6
  end
7
7
  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-02-11'
6
+ s.date = '2018-02-15'
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: 2.0.1
4
+ version: 2.0.2
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-02-11 00:00:00.000000000 Z
11
+ date: 2018-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n