Class: VagrantPlugins::ESXi::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-vmware-esxi/config.rb

Overview

Config class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/vagrant-vmware-esxi/config.rb', line 63

def initialize
  @esxi_hostname = nil
  @esxi_hostport = 22
  @esxi_username = 'root'
  @esxi_password = ''
  @encoded_esxi_password = nil
  @esxi_disk_store = nil
  @esxi_virtual_network = nil
  @esxi_resource_pool = nil
  @clone_from_vm = nil
  @guest_username = 'vagrant'
  @guest_name = nil
  @guest_name_prefix = 'V-'
  @guest_guestos = nil
  @guest_disk_type = nil
  @guest_boot_disk_size = nil
  @guest_storage = nil
  @guest_nic_type = nil
  @guest_mac_address = ["","","",""]
  @guest_memsize = nil
  @guest_numvcpus = nil
  @guest_virtualhw_version = nil
  @guest_snapshot_includememory = 'False'
  @guest_snapshot_quiesced = 'False'
  @guest_custom_vmx_settings = nil
  @local_private_keys = nil
  @local_allow_overwrite = 'False'
  @local_lax = 'False'
  @local_use_ip_cache = 'True'
  @local_failonwarning = 'False'
  @debug = 'False'
  @saved_ipaddress = nil
  @supported_guest_virtualhw_versions = [
    4,7,8,9,10,11,12,13,14
  ]
  @supported_guest_disk_types = [
    'thin',
    'thick',
    'eagerzeroedthick'
  ]
  @supported_guest_nic_types = [
    'vlance',
    'flexible',
    'e1000',
    'e1000e',
    'vmxnet',
    'vmxnet2',
    'vmxnet3'
  ]
  @supported_guest_guestos = [
    'asianux3-64',
    'asianux3',
    'asianux4-64',
    'asianux4',
    'asianux5-64',
    'asianux7-64',
    'centos6-64',
    'centos-64',
    'centos6',
    'centos7-64',
    'centos7',
    'centos8-64',
    'centos',
    'coreos-64',
    'darwin10-64',
    'darwin10',
    'darwin11-64',
    'darwin11',
    'darwin12-64',
    'darwin13-64',
    'darwin14-64',
    'darwin15-64',
    'darwin16-64',
    'darwin17-64',
    'darwin18-64',
    'darwin19-64',
    'darwin-64',
    'darwin',
    'debian10-64',
    'debian10',
    'debian4-64',
    'debian4',
    'debian5-64',
    'debian5',
    'debian6-64',
    'debian6',
    'debian7-64',
    'debian7',
    'debian8-64',
    'debian8',
    'debian9-64',
    'debian9',
    'dos',
    'ecomstation2',
    'ecomstation',
    'fedora-64',
    'fedora',
    'freebsd-64',
    'freebsd',
    'freebsd11-64',
    'freebsd11',
    'freebsd12-64',
    'freebsd12',
    'genericlinux',
    'mandrake',
    'mandriva-64',
    'mandriva',
    'netware4',
    'netware5',
    'netware6',
    'nld9',
    'oes',
    'openserver5',
    'openserver6',
    'opensuse-64',
    'opensuse',
    'oraclelinux6-64',
    'oraclelinux-64',
    'oraclelinux6',
    'oraclelinux7-64',
    'oraclelinux7',
    'oraclelinux',
    'os2',
    'other24xlinux-64',
    'other24xlinux',
    'other26xlinux-64',
    'other26xlinux',
    'other3xlinux-64',
    'other3xlinux',
    'other',
    'otherguest-64',
    'otherlinux-64',
    'otherlinux',
    'redhat',
    'rhel2',
    'rhel3-64',
    'rhel3',
    'rhel4-64',
    'rhel4',
    'rhel5-64',
    'rhel5',
    'rhel6-64',
    'rhel6',
    'rhel7-64',
    'rhel7',
    'rhel8-64',
    'sjds',
    'sles10-64',
    'sles10',
    'sles11-64',
    'sles11',
    'sles12-64',
    'sles12',
    'sles-64',
    'sles',
    'solaris10-64',
    'solaris10',
    'solaris11-64',
    'solaris6',
    'solaris7',
    'solaris8',
    'solaris9',
    'suse-64',
    'suse',
    'turbolinux-64',
    'turbolinux',
    'ubuntu-64',
    'ubuntu',
    'unixware7',
    'vmkernel5',
    'vmkernel65',
    'vmkernel6',
    'vmkernel',
    'vmwarephoton-64',
    'win2000advserv',
    'win2000pro',
    'win2000serv',
    'win31',
    'win95',
    'win98',
    'windows7-64',
    'windows7',
    'windows7server-64',
    'windows8-64',
    'windows8',
    'windows8server-64',
    'windows9-64',
    'windows9',
    'windows9server-64',
    'windowshyperv',
    'winlonghorn-64',
    'winlonghorn',
    'winme',
    'winnetbusiness',
    'winnetdatacenter-64',
    'winnetdatacenter',
    'winnetenterprise-64',
    'winnetenterprise',
    'winnetstandard-64',
    'winnetstandard',
    'winnetweb',
    'winnt',
    'winvista-64',
    'winvista',
    'winxphome',
    'winxppro-64',
    'winxppro'
  ]

  # Legacy (1.x)
  @esxi_private_keys = nil
  @ssh_username = nil
  @vmname = nil
  @vmname_prefix = nil
  @guestos = nil
  @vm_disk_store = nil
  @vm_disk_type = nil
  @virtual_network = nil
  @nic_type = nil
  @mac_address = nil
  @resource_pool = nil
  @memsize = nil
  @numvcpus = nil
  @virtualhw_version = nil
  @custom_vmx_settings = nil
  @allow_overwrite = nil
  @lax = nil
