vagrant-vmware-esxi 2.0.7 → 2.1.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/README.md +17 -1
- data/example_box/Vagrantfile +8 -0
- data/lib/vagrant-vmware-esxi/action.rb +3 -6
- data/lib/vagrant-vmware-esxi/action/createvm.rb +169 -193
- data/lib/vagrant-vmware-esxi/action/read_ssh_info.rb +0 -1
- data/lib/vagrant-vmware-esxi/action/set_network_ip.rb +1 -0
- data/lib/vagrant-vmware-esxi/action/wait_for_state.rb +1 -0
- data/lib/vagrant-vmware-esxi/config.rb +50 -48
- data/lib/vagrant-vmware-esxi/version.rb +1 -1
- data/vagrant-vmware-esxi.gemspec +1 -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: a0fd559e963813bd56e7f2dedf83924abbe16706
|
4
|
+
data.tar.gz: 56447256f57346e7f1b3da2de4da83d0a529c237
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00200e42bb32d12799a69d1f50a79c9345078c4d84875017ad7c8d1cef46e168296d1ba06aab9720fc5b0e66bc9086b739ac9e938d291bfedaa54a20c44eff2e
|
7
|
+
data.tar.gz: 043e6563f627a24a820f4963eff2e225ff082063db94f7bddbb8d25ec87e2d57449c9368140c16ecd2e4205e8d665931ab5122567126c9486d4bdf6e72a27d20
|
data/README.md
CHANGED
@@ -9,9 +9,14 @@ Refer to the WIKI for documentation, examples and other information...
|
|
9
9
|
>https://github.com/josenk/vagrant-vmware-esxi/wiki
|
10
10
|
|
11
11
|
|
12
|
+
What's new!
|
13
|
+
-----------
|
14
|
+
Added support to clone from a VM! Refer to the WIKI for documentation, example and other information.
|
15
|
+
>https://github.com/josenk/vagrant-vmware-esxi/wiki/How-to-clone_from_vm.
|
12
16
|
|
13
17
|
Features and Compatibility
|
14
18
|
--------------------------
|
19
|
+
* Clone from VMs. Clone a VM on the esxi host instead of transferring a box stored on your local pc.
|
15
20
|
* Any of the vmware Box formats should be compatible.
|
16
21
|
* vmware_desktop, vmware_fusion, vmware_workstation...
|
17
22
|
* To be fully functional, you must have open-vm-tools or vmware tools installed.
|
@@ -78,7 +83,7 @@ Vagrant.configure('2') do |config|
|
|
78
83
|
# Here are some of the MANY examples....
|
79
84
|
config.vm.box = 'generic/centos7'
|
80
85
|
#config.vm.box = 'generic/centos6'
|
81
|
-
#config.vm.box = 'generic/
|
86
|
+
#config.vm.box = 'generic/fedora27'
|
82
87
|
#config.vm.box = 'generic/freebsd11'
|
83
88
|
#config.vm.box = 'generic/ubuntu1710'
|
84
89
|
#config.vm.box = 'generic/debian9'
|
@@ -145,6 +150,13 @@ Vagrant.configure('2') do |config|
|
|
145
150
|
# Vagrant will NOT create a Resource pool it for you.
|
146
151
|
#esxi.esxi_resource_pool = '/Vagrant'
|
147
152
|
|
153
|
+
# Optional. Specify a VM to clone instead of uploading a box.
|
154
|
+
# Vagrant can use any stopped VM as the source 'box'. The VM must be
|
155
|
+
# registered, stopped and must have the vagrant insecure ssh key installed.
|
156
|
+
# If the VM is stored in a resource pool, it must be specified.
|
157
|
+
# See wiki: https://github.com/josenk/vagrant-vmware-esxi/wiki/How-to-clone_from_vm.
|
158
|
+
#esxi.clone_from_vm = 'resource_pool/source_vm'
|
159
|
+
|
148
160
|
# OPTIONAL. Guest VM name to use.
|
149
161
|
# The Default will be automatically generated.
|
150
162
|
#esxi.guest_name = 'Custom-Guest-VM_Name'
|
@@ -256,8 +268,12 @@ Known issues with vmware_esxi
|
|
256
268
|
|
257
269
|
Version History
|
258
270
|
---------------
|
271
|
+
* 2.1.0 Add support for clone_from_vm.
|
272
|
+
Fix, use esxcli to get storage information.
|
273
|
+
|
259
274
|
* 2.0.7 Fix, Doesn't wait for running when executing "vagrant reload"
|
260
275
|
Fix, "vagrant halt" will now attempt a graceful shutdown before doing a hard power off.
|
276
|
+
|
261
277
|
* 2.0.6 Fix Windows compatibility by not supporting ed25519 ssh keys. When net-ssh 5.x is released AND vagrant allows it's use, I will support ed25519 again.
|
262
278
|
Fix, encode '/' in esxi passwords.
|
263
279
|
Fix, Get local IP address for NFS syncd folders. Filter out localhost 127.0.0.0/8.
|
data/example_box/Vagrantfile
CHANGED
@@ -126,6 +126,14 @@ Vagrant.configure('2') do |config|
|
|
126
126
|
# Vagrant will NOT create a Resource pool it for you.
|
127
127
|
#esxi.esxi_resource_pool = '/Vagrant'
|
128
128
|
|
129
|
+
# Optional. Specify a VM to clone instead of uploading a box.
|
130
|
+
# Vagrant can use any stopped VM as the source 'box'. The VM must be
|
131
|
+
# registered, stopped and must have the vagrant insecure ssh key installed.
|
132
|
+
# If the VM is stored in a resource pool, it must be specified. If this
|
133
|
+
# option is specified, config.vm.box should be set to a dummy box.
|
134
|
+
# See wiki: https://github.com/josenk/vagrant-vmware-esxi/wiki/How-to-clone_from_vm.
|
135
|
+
#esxi.clone_from_vm = 'resource_pool/source_vm'
|
136
|
+
|
129
137
|
# OPTIONAL. Guest VM name to use.
|
130
138
|
# The Default will be automatically generated. It will be based on
|
131
139
|
# the guest_name_prefix (see below), your hostname & username and path.
|
@@ -27,9 +27,7 @@ module VagrantPlugins
|
|
27
27
|
if env1[:machine_state].to_s == 'running'
|
28
28
|
b1.use Shutdown
|
29
29
|
b1.use Call, WaitForState, :powered_off, 30 do |env1, b2|
|
30
|
-
unless env1[:result] == 'True'
|
31
|
-
b2.use Halt
|
32
|
-
end
|
30
|
+
b2.use Halt unless env1[:result] == 'True'
|
33
31
|
end
|
34
32
|
else
|
35
33
|
b1.use Halt
|
@@ -113,9 +111,7 @@ module VagrantPlugins
|
|
113
111
|
Vagrant::Action::Builder.new.tap do |b|
|
114
112
|
b.use SetESXiPassword
|
115
113
|
b.use Call, ReadState do |env1, b1|
|
116
|
-
unless env1[:machine_state] == 'powered_off'
|
117
|
-
b1.use Halt
|
118
|
-
end
|
114
|
+
b1.use Halt unless env1[:machine_state] == 'powered_off'
|
119
115
|
b1.use ReadState
|
120
116
|
b1.use Destroy
|
121
117
|
end
|
@@ -164,6 +160,7 @@ module VagrantPlugins
|
|
164
160
|
b1.use Provision
|
165
161
|
b1.use SyncedFolderCleanup
|
166
162
|
b1.use SyncedFolders
|
163
|
+
#b1.use SetHostname # Still too buggy. Tested with vagrant 2.0.4dev
|
167
164
|
end
|
168
165
|
end
|
169
166
|
end
|
@@ -31,6 +31,16 @@ module VagrantPlugins
|
|
31
31
|
return
|
32
32
|
end
|
33
33
|
|
34
|
+
#
|
35
|
+
# Verify ovftool is installed.
|
36
|
+
#
|
37
|
+
unless system 'ovftool --version'
|
38
|
+
raise Errors::OVFToolError,
|
39
|
+
message: 'ovftool not found or not in your path.'\
|
40
|
+
" Please download and "\
|
41
|
+
' install from http://www.vmware.com.'
|
42
|
+
end
|
43
|
+
|
34
44
|
# Set desired_guest_name
|
35
45
|
if !env[:machine].config.vm.hostname.nil?
|
36
46
|
# A hostname has been set, so use it.
|
@@ -52,15 +62,38 @@ module VagrantPlugins
|
|
52
62
|
desired_guest_name = desired_guest_name[0..252].gsub(/_/,'-').gsub(/[^0-9A-Za-z\-\.]/i, '').strip
|
53
63
|
@logger.info("vagrant-vmware-esxi, createvm: config.guest_name: #{config.guest_name}")
|
54
64
|
|
55
|
-
#
|
56
65
|
# Source vmx / vmdk files
|
57
66
|
src_dir = env[:machine].box.directory
|
58
67
|
@logger.info("vagrant-vmware-esxi, createvm: src_dir: #{src_dir}")
|
59
68
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
69
|
+
if config.clone_from_vm.nil?
|
70
|
+
vmx_file = Dir.glob("#{src_dir}/*.vmx").first
|
71
|
+
@logger.info("vagrant-vmware-esxi, createvm: vmx_file: #{vmx_file}")
|
72
|
+
source_vmx_contents = File.read(vmx_file)
|
73
|
+
else
|
74
|
+
begin
|
75
|
+
tmpdir = Dir.mktmpdir
|
76
|
+
rescue
|
77
|
+
raise Errors::GeneralError,
|
78
|
+
message: "Unable to create tmp dir #{tmpdir}"
|
79
|
+
end
|
80
|
+
#
|
81
|
+
# Source from Clone Source
|
82
|
+
clone_from_vm_path = "vi://#{config.esxi_username}:#{$encoded_esxi_password}@#{config.esxi_hostname}/#{config.clone_from_vm}"
|
83
|
+
ovf_cmd = "ovftool --noSSLVerify --overwrite --powerOffTarget --noDisks --targetType=vmx "\
|
84
|
+
"#{clone_from_vm_path} #{tmpdir}"
|
85
|
+
unless system "#{ovf_cmd}"
|
86
|
+
raise Errors::OVFToolError,
|
87
|
+
message: "Unable to access #{config.clone_from_vm}"
|
88
|
+
end
|
89
|
+
vmx_file = Dir.glob("#{tmpdir}/#{config.clone_from_vm.split('/')[-1]}/*.vmx").first
|
90
|
+
unless source_vmx_contents = File.read(vmx_file)
|
91
|
+
raise Errors::GeneralError,
|
92
|
+
message: "Unable to read #{vmx_file}"
|
93
|
+
end
|
94
|
+
|
95
|
+
puts "source_vmx_contents: #{source_vmx_contents}" if config.debug =~ %r{vmx}i
|
96
|
+
end
|
64
97
|
|
65
98
|
#
|
66
99
|
# Open the network connection
|
@@ -79,8 +112,8 @@ module VagrantPlugins
|
|
79
112
|
#
|
80
113
|
# Figure out DataStore
|
81
114
|
r = ssh.exec!(
|
82
|
-
'
|
83
|
-
|
115
|
+
'esxcli storage filesystem list | grep "/vmfs/volumes/.*[VMFS|NFS]" | '\
|
116
|
+
"sort -nk7 | awk '{print $2}'")
|
84
117
|
|
85
118
|
availvolumes = r.split(/\n/)
|
86
119
|
if config.debug =~ %r{true}i
|
@@ -196,60 +229,93 @@ module VagrantPlugins
|
|
196
229
|
@logger.info('vagrant-vmware-esxi, createvm: '\
|
197
230
|
"esxi_virtual_network: #{@guestvm_network}")
|
198
231
|
|
199
|
-
#
|
200
|
-
#if (config.guest_memsize.is_a? String) || (config.guest_memsize.is_a? Integer)
|
201
|
-
# desired_guest_memsize = config.guest_memsize.to_s.to_i
|
202
|
-
#end
|
203
|
-
#if (config.guest_numvcpus.is_a? String) || (config.guest_numvcpus.is_a? Integer)
|
204
|
-
# desired_guest_numvcpus = config.guest_numvcpus.to_s.to_i
|
205
|
-
#end
|
232
|
+
# Set some defaults
|
206
233
|
desired_guest_memsize = config.guest_memsize.to_s.to_i unless config.guest_memsize.nil?
|
234
|
+
desired_guest_memsize = 1024 if desired_guest_memsize.nil?
|
235
|
+
|
207
236
|
desired_guest_numvcpus = config.guest_numvcpus.to_s.to_i unless config.guest_numvcpus.nil?
|
237
|
+
desired_guest_numvcpus = 1 if desired_guest_numvcpus.nil?
|
238
|
+
|
239
|
+
unless config.guest_guestos.nil?
|
240
|
+
if config.supported_guest_guestos.include? config.guest_guestos.downcase
|
241
|
+
desired_guestos = config.guest_guestos.downcase.strip
|
242
|
+
else
|
243
|
+
config.guest_guestos = nil
|
244
|
+
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
245
|
+
message: 'WARNING : '\
|
246
|
+
"GuestOS: #{config.guest_guestos} not "\
|
247
|
+
"supported, using box/ovftool defaults")
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
unless config.guest_virtualhw_version.nil?
|
252
|
+
if config.supported_guest_virtualhw_versions.include? config.guest_virtualhw_version.to_i
|
253
|
+
desired_virtualhw_version = config.guest_virtualhw_version.to_i.to_s
|
254
|
+
else
|
255
|
+
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
256
|
+
message: 'WARNING : '\
|
257
|
+
"Invalid guest_virtualhw_version: #{config.guest_virtualhw_version},"\
|
258
|
+
"using ovftool defaults")
|
259
|
+
config.guest_virtualhw_version = nil
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
unless config.guest_nic_type.nil?
|
264
|
+
if config.supported_guest_nic_types.include? config.guest_nic_type.downcase
|
265
|
+
desired_nic_type = config.guest_nic_type.downcase
|
266
|
+
else
|
267
|
+
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
268
|
+
message: 'WARNING : '\
|
269
|
+
"NIC type: #{config.guest_nic_type} not "\
|
270
|
+
"found, using ovftool defaults.")
|
271
|
+
config.guest_nic_type = nil
|
272
|
+
end
|
273
|
+
end
|
208
274
|
|
209
275
|
#
|
210
276
|
# Fix/clean up vmx file.
|
211
277
|
#
|
212
278
|
new_vmx_contents = ''
|
213
|
-
|
279
|
+
source_vmx_contents.each_line do |line|
|
214
280
|
|
215
281
|
case line
|
216
282
|
when /^displayname =/i
|
217
283
|
new_vmx_contents << "displayname = \"#{desired_guest_name}\"\n"
|
284
|
+
|
218
285
|
when /^memsize =/i
|
219
|
-
if
|
220
|
-
new_vmx_contents << line
|
286
|
+
if config.guest_memsize.nil?
|
221
287
|
desired_guest_memsize = line.gsub(/^memsize = /i, '').gsub(/\"/, '').to_i
|
222
|
-
else
|
223
|
-
new_vmx_contents << "memsize = \"#{desired_guest_memsize}\"\n"
|
224
288
|
end
|
289
|
+
new_vmx_contents << "memsize = \"#{desired_guest_memsize}\"\n"
|
290
|
+
|
225
291
|
when /^numvcpus =/i
|
226
|
-
if
|
227
|
-
new_vmx_contents << line
|
292
|
+
if config.guest_numvcpus.nil?
|
228
293
|
desired_guest_numvcpus = line.gsub(/^numvcpus = /i, '').gsub(/\"/, '').to_i
|
229
|
-
else
|
230
|
-
new_vmx_contents << "numvcpus = \"#{desired_guest_numvcpus}\"\n"
|
231
294
|
end
|
232
|
-
|
233
|
-
# Do nothing, delete these lines, we'll fix it later.
|
234
|
-
when /^guestOS = /i
|
295
|
+
new_vmx_contents << "numvcpus = \"#{desired_guest_numvcpus}\"\n"
|
235
296
|
|
236
|
-
|
297
|
+
when /^guestOS = /i
|
237
298
|
if config.guest_guestos.nil?
|
238
|
-
|
299
|
+
desired_guestos = line.gsub(/^guestOS = /i, '').gsub(/\"/, '').strip
|
239
300
|
new_vmx_contents << line
|
240
301
|
else
|
241
|
-
|
242
|
-
config.guest_guestos = config.guest_guestos.downcase.strip
|
243
|
-
new_vmx_contents << "guestOS = \"#{config.guest_guestos}\"\n"
|
244
|
-
else
|
245
|
-
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
246
|
-
message: 'WARNING : '\
|
247
|
-
"GuestOS: #{config.guest_guestos} not "\
|
248
|
-
"supported, using box/ovftool defaults")
|
249
|
-
config.guest_guestos = in_vmx_guest_guestos
|
250
|
-
new_vmx_contents << line
|
251
|
-
end
|
302
|
+
new_vmx_contents << "guestOS = \"#{desired_guestos}\"\n"
|
252
303
|
end
|
304
|
+
|
305
|
+
when /^virtualHW.version = /i
|
306
|
+
if desired_virtualhw_version.nil?
|
307
|
+
desired_virtualhw_version = line.gsub(/^virtualHW.version = /i, '').gsub(/\"/, '').strip
|
308
|
+
new_vmx_contents << line
|
309
|
+
else
|
310
|
+
new_vmx_contents << "virtualHW.version = \"#{desired_virtualhw_version}\"\n"
|
311
|
+
end
|
312
|
+
|
313
|
+
when /^ethernet[0-9]/i
|
314
|
+
# Just save the nic type
|
315
|
+
if (line =~ /ethernet0.virtualDev = /i) and desired_nic_type.nil?
|
316
|
+
desired_nic_type = line.gsub(/ethernet0.virtualDev = /i, '').gsub('"', '').strip
|
317
|
+
end
|
318
|
+
|
253
319
|
else
|
254
320
|
new_vmx_contents << line
|
255
321
|
end
|
@@ -258,29 +324,7 @@ module VagrantPlugins
|
|
258
324
|
|
259
325
|
# finalize vmx.
|
260
326
|
unless new_vmx_contents =~ %r{^numvcpus =}i
|
261
|
-
|
262
|
-
new_vmx_contents << "numvcpus = \"1\"\n"
|
263
|
-
else
|
264
|
-
new_vmx_contents << "numvcpus = \"#{desired_guest_numvcpus}\"\n"
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
# Append virt network options
|
269
|
-
netOpts = ""
|
270
|
-
networkID = 0
|
271
|
-
for element in @guestvm_network do
|
272
|
-
if config.debug =~ %r{true}i
|
273
|
-
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
274
|
-
message: "Network[#{networkID}] : #{element}")
|
275
|
-
end
|
276
|
-
new_vmx_contents << "ethernet#{networkID}.networkName = \"net#{networkID}\"\n"
|
277
|
-
new_vmx_contents << "ethernet#{networkID}.present = \"TRUE\"\n"
|
278
|
-
new_vmx_contents << "ethernet#{networkID}.addressType = \"generated\"\n"
|
279
|
-
netOpts << " --net:\"net#{networkID}=#{element}\""
|
280
|
-
networkID += 1
|
281
|
-
if networkID >= 4
|
282
|
-
break
|
283
|
-
end
|
327
|
+
new_vmx_contents << "numvcpus = \"#{desired_guest_numvcpus}\"\n"
|
284
328
|
end
|
285
329
|
|
286
330
|
# Write new vmx file on local filesystem
|
@@ -334,21 +378,6 @@ module VagrantPlugins
|
|
334
378
|
config.guest_mac_address = new_guest_mac_address
|
335
379
|
end
|
336
380
|
|
337
|
-
# Validate nic types
|
338
|
-
if config.guest_nic_type.nil?
|
339
|
-
guest_nic_type = nil
|
340
|
-
else
|
341
|
-
if config.supported_guest_nic_types.include?(config.guest_nic_type.downcase)
|
342
|
-
guest_nic_type = config.guest_nic_type.downcase
|
343
|
-
else
|
344
|
-
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
345
|
-
message: 'WARNING : '\
|
346
|
-
"NIC type: #{config.guest_nic_type} not "\
|
347
|
-
"found, using ovftool defaults.")
|
348
|
-
guest_nic_type = nil
|
349
|
-
end
|
350
|
-
end
|
351
|
-
|
352
381
|
# Validate disk types (thin, thick, etc...)
|
353
382
|
if config.guest_disk_type.nil?
|
354
383
|
guest_disk_type = "thin"
|
@@ -382,19 +411,6 @@ module VagrantPlugins
|
|
382
411
|
config.guest_storage = new_guest_storage
|
383
412
|
end
|
384
413
|
|
385
|
-
# Validate virtual HW levels
|
386
|
-
unless config.guest_virtualhw_version.nil?
|
387
|
-
if config.supported_guest_virtualhw_versions.include? config.guest_virtualhw_version.to_i
|
388
|
-
guest_virtualhw_version = config.guest_virtualhw_version.to_i.to_s
|
389
|
-
else
|
390
|
-
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
391
|
-
message: 'WARNING : '\
|
392
|
-
"Invalid guest_virtualhw_version: #{config.guest_virtualhw_version},"\
|
393
|
-
" using ovftool defaults")
|
394
|
-
guest_virtualhw_version = nil
|
395
|
-
end
|
396
|
-
end
|
397
|
-
|
398
414
|
# Validate local_lax setting (use relaxed (--lax) ovftool option)
|
399
415
|
unless config.local_lax.nil?
|
400
416
|
if config.local_lax == 'True'
|
@@ -404,7 +420,6 @@ module VagrantPlugins
|
|
404
420
|
end
|
405
421
|
end
|
406
422
|
|
407
|
-
|
408
423
|
#
|
409
424
|
# Print summary
|
410
425
|
#
|
@@ -423,10 +438,15 @@ module VagrantPlugins
|
|
423
438
|
message: " --- Guest Summary ---")
|
424
439
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
425
440
|
message: "VM Name : #{desired_guest_name}")
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
441
|
+
if config.clone_from_vm.nil?
|
442
|
+
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
443
|
+
message: "Box : #{env[:machine].box.name}")
|
444
|
+
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
445
|
+
message: "Box Ver : #{env[:machine].box.version}")
|
446
|
+
else
|
447
|
+
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
448
|
+
message: "Clone from VM : #{config.clone_from_vm}")
|
449
|
+
end
|
430
450
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
431
451
|
message: "Memsize (MB) : #{desired_guest_memsize}")
|
432
452
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
@@ -435,9 +455,9 @@ module VagrantPlugins
|
|
435
455
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
436
456
|
message: "Mac Address : #{config.guest_mac_address[0..3]}")
|
437
457
|
end
|
438
|
-
unless guest_nic_type.nil?
|
458
|
+
unless config.guest_nic_type.nil?
|
439
459
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
440
|
-
message: "Nic Type : #{
|
460
|
+
message: "Nic Type : #{desired_nic_type}")
|
441
461
|
end
|
442
462
|
unless config.guest_disk_type.nil?
|
443
463
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
@@ -448,10 +468,10 @@ module VagrantPlugins
|
|
448
468
|
message: "Storage (GB) : #{config.guest_storage[0..13]}")
|
449
469
|
end
|
450
470
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
451
|
-
message: "Guest OS type : #{
|
452
|
-
unless
|
471
|
+
message: "Guest OS type : #{desired_guestos}")
|
472
|
+
unless config.virtualhw_version.nil?
|
453
473
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
454
|
-
message: "Virtual HW ver : #{
|
474
|
+
message: "Virtual HW ver : #{desired_virtualhw_version}")
|
455
475
|
end
|
456
476
|
if config.local_lax == 'True'
|
457
477
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
@@ -464,20 +484,15 @@ module VagrantPlugins
|
|
464
484
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
465
485
|
message: " --- Guest Build ---")
|
466
486
|
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
raise Errors::OVFToolError,
|
472
|
-
message: 'ovftool not found or not in your path.'\
|
473
|
-
" Please download and "\
|
474
|
-
' install from http://www.vmware.com.'
|
487
|
+
if config.clone_from_vm.nil?
|
488
|
+
src_path = new_vmx_file
|
489
|
+
else
|
490
|
+
src_path = clone_from_vm_path
|
475
491
|
end
|
476
|
-
|
477
492
|
ovf_cmd = "ovftool --noSSLVerify #{overwrite_opts} "\
|
478
|
-
"
|
493
|
+
"-dm=#{guest_disk_type} #{local_laxoption} "\
|
479
494
|
"-ds=\"#{@guestvm_dsname}\" --name=\"#{desired_guest_name}\" "\
|
480
|
-
"\"#{
|
495
|
+
"\"#{src_path}\" vi://#{config.esxi_username}:"\
|
481
496
|
"#{$encoded_esxi_password}@#{config.esxi_hostname}"\
|
482
497
|
"#{esxi_resource_pool}"
|
483
498
|
|
@@ -505,10 +520,11 @@ module VagrantPlugins
|
|
505
520
|
message: "Keeping file : #{new_vmx_file}")
|
506
521
|
else
|
507
522
|
File.delete(new_vmx_file)
|
523
|
+
FileUtils.remove_entry tmpdir unless tmpdir.nil?
|
508
524
|
end
|
509
525
|
|
510
526
|
#
|
511
|
-
# Re-open the network connection to get VMID and do
|
527
|
+
# Re-open the network connection to get VMID and do adjustments
|
512
528
|
# to vmx file.
|
513
529
|
#
|
514
530
|
Net::SSH.start(config.esxi_hostname, config.esxi_username,
|
@@ -621,64 +637,31 @@ module VagrantPlugins
|
|
621
637
|
|
622
638
|
# read each line in vmx to customize
|
623
639
|
new_vmx_contents = ''
|
624
|
-
vmx_need_change_flag = false
|
625
640
|
esxi_orig_vmx_file.each_line do |line|
|
626
641
|
|
627
642
|
case line
|
628
643
|
|
629
|
-
|
644
|
+
when /^memsize = /i
|
645
|
+
new_vmx_contents << "memsize = \"#{desired_guest_memsize}\"\n"
|
646
|
+
|
647
|
+
when /^numvcpus = /i
|
648
|
+
new_vmx_contents << "numvcpus = \"#{desired_guest_numvcpus}\"\n"
|
649
|
+
|
630
650
|
when /^virtualHW.version = /i
|
631
|
-
|
632
|
-
new_vmx_contents << line
|
633
|
-
else
|
634
|
-
new_vmx_contents << "virtualHW.version = \"#{guest_virtualhw_version}\"\n"
|
635
|
-
vmx_need_change_flag = true
|
636
|
-
end
|
651
|
+
new_vmx_contents << "virtualHW.version = \"#{desired_virtualhw_version}\"\n"
|
637
652
|
|
638
653
|
when /^guestOS = /i
|
639
|
-
|
640
|
-
new_vmx_contents << line
|
641
|
-
else
|
642
|
-
new_vmx_contents << "guestOS = \"#{config.guest_guestos}\"\n"
|
643
|
-
vmx_need_change_flag = true
|
644
|
-
end
|
654
|
+
new_vmx_contents << "guestOS = \"#{desired_guestos}\"\n"
|
645
655
|
|
646
|
-
# configure mac and nic type.
|
647
656
|
when /^ethernet[0-9]/i
|
648
|
-
|
649
|
-
|
650
|
-
new_vmx_contents << line
|
651
|
-
elsif line.match(/^ethernet0.virtualDev = /i)
|
652
|
-
# Update guest_nic_type if it's set, otherwise, save eth0 guest_nic_type
|
653
|
-
# for the remaining nics. (ovftool doesn't set it...)
|
654
|
-
if guest_nic_type.nil?
|
655
|
-
guest_nic_type = line.gsub(/ethernet0.virtualDev = /i, '').gsub('"', '').strip
|
656
|
-
new_vmx_contents << line
|
657
|
-
else
|
658
|
-
new_vmx_contents << line.gsub(/ = .*$/, " = \"#{guest_nic_type}\"\n")
|
659
|
-
vmx_need_change_flag = true
|
660
|
-
end
|
661
|
-
elsif (line.match(/^ethernet[0-9].addressType = /i) &&
|
662
|
-
!config.guest_mac_address[nicindex].nil?)
|
663
|
-
# Update MAC address if it's set
|
664
|
-
guest_mac_address = config.guest_mac_address[nicindex]
|
665
|
-
if guest_mac_address =~ /^([0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$/i
|
666
|
-
new_vmx_contents << line.gsub(/ = .*$/, " = \"static\"")
|
667
|
-
new_vmx_contents << line.gsub(/Type = .*$/, " = \"#{guest_mac_address}\"")
|
668
|
-
vmx_need_change_flag = true
|
669
|
-
elsif guest_mac_address == ''
|
670
|
-
new_vmx_contents << line
|
671
|
-
else
|
672
|
-
new_vmx_contents << line
|
673
|
-
end
|
674
|
-
end
|
657
|
+
# Delete these entries. We'll append them later.
|
658
|
+
|
675
659
|
else
|
676
660
|
line_changed = false
|
677
661
|
if config.guest_custom_vmx_settings.is_a? Array
|
678
662
|
env[:machine].provider_config.guest_custom_vmx_settings.each do |k, v|
|
679
663
|
if line =~ /#{k} = /
|
680
664
|
new_vmx_contents << "#{k} = \"#{v}\"\n"
|
681
|
-
vmx_need_change_flag = true
|
682
665
|
line_changed = true
|
683
666
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
684
667
|
message: "Custom vmx : Modify #{k} = \"#{v}\"")
|
@@ -691,25 +674,29 @@ module VagrantPlugins
|
|
691
674
|
end
|
692
675
|
end
|
693
676
|
|
694
|
-
# For all nics, configure
|
695
|
-
if
|
696
|
-
|
697
|
-
end
|
677
|
+
# For all nics, configure desired_nic_type and enable nics
|
678
|
+
desired_nic_type = 'e1000' if desired_nic_type.nil?
|
679
|
+
|
698
680
|
if config.esxi_virtual_network.is_a? Array
|
699
681
|
number_of_adapters = config.esxi_virtual_network.count
|
700
682
|
else
|
701
683
|
number_of_adapters = 1
|
702
684
|
end
|
703
685
|
|
704
|
-
|
705
|
-
nic_index =
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
686
|
+
0.upto(number_of_adapters - 1) do |nic_index|
|
687
|
+
new_vmx_contents << "ethernet#{nic_index}.networkName = \"#{@guestvm_network[nic_index]}\"\n"
|
688
|
+
new_vmx_contents << "ethernet#{nic_index}.virtualDev = \"#{desired_nic_type}\"\n"
|
689
|
+
new_vmx_contents << "ethernet#{nic_index}.present = \"TRUE\"\n"
|
690
|
+
if config.guest_mac_address[nic_index].nil?
|
691
|
+
new_vmx_contents << "ethernet#{nic_index}.addressType = \"generated\"\n"
|
692
|
+
else
|
693
|
+
guest_mac_address = config.guest_mac_address[nic_index]
|
694
|
+
if guest_mac_address =~ /^([0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$/i
|
695
|
+
new_vmx_contents << "ethernet#{nic_index}.addressType = \"static\"\n"
|
696
|
+
new_vmx_contents << "ethernet#{nic_index}.address = \"#{guest_mac_address}\"\n"
|
697
|
+
else
|
698
|
+
new_vmx_contents << "ethernet#{nic_index}.addressType = \"generated\"\n"
|
699
|
+
end
|
713
700
|
end
|
714
701
|
end
|
715
702
|
|
@@ -718,39 +705,28 @@ module VagrantPlugins
|
|
718
705
|
env[:machine].provider_config.guest_custom_vmx_settings.each do |k, v|
|
719
706
|
unless new_vmx_contents =~ /#{k} = /
|
720
707
|
new_vmx_contents << "#{k} = \"#{v}\"\n"
|
721
|
-
vmx_need_change_flag = true
|
722
708
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
723
709
|
message: "Custom vmx : Append #{k} = \"#{v}\"")
|
724
710
|
end
|
725
711
|
end
|
726
712
|
end
|
727
713
|
|
728
|
-
#
|
729
|
-
if
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
channel.send_data(new_vmx_contents)
|
742
|
-
channel.eof!
|
743
|
-
end
|
744
|
-
end
|
745
|
-
ssh.loop
|
746
|
-
else
|
747
|
-
if config.debug =~ %r{vmx}i
|
748
|
-
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
749
|
-
message: 'ESXi vmx file : Unmodified')
|
714
|
+
# update vmx on esxi
|
715
|
+
if config.debug =~ %r{vmx}i
|
716
|
+
puts "new vmx: #{new_vmx_contents}"
|
717
|
+
puts "\n\n"
|
718
|
+
end
|
719
|
+
r = ''
|
720
|
+
ssh.open_channel do |channel|
|
721
|
+
channel.exec("cat >#{dst_vmx_file}") do |ch, success|
|
722
|
+
raise Errors::ESXiError,
|
723
|
+
message: "Unable to update vmx file.\n"\
|
724
|
+
" #{r}" unless success
|
725
|
+
channel.send_data(new_vmx_contents)
|
726
|
+
channel.eof!
|
750
727
|
end
|
751
728
|
end
|
752
|
-
|
753
|
-
|
729
|
+
ssh.loop
|
754
730
|
|
755
731
|
# Done
|
756
732
|
end
|
@@ -39,7 +39,6 @@ module VagrantPlugins
|
|
39
39
|
" #{env[:machine_state]}")
|
40
40
|
|
41
41
|
if config.saved_ipaddress.nil? or config.local_use_ip_cache == 'False'
|
42
|
-
puts "Determine guest IP address." if config.debug =~ %r{ip}i
|
43
42
|
|
44
43
|
# Figure out vm_ipaddress
|
45
44
|
Net::SSH.start(config.esxi_hostname, config.esxi_username,
|
@@ -11,6 +11,7 @@ module VagrantPlugins
|
|
11
11
|
attr_accessor :esxi_disk_store
|
12
12
|
attr_accessor :esxi_virtual_network
|
13
13
|
attr_accessor :esxi_resource_pool
|
14
|
+
attr_accessor :clone_from_vm
|
14
15
|
attr_accessor :guest_username
|
15
16
|
attr_accessor :guest_name
|
16
17
|
attr_accessor :guest_name_prefix
|
@@ -66,6 +67,7 @@ module VagrantPlugins
|
|
66
67
|
@esxi_disk_store = nil
|
67
68
|
@esxi_virtual_network = nil
|
68
69
|
@esxi_resource_pool = nil
|
70
|
+
@clone_from_vm = nil
|
69
71
|
@guest_username = 'vagrant'
|
70
72
|
@guest_name = nil
|
71
73
|
@guest_name_prefix = 'V-'
|
@@ -152,13 +154,13 @@ module VagrantPlugins
|
|
152
154
|
'debian9-64',
|
153
155
|
'debian9',
|
154
156
|
'dos',
|
155
|
-
'
|
156
|
-
'
|
157
|
+
'ecomstation2',
|
158
|
+
'ecomstation',
|
157
159
|
'fedora-64',
|
158
160
|
'fedora',
|
159
161
|
'freebsd-64',
|
160
162
|
'freebsd',
|
161
|
-
'
|
163
|
+
'genericlinux',
|
162
164
|
'mandrake',
|
163
165
|
'mandriva-64',
|
164
166
|
'mandriva',
|
@@ -167,27 +169,27 @@ module VagrantPlugins
|
|
167
169
|
'netware6',
|
168
170
|
'nld9',
|
169
171
|
'oes',
|
170
|
-
'
|
171
|
-
'
|
172
|
+
'openserver5',
|
173
|
+
'openserver6',
|
172
174
|
'opensuse-64',
|
173
175
|
'opensuse',
|
174
|
-
'
|
175
|
-
'
|
176
|
-
'
|
177
|
-
'
|
178
|
-
'
|
179
|
-
'
|
176
|
+
'oraclelinux6-64',
|
177
|
+
'oraclelinux-64',
|
178
|
+
'oraclelinux6',
|
179
|
+
'oraclelinux7-64',
|
180
|
+
'oraclelinux7',
|
181
|
+
'oraclelinux',
|
180
182
|
'os2',
|
181
|
-
'
|
182
|
-
'
|
183
|
-
'
|
184
|
-
'
|
185
|
-
'
|
186
|
-
'
|
183
|
+
'other24xlinux-64',
|
184
|
+
'other24xlinux',
|
185
|
+
'other26xlinux-64',
|
186
|
+
'other26xlinux',
|
187
|
+
'other3xlinux-64',
|
188
|
+
'other3xlinux',
|
187
189
|
'other',
|
188
|
-
'
|
189
|
-
'
|
190
|
-
'
|
190
|
+
'otherguest-64',
|
191
|
+
'otherlinux-64',
|
192
|
+
'otherlinux',
|
191
193
|
'redhat',
|
192
194
|
'rhel2',
|
193
195
|
'rhel3-64',
|
@@ -218,49 +220,49 @@ module VagrantPlugins
|
|
218
220
|
'solaris9',
|
219
221
|
'suse-64',
|
220
222
|
'suse',
|
221
|
-
'
|
222
|
-
'
|
223
|
+
'turbolinux-64',
|
224
|
+
'turbolinux',
|
223
225
|
'ubuntu-64',
|
224
226
|
'ubuntu',
|
225
|
-
'
|
227
|
+
'unixware7',
|
226
228
|
'vmkernel5',
|
227
229
|
'vmkernel65',
|
228
230
|
'vmkernel6',
|
229
231
|
'vmkernel',
|
230
|
-
'
|
231
|
-
'
|
232
|
-
'
|
233
|
-
'
|
232
|
+
'vmwarephoton-64',
|
233
|
+
'win2000advserv',
|
234
|
+
'win2000pro',
|
235
|
+
'win2000serv',
|
234
236
|
'win31',
|
235
237
|
'win95',
|
236
238
|
'win98',
|
237
239
|
'windows7-64',
|
238
240
|
'windows7',
|
239
|
-
'
|
241
|
+
'windows7server-64',
|
240
242
|
'windows8-64',
|
241
243
|
'windows8',
|
242
|
-
'
|
244
|
+
'windows8server-64',
|
243
245
|
'windows9-64',
|
244
246
|
'windows9',
|
245
|
-
'
|
246
|
-
'
|
247
|
-
'
|
248
|
-
'
|
249
|
-
'
|
250
|
-
'
|
251
|
-
'
|
252
|
-
'
|
253
|
-
'
|
254
|
-
'
|
255
|
-
'
|
256
|
-
'
|
257
|
-
'
|
258
|
-
'
|
259
|
-
'
|
260
|
-
'
|
261
|
-
'
|
262
|
-
'
|
263
|
-
'
|
247
|
+
'windows9server-64',
|
248
|
+
'windowshyperv',
|
249
|
+
'winlonghorn-64',
|
250
|
+
'winlonghorn',
|
251
|
+
'winme',
|
252
|
+
'winnetbusiness',
|
253
|
+
'winnetdatacenter-64',
|
254
|
+
'winnetdatacenter',
|
255
|
+
'winnetenterprise-64',
|
256
|
+
'winnetenterprise',
|
257
|
+
'winnetstandard-64',
|
258
|
+
'winnetstandard',
|
259
|
+
'winnetweb',
|
260
|
+
'winnt',
|
261
|
+
'winvista-64',
|
262
|
+
'winvista',
|
263
|
+
'winxphome',
|
264
|
+
'winxppro-64',
|
265
|
+
'winxppro'
|
264
266
|
]
|
265
267
|
|
266
268
|
# Legacy (1.x)
|
data/vagrant-vmware-esxi.gemspec
CHANGED
@@ -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-
|
6
|
+
s.date = '2018-04-01'
|
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
|
4
|
+
version: 2.1.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-
|
11
|
+
date: 2018-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|