end

Instance Attribute Details

#allow_overwriteObject

local_allow_overwrite



60
61
62
# File 'lib/vagrant-vmware-esxi/config.rb', line 60

def allow_overwrite
  @allow_overwrite
end

#clone_from_vmObject

Returns the value of attribute clone_from_vm.



15
16
17
# File 'lib/vagrant-vmware-esxi/config.rb', line 15

def clone_from_vm
  @clone_from_vm
end

#custom_vmx_settingsObject

guest_custom_vmx_settings



59
60
61
# File 'lib/vagrant-vmware-esxi/config.rb', line 59

def custom_vmx_settings
  @custom_vmx_settings
end

#debugObject

Returns the value of attribute debug.



36
37
38
# File 'lib/vagrant-vmware-esxi/config.rb', line 36

def debug
  @debug
end

#encoded_esxi_passwordObject

Returns the value of attribute encoded_esxi_password.



11
12
13
# File 'lib/vagrant-vmware-esxi/config.rb', line 11

def encoded_esxi_password
  @encoded_esxi_password
end

#esxi_disk_storeObject

Returns the value of attribute esxi_disk_store.



12
13
14
# File 'lib/vagrant-vmware-esxi/config.rb', line 12

def esxi_disk_store
  @esxi_disk_store
end

#esxi_hostnameObject

Returns the value of attribute esxi_hostname.



7
8
9
# File 'lib/vagrant-vmware-esxi/config.rb', line 7

def esxi_hostname
  @esxi_hostname
end

#esxi_hostportObject

Returns the value of attribute esxi_hostport.



8
9
10
# File 'lib/vagrant-vmware-esxi/config.rb', line 8

def esxi_hostport
  @esxi_hostport
end

#esxi_passwordObject

Returns the value of attribute esxi_password.



10
11
12
# File 'lib/vagrant-vmware-esxi/config.rb', line 10

def esxi_password
  @esxi_password
end

#esxi_private_keysObject

legacy (1.x) config entries



45
46
47
# File 'lib/vagrant-vmware-esxi/config.rb', line 45

def esxi_private_keys
  @esxi_private_keys
end

#esxi_resource_poolObject

Returns the value of attribute esxi_resource_pool.



14
15
16
# File 'lib/vagrant-vmware-esxi/config.rb', line 14

def esxi_resource_pool
  @esxi_resource_pool
end

#esxi_usernameObject

Returns the value of attribute esxi_username.



9
10
11
# File 'lib/vagrant-vmware-esxi/config.rb', line 9

def esxi_username
  @esxi_username
end

#esxi_virtual_networkObject

Returns the value of attribute esxi_virtual_network.



13
14
15
# File 'lib/vagrant-vmware-esxi/config.rb', line 13

def esxi_virtual_network
  @esxi_virtual_network
end

#guest_boot_disk_sizeObject

Returns the value of attribute guest_boot_disk_size.



21
22
23
# File 'lib/vagrant-vmware-esxi/config.rb', line 21

def guest_boot_disk_size
  @guest_boot_disk_size
end

#guest_custom_vmx_settingsObject

Returns the value of attribute guest_custom_vmx_settings.



30
31
32
# File 'lib/vagrant-vmware-esxi/config.rb', line 30

def guest_custom_vmx_settings
  @guest_custom_vmx_settings
end

#guest_disk_typeObject

Returns the value of attribute guest_disk_type.



20
21
22
# File 'lib/vagrant-vmware-esxi/config.rb', line 20

def guest_disk_type
  @guest_disk_type
end

#guest_guestosObject

Returns the value of attribute guest_guestos.



19
20
21
# File 'lib/vagrant-vmware-esxi/config.rb', line 19

def guest_guestos
  @guest_guestos
end

#guest_mac_addressObject

Returns the value of attribute guest_mac_address.



24
25
26
# File 'lib/vagrant-vmware-esxi/config.rb', line 24

def guest_mac_address
  @guest_mac_address
end

#guest_memsizeObject

Returns the value of attribute guest_memsize.



25
26
27
# File 'lib/vagrant-vmware-esxi/config.rb', line 25

def guest_memsize
  @guest_memsize
end

#guest_nameObject

Returns the value of attribute guest_name.



17
18
19
# File 'lib/vagrant-vmware-esxi/config.rb', line 17

def guest_name
  @guest_name
end

#guest_name_prefixObject

Returns the value of attribute guest_name_prefix.



18
19
20
# File 'lib/vagrant-vmware-esxi/config.rb', line 18

def guest_name_prefix
  @guest_name_prefix
end

#guest_nic_typeObject

Returns the value of attribute guest_nic_type.



23
24
25
# File 'lib/vagrant-vmware-esxi/config.rb', line 23

def guest_nic_type
  @guest_nic_type
end

#guest_numvcpusObject

Returns the value of attribute guest_numvcpus.



26
27
28
# File 'lib/vagrant-vmware-esxi/config.rb', line 26

def guest_numvcpus
  @guest_numvcpus
end

#guest_snapshot_includememoryObject

Returns the value of attribute guest_snapshot_includememory.



28
29
30
# File 'lib/vagrant-vmware-esxi/config.rb', line 28

def guest_snapshot_includememory
  @guest_snapshot_includememory
end

#guest_snapshot_quiescedObject

Returns the value of attribute guest_snapshot_quiesced.



29
30
31
# File 'lib/vagrant-vmware-esxi/config.rb', line 29

def guest_snapshot_quiesced
  @guest_snapshot_quiesced
end

#guest_storageObject

Returns the value of attribute guest_storage.



22
23
24
# File 'lib/vagrant-vmware-esxi/config.rb', line 22

def guest_storage
  @guest_storage
end

#guest_usernameObject

Returns the value of attribute guest_username.



16
17
18
# File 'lib/vagrant-vmware-esxi/config.rb', line 16

def guest_username
  @guest_username
end

#guest_virtualhw_versionObject

Returns the value of attribute guest_virtualhw_version.



27
28
29
# File 'lib/vagrant-vmware-esxi/config.rb', line 27

def guest_virtualhw_version
  @guest_virtualhw_version
end

#guestosObject

guest_guestos



49
50
51
# File 'lib/vagrant-vmware-esxi/config.rb', line 49

def guestos
  @guestos
end

#laxObject

local_lax



61
62
63
# File 'lib/vagrant-vmware-esxi/config.rb', line 61

def lax
  @lax
end

#local_allow_overwriteObject

Returns the value of attribute local_allow_overwrite.



32
33
34
# File 'lib/vagrant-vmware-esxi/config.rb', line 32

def local_allow_overwrite
  @local_allow_overwrite
end

#local_failonwarningObject

Returns the value of attribute local_failonwarning.



35
36
37
# File 'lib/vagrant-vmware-esxi/config.rb', line 35

def local_failonwarning
  @local_failonwarning
end

#local_laxObject

Returns the value of attribute local_lax.



33
34
35
# File 'lib/vagrant-vmware-esxi/config.rb', line 33

def local_lax
  @local_lax
end

#local_private_keysObject

Returns the value of attribute local_private_keys.



31
32
33
# File 'lib/vagrant-vmware-esxi/config.rb', line 31

def local_private_keys
  @local_private_keys
end

#local_use_ip_cacheObject

Returns the value of attribute local_use_ip_cache.



34
35
36
# File 'lib/vagrant-vmware-esxi/config.rb', line 34

def local_use_ip_cache
  @local_use_ip_cache
end

#mac_addressObject

guest_mac_address



54
55
56
# File 'lib/vagrant-vmware-esxi/config.rb', line 54

def mac_address
  @mac_address
end

#memsizeObject

guest_memsize



56
57
58
# File 'lib/vagrant-vmware-esxi/config.rb', line 56

def memsize
  @memsize
end

#nic_typeObject

guest_nic_type



53
54
55
# File 'lib/vagrant-vmware-esxi/config.rb', line 53

def nic_type
  @nic_type
end

#numvcpusObject

guest_numvcpus



57
58
59
# File 'lib/vagrant-vmware-esxi/config.rb', line 57

def numvcpus
  @numvcpus
end

#resource_poolObject

esxi_resource_pool



55
56
57
# File 'lib/vagrant-vmware-esxi/config.rb', line 55

def resource_pool
  @resource_pool
end

#saved_ipaddressObject

Returns the value of attribute saved_ipaddress.



41
42
43
# File 'lib/vagrant-vmware-esxi/config.rb', line 41

def saved_ipaddress
  @saved_ipaddress
end

#ssh_usernameObject

guest_username



46
47
48
# File 'lib/vagrant-vmware-esxi/config.rb', line 46

def ssh_username
  @ssh_username
end

#supported_guest_disk_typesObject

Returns the value of attribute supported_guest_disk_types.



38
39
40
# File 'lib/vagrant-vmware-esxi/config.rb', line 38

def supported_guest_disk_types
  @supported_guest_disk_types
end

#supported_guest_guestosObject

Returns the value of attribute supported_guest_guestos.



40
41
42
# File 'lib/vagrant-vmware-esxi/config.rb', line 40

def supported_guest_guestos
  @supported_guest_guestos
end

#supported_guest_nic_typesObject

Returns the value of attribute supported_guest_nic_types.



39
40
41
# File 'lib/vagrant-vmware-esxi/config.rb', line 39

def supported_guest_nic_types
  @supported_guest_nic_types
end

#supported_guest_virtualhw_versionsObject

Returns the value of attribute supported_guest_virtualhw_versions.



37
38
39
# File 'lib/vagrant-vmware-esxi/config.rb', line 37

def supported_guest_virtualhw_versions
  @supported_guest_virtualhw_versions
end

#virtual_networkObject

esxi_virtual_network



52
53
54
# File 'lib/vagrant-vmware-esxi/config.rb', line 52

def virtual_network
  @virtual_network
end

#virtualhw_versionObject

guest_virtualhw_version



58
59
60
# File 'lib/vagrant-vmware-esxi/config.rb', line 58

def virtualhw_version
  @virtualhw_version
end

#vm_disk_storeObject

esxi_disk_store



50
51
52
# File 'lib/vagrant-vmware-esxi/config.rb', line 50

def vm_disk_store
  @vm_disk_store
end

#vm_disk_typeObject

guest_disk_type



51
52
53
# File 'lib/vagrant-vmware-esxi/config.rb', line 51

def vm_disk_type
  @vm_disk_type
end

#vmnameObject

guest_name



47
48
49
# File 'lib/vagrant-vmware-esxi/config.rb', line 47

def vmname
  @vmname
end

#vmname_prefixObject

guest_name_prefix



48
49
50
# File 'lib/vagrant-vmware-esxi/config.rb', line 48

def vmname_prefix
  @vmname_prefix
end

Instance Method Details

#finalize!Object



292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# File 'lib/vagrant-vmware-esxi/config.rb', line 292

def finalize!

  #  Migrate legacy(1.x) parms to 2.0
  migrate_msg = ""
  unless @esxi_private_keys.nil?
    migrate_msg << "You should migrate legacy option esxi_private_keys to esxi_password = \"key:\" in Vagrant file.\n"
  end
  unless @ssh_username.nil?
    migrate_msg << "You should migrate legacy option ssh_username to guest_username in Vagrant file.\n"
    @guest_username = @ssh_username.dup
  end
  unless @vmname.nil?
    migrate_msg << "You should migrate legacy option vmname to guest_name in Vagrant file.\n"
    @guest_name = @vmname.dup
  end
  unless @vmname_prefix.nil?
    migrate_msg << "You should migrate legacy option vmname_prefix to guest_name_prefix in Vagrant file.\n"
    @guest_name_prefix = @vmname_prefix.dup
  end
  unless @guestos.nil?
    migrate_msg << "You should migrate legacy option guestos to guest_guestos in Vagrant file.\n"
    @guest_guestos = @guestos.dup
  end
  unless @vm_disk_store.nil?
    migrate_msg << "You should migrate legacy option vm_disk_store to esxi_disk_store in Vagrant file.\n"
    @esxi_disk_store = @vm_disk_store.dup
  end
  unless @vm_disk_type.nil?
    migrate_msg << "You should migrate legacy option vm_disk_type to guest_disk_type in Vagrant file.\n"
    @guest_disk_type = @vm_disk_type.dup
  end
  unless @virtual_network.nil?
    migrate_msg << "You should migrate legacy option virtual_network to esxi_virtual_network in Vagrant file.\n"
    @esxi_virtual_network = @virtual_network.dup
  end
  unless @nic_type.nil?
    migrate_msg << "You should migrate legacy option nic_type to guest_nic_type in Vagrant file.\n"
    @guest_nic_type = @nic_type.dup
  end
  unless @mac_address.nil?
    migrate_msg << "You should migrate legacy option mac_address to guest_mac_address in Vagrant file.\n"
    @guest_mac_address = @mac_address.dup
  end
  unless @resource_pool.nil?
    migrate_msg << "You should migrate legacy option resource_pool to esxi_resource_pool in Vagrant file.\n"
    @esxi_resource_pool = @resource_pool.dup
  end
  unless @memsize.nil?
    migrate_msg << "You should migrate legacy option memsize to guest_memsize in Vagrant file.\n"
    @guest_memsize = @memsize.dup
  end
  unless @numvcpus.nil?
    migrate_msg << "You should migrate legacy option numvcpus to guest_numvcpus in Vagrant file.\n"
    @guest_numvcpus = @numvcpus.dup
  end
  unless @virtualhw_version.nil?
    migrate_msg << "You should migrate legacy option virtualhw_version to guest_virtualhw_version in Vagrant file.\n"
    @guest_virtualhw_version = @virtualhw_version.dup
  end
  unless @custom_vmx_settings.nil?
    migrate_msg << "You should migrate legacy option custom_vmx_settings to guest_custom_vmx_settings in Vagrant file.\n"
    @guest_custom_vmx_settings = @custom_vmx_settings.dup
  end
  unless @allow_overwrite.nil?
    migrate_msg << "You should migrate legacy option allow_overwrite to local_allow_overwrite in Vagrant file.\n"
    @local_allow_overwrite = @allow_overwrite.dup
  end
  unless @lax.nil?
    migrate_msg << "You should migrate legacy option lax to local_lax in Vagrant file.\n"
    @local_lax = @lax.dup
  end

  if $migrate_msg_flag.nil?
    $migrate_msg_flag = 'True'
    puts migrate_msg
  end

  @guest_username = nil if @guest_username == UNSET_VALUE
  @encoded_esxi_password = nil

  @guest_boot_disk_size = @guest_boot_disk_size.to_i if @guest_boot_disk_size.is_a? String
  @guest_boot_disk_size = nil if @guest_boot_disk_size == 0
  @guest_storage = [@guest_storage.to_i] if @guest_storage.is_a? String
  @guest_storage = [@guest_storage] if @guest_storage.is_a? Integer
  @guest_storage = [{ size: @guest_storage[:size], datastore: @guest_storage[:datastore] }] if @guest_storage.is_a? Hash

  @esxi_virtual_network = [@esxi_virtual_network] if @esxi_virtual_network.is_a? String

  @esxi_virtual_network = ['--NotSet--'] if @esxi_virtual_network.nil?

  @local_private_keys = [
    '~/.ssh/id_rsa',
    '~/.ssh/id_ecdsa',
    '~/.ssh/id_dsa'
  ]
  #'~/.ssh/id_ed25519',
  # Removed support for ed25519 because libsodium is not compatible with windows.
  # Should be added back when net-ssh 5.0 is out of beta.

  if @local_lax =~ /true/i
    @local_lax = 'True'
  else
    @local_lax = 'False'
  end

  if @local_use_ip_cache =~ /false/i
    @local_use_ip_cache = 'False'
  else
    @local_use_ip_cache = 'True'
  end

  if @local_failonwarning =~ /true/i
    @local_failonwarning = 'True'
  else
    @local_failonwarning = 'False'
  end

  if @guest_snapshot_includememory =~ /true/i
    @guest_snapshot_includememory = 'includeMemory'
  else
    @guest_snapshot_includememory = ''
 end
 if @guest_snapshot_quiesced =~ /true/i
   @guest_snapshot_quiesced = 'quiesced'
 else
   @guest_snapshot_quiesced = ''
 end
 @saved_ipaddress = nil

end