vagrant-libvirt 0.0.36 → 0.0.37
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/.coveralls.yml +1 -0
- data/Gemfile +1 -0
- data/README.md +171 -13
- data/lib/vagrant-libvirt/action/create_domain.rb +44 -19
- data/lib/vagrant-libvirt/action/create_domain_volume.rb +12 -12
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +37 -39
- data/lib/vagrant-libvirt/action/create_networks.rb +34 -34
- data/lib/vagrant-libvirt/action/destroy_domain.rb +7 -8
- data/lib/vagrant-libvirt/action/destroy_networks.rb +12 -13
- data/lib/vagrant-libvirt/action/forward_ports.rb +21 -23
- data/lib/vagrant-libvirt/action/halt_domain.rb +8 -9
- data/lib/vagrant-libvirt/action/handle_box_image.rb +28 -27
- data/lib/vagrant-libvirt/action/handle_storage_pool.rb +8 -8
- data/lib/vagrant-libvirt/action/is_created.rb +1 -1
- data/lib/vagrant-libvirt/action/is_running.rb +2 -2
- data/lib/vagrant-libvirt/action/is_suspended.rb +4 -4
- data/lib/vagrant-libvirt/action/message_already_created.rb +2 -2
- data/lib/vagrant-libvirt/action/message_not_created.rb +2 -2
- data/lib/vagrant-libvirt/action/message_not_running.rb +2 -2
- data/lib/vagrant-libvirt/action/message_not_suspended.rb +2 -2
- data/lib/vagrant-libvirt/action/package_domain.rb +6 -5
- data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +7 -6
- data/lib/vagrant-libvirt/action/prepare_nfs_valid_ids.rb +2 -2
- data/lib/vagrant-libvirt/action/prune_nfs_exports.rb +3 -3
- data/lib/vagrant-libvirt/action/read_mac_addresses.rb +8 -10
- data/lib/vagrant-libvirt/action/remove_libvirt_image.rb +4 -4
- data/lib/vagrant-libvirt/action/remove_stale_volume.rb +8 -7
- data/lib/vagrant-libvirt/action/resume_domain.rb +5 -5
- data/lib/vagrant-libvirt/action/set_boot_order.rb +70 -27
- data/lib/vagrant-libvirt/action/set_name_of_domain.rb +10 -12
- data/lib/vagrant-libvirt/action/share_folders.rb +16 -18
- data/lib/vagrant-libvirt/action/start_domain.rb +59 -64
- data/lib/vagrant-libvirt/action/suspend_domain.rb +5 -5
- data/lib/vagrant-libvirt/action/wait_till_up.rb +24 -26
- data/lib/vagrant-libvirt/action.rb +18 -23
- data/lib/vagrant-libvirt/cap/mount_p9.rb +11 -10
- data/lib/vagrant-libvirt/cap/nic_mac_addresses.rb +1 -1
- data/lib/vagrant-libvirt/cap/synced_folder.rb +20 -19
- data/lib/vagrant-libvirt/config.rb +164 -136
- data/lib/vagrant-libvirt/driver.rb +10 -13
- data/lib/vagrant-libvirt/errors.rb +4 -3
- data/lib/vagrant-libvirt/plugin.rb +4 -6
- data/lib/vagrant-libvirt/provider.rb +23 -24
- data/lib/vagrant-libvirt/templates/domain.xml.erb +14 -1
- data/lib/vagrant-libvirt/templates/private_network.xml.erb +4 -0
- data/lib/vagrant-libvirt/util/collection.rb +0 -3
- data/lib/vagrant-libvirt/util/erb_template.rb +6 -10
- data/lib/vagrant-libvirt/util/error_codes.rb +32 -33
- data/lib/vagrant-libvirt/util/network_util.rb +29 -21
- data/lib/vagrant-libvirt/util.rb +3 -4
- data/lib/vagrant-libvirt/version.rb +1 -1
- data/locales/en.yml +3 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/environment_helper.rb +5 -7
- data/spec/support/libvirt_context.rb +13 -11
- data/spec/support/sharedcontext.rb +9 -10
- data/spec/unit/action/destroy_domain_spec.rb +38 -37
- data/spec/unit/action/set_name_of_domain_spec.rb +4 -4
- data/spec/unit/action/wait_till_up_spec.rb +45 -46
- data/spec/unit/config_spec.rb +106 -0
- data/spec/unit/templates/domain_all_settings.xml +125 -0
- data/spec/unit/templates/domain_defaults.xml +44 -0
- data/spec/unit/templates/domain_spec.rb +69 -0
- data/tools/create_box.sh +8 -2
- metadata +12 -3
@@ -3,9 +3,10 @@ require 'vagrant'
|
|
3
3
|
class Numeric
|
4
4
|
Alphabet = ('a'..'z').to_a
|
5
5
|
def vdev
|
6
|
-
s
|
6
|
+
s = ''
|
7
|
+
q = self
|
7
8
|
(q, r = (q - 1).divmod(26)) && s.prepend(Alphabet[r]) until q.zero?
|
8
|
-
'vd'+s
|
9
|
+
'vd' + s
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
@@ -49,6 +50,7 @@ module VagrantPlugins
|
|
49
50
|
attr_accessor :management_network_mode
|
50
51
|
attr_accessor :management_network_mac
|
51
52
|
attr_accessor :management_network_guest_ipv6
|
53
|
+
attr_accessor :management_network_autostart
|
52
54
|
|
53
55
|
# Default host prefix (alternative to use project folder name)
|
54
56
|
attr_accessor :default_prefix
|
@@ -117,12 +119,19 @@ module VagrantPlugins
|
|
117
119
|
# USB device passthrough
|
118
120
|
attr_accessor :usbs
|
119
121
|
|
122
|
+
# Redirected devices
|
123
|
+
attr_accessor :redirdevs
|
124
|
+
attr_accessor :redirfilters
|
125
|
+
|
120
126
|
# Suspend mode
|
121
127
|
attr_accessor :suspend_mode
|
122
128
|
|
123
129
|
# Autostart
|
124
130
|
attr_accessor :autostart
|
125
131
|
|
132
|
+
# Attach mgmt network
|
133
|
+
attr_accessor :mgmt_attach
|
134
|
+
|
126
135
|
def initialize
|
127
136
|
@uri = UNSET_VALUE
|
128
137
|
@driver = UNSET_VALUE
|
@@ -137,7 +146,8 @@ module VagrantPlugins
|
|
137
146
|
@management_network_address = UNSET_VALUE
|
138
147
|
@management_network_mode = UNSET_VALUE
|
139
148
|
@management_network_mac = UNSET_VALUE
|
140
|
-
@management_network_guest_ipv6
|
149
|
+
@management_network_guest_ipv6 = UNSET_VALUE
|
150
|
+
@management_network_autostart = UNSET_VALUE
|
141
151
|
|
142
152
|
# Domain specific settings.
|
143
153
|
@uuid = UNSET_VALUE
|
@@ -193,41 +203,46 @@ module VagrantPlugins
|
|
193
203
|
@pcis = UNSET_VALUE
|
194
204
|
|
195
205
|
# Random number device passthrough
|
196
|
-
@rng
|
206
|
+
@rng = UNSET_VALUE
|
197
207
|
|
198
208
|
# USB device passthrough
|
199
209
|
@usbs = UNSET_VALUE
|
200
210
|
|
211
|
+
# Redirected devices
|
212
|
+
@redirdevs = UNSET_VALUE
|
213
|
+
@redirfilters = UNSET_VALUE
|
214
|
+
|
201
215
|
# Suspend mode
|
202
216
|
@suspend_mode = UNSET_VALUE
|
203
217
|
|
204
218
|
# Autostart
|
205
219
|
@autostart = UNSET_VALUE
|
220
|
+
|
221
|
+
# Attach mgmt network
|
222
|
+
@mgmt_attach = UNSET_VALUE
|
206
223
|
end
|
207
224
|
|
208
225
|
def boot(device)
|
209
|
-
@boot_order << device
|
226
|
+
@boot_order << device # append
|
210
227
|
end
|
211
228
|
|
212
229
|
def _get_device(disks)
|
213
230
|
# skip existing devices and also the first one (vda)
|
214
|
-
exist = disks.collect {|x| x[:device]}+[1.vdev.to_s]
|
215
|
-
skip = 1
|
216
|
-
|
217
|
-
dev = skip.vdev
|
218
|
-
|
219
|
-
|
220
|
-
end
|
221
|
-
skip+=1
|
231
|
+
exist = disks.collect { |x| x[:device] } + [1.vdev.to_s]
|
232
|
+
skip = 1 # we're 1 based, not 0 based...
|
233
|
+
loop do
|
234
|
+
dev = skip.vdev # get lettered device
|
235
|
+
return dev unless exist.include?(dev)
|
236
|
+
skip += 1
|
222
237
|
end
|
223
238
|
end
|
224
239
|
|
225
240
|
def _get_cdrom_dev(cdroms)
|
226
|
-
exist = Hash[cdroms.collect{|x| [x[:dev],true]}]
|
241
|
+
exist = Hash[cdroms.collect { |x| [x[:dev], true] }]
|
227
242
|
# hda - hdc
|
228
|
-
curr =
|
229
|
-
while curr <=
|
230
|
-
dev =
|
243
|
+
curr = 'a'.ord
|
244
|
+
while curr <= 'd'.ord
|
245
|
+
dev = 'hd' + curr.chr
|
231
246
|
if exist[dev]
|
232
247
|
curr += 1
|
233
248
|
next
|
@@ -241,9 +256,7 @@ module VagrantPlugins
|
|
241
256
|
end
|
242
257
|
|
243
258
|
def _generate_numa
|
244
|
-
if @cpus % @numa_nodes != 0
|
245
|
-
raise 'NUMA nodes must be a factor of CPUs'
|
246
|
-
end
|
259
|
+
raise 'NUMA nodes must be a factor of CPUs' if @cpus % @numa_nodes != 0
|
247
260
|
|
248
261
|
if @memory % @numa_nodes != 0
|
249
262
|
raise 'NUMA nodes must be a factor of memory'
|
@@ -257,120 +270,116 @@ module VagrantPlugins
|
|
257
270
|
numa_cpu = Array(numa_cpu_start..numa_cpu_end).join(',')
|
258
271
|
numa_mem = @memory / @numa_nodes
|
259
272
|
|
260
|
-
numa.push(
|
261
|
-
|
262
|
-
|
263
|
-
mem: numa_mem
|
264
|
-
})
|
273
|
+
numa.push(id: node,
|
274
|
+
cpu: numa_cpu,
|
275
|
+
mem: numa_mem)
|
265
276
|
end
|
266
277
|
|
267
278
|
@numa_nodes = numa
|
268
279
|
end
|
269
280
|
|
270
|
-
def cpu_feature(options={})
|
281
|
+
def cpu_feature(options = {})
|
271
282
|
if options[:name].nil? || options[:policy].nil?
|
272
283
|
raise 'CPU Feature name AND policy must be specified'
|
273
284
|
end
|
274
285
|
|
275
|
-
if @cpu_features == UNSET_VALUE
|
276
|
-
@cpu_features = []
|
277
|
-
end
|
286
|
+
@cpu_features = [] if @cpu_features == UNSET_VALUE
|
278
287
|
|
279
|
-
@cpu_features.push(
|
280
|
-
|
281
|
-
policy: options[:policy]
|
282
|
-
})
|
288
|
+
@cpu_features.push(name: options[:name],
|
289
|
+
policy: options[:policy])
|
283
290
|
end
|
284
291
|
|
285
|
-
def input(options={})
|
292
|
+
def input(options = {})
|
286
293
|
if options[:type].nil? || options[:bus].nil?
|
287
294
|
raise 'Input type AND bus must be specified'
|
288
295
|
end
|
289
296
|
|
290
|
-
if @inputs == UNSET_VALUE
|
291
|
-
@inputs = []
|
292
|
-
end
|
297
|
+
@inputs = [] if @inputs == UNSET_VALUE
|
293
298
|
|
294
|
-
@inputs.push(
|
295
|
-
|
296
|
-
bus: options[:bus]
|
297
|
-
})
|
299
|
+
@inputs.push(type: options[:type],
|
300
|
+
bus: options[:bus])
|
298
301
|
end
|
299
302
|
|
300
|
-
def channel(options={})
|
303
|
+
def channel(options = {})
|
301
304
|
if options[:type].nil?
|
302
|
-
|
305
|
+
raise 'Channel type must be specified.'
|
303
306
|
elsif options[:type] == 'unix' && options[:target_type] == 'guestfwd'
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
307
|
+
# Guest forwarding requires a target (ip address) and a port
|
308
|
+
if options[:target_address].nil? || options[:target_port].nil? ||
|
309
|
+
options[:source_path].nil?
|
310
|
+
raise 'guestfwd requires target_address, target_port and source_path'
|
311
|
+
end
|
309
312
|
end
|
310
313
|
|
311
|
-
if @channels == UNSET_VALUE
|
312
|
-
@channels = []
|
313
|
-
end
|
314
|
+
@channels = [] if @channels == UNSET_VALUE
|
314
315
|
|
315
|
-
@channels.push(
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
target_type: options[:target_type]
|
323
|
-
})
|
316
|
+
@channels.push(type: options[:type],
|
317
|
+
source_mode: options[:source_mode],
|
318
|
+
source_path: options[:source_path],
|
319
|
+
target_address: options[:target_address],
|
320
|
+
target_name: options[:target_name],
|
321
|
+
target_port: options[:target_port],
|
322
|
+
target_type: options[:target_type])
|
324
323
|
end
|
325
324
|
|
326
|
-
def random(options={})
|
327
|
-
if !options[:model].nil? && options[:model] !=
|
325
|
+
def random(options = {})
|
326
|
+
if !options[:model].nil? && options[:model] != 'random'
|
328
327
|
raise 'The only supported rng backend is "random".'
|
329
328
|
end
|
330
329
|
|
331
|
-
if @rng == UNSET_VALUE
|
332
|
-
@rng = {}
|
333
|
-
end
|
330
|
+
@rng = {} if @rng == UNSET_VALUE
|
334
331
|
|
335
332
|
@rng[:model] = options[:model]
|
336
333
|
end
|
337
334
|
|
338
|
-
def pci(options={})
|
335
|
+
def pci(options = {})
|
339
336
|
if options[:bus].nil? || options[:slot].nil? || options[:function].nil?
|
340
337
|
raise 'Bus AND slot AND function must be specified. Check `lspci` for that numbers.'
|
341
338
|
end
|
342
339
|
|
343
|
-
if @pcis == UNSET_VALUE
|
344
|
-
@pcis = []
|
345
|
-
end
|
340
|
+
@pcis = [] if @pcis == UNSET_VALUE
|
346
341
|
|
347
|
-
@pcis.push(
|
348
|
-
|
349
|
-
|
350
|
-
function: options[:function]
|
351
|
-
})
|
342
|
+
@pcis.push(bus: options[:bus],
|
343
|
+
slot: options[:slot],
|
344
|
+
function: options[:function])
|
352
345
|
end
|
353
346
|
|
354
|
-
def usb(options={})
|
347
|
+
def usb(options = {})
|
355
348
|
if (options[:bus].nil? || options[:device].nil?) && options[:vendor].nil? && options[:product].nil?
|
356
349
|
raise 'Bus and device and/or vendor and/or product must be specified. Check `lsusb` for these.'
|
357
350
|
end
|
358
351
|
|
359
|
-
if @usbs == UNSET_VALUE
|
360
|
-
|
361
|
-
|
352
|
+
@usbs = [] if @usbs == UNSET_VALUE
|
353
|
+
|
354
|
+
@usbs.push(bus: options[:bus],
|
355
|
+
device: options[:device],
|
356
|
+
vendor: options[:vendor],
|
357
|
+
product: options[:product],
|
358
|
+
startupPolicy: options[:startupPolicy])
|
359
|
+
end
|
360
|
+
|
361
|
+
def redirdev(options = {})
|
362
|
+
raise 'Type must be specified.' if options[:type].nil?
|
363
|
+
|
364
|
+
@redirdevs = [] if @redirdevs == UNSET_VALUE
|
362
365
|
|
363
|
-
@
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
366
|
+
@redirdevs.push(type: options[:type])
|
367
|
+
end
|
368
|
+
|
369
|
+
def redirfilter(options = {})
|
370
|
+
raise 'Option allow must be specified.' if options[:allow].nil?
|
371
|
+
|
372
|
+
@redirfilters = [] if @redirfilters == UNSET_VALUE
|
373
|
+
|
374
|
+
@redirfilters.push(class: options[:class] || -1,
|
375
|
+
vendor: options[:class] || -1,
|
376
|
+
product: options[:class] || -1,
|
377
|
+
version: options[:class] || -1,
|
378
|
+
allow: options[:allow])
|
370
379
|
end
|
371
380
|
|
372
381
|
# NOTE: this will run twice for each time it's needed- keep it idempotent
|
373
|
-
def storage(storage_type, options={})
|
382
|
+
def storage(storage_type, options = {})
|
374
383
|
if storage_type == :file
|
375
384
|
if options[:device] == :cdrom
|
376
385
|
_handle_cdrom_storage(options)
|
@@ -380,7 +389,7 @@ module VagrantPlugins
|
|
380
389
|
end
|
381
390
|
end
|
382
391
|
|
383
|
-
def _handle_cdrom_storage(options={})
|
392
|
+
def _handle_cdrom_storage(options = {})
|
384
393
|
# <disk type="file" device="cdrom">
|
385
394
|
# <source file="/home/user/virtio-win-0.1-100.iso"/>
|
386
395
|
# <target dev="hdc"/>
|
@@ -392,41 +401,39 @@ module VagrantPlugins
|
|
392
401
|
# as will the address unit number (unit=0, unit=1, etc)
|
393
402
|
|
394
403
|
options = {
|
395
|
-
:
|
396
|
-
:
|
397
|
-
:path => nil,
|
404
|
+
bus: 'ide',
|
405
|
+
path: nil
|
398
406
|
}.merge(options)
|
399
407
|
|
400
408
|
cdrom = {
|
401
|
-
:
|
402
|
-
:
|
403
|
-
:
|
409
|
+
dev: options[:dev],
|
410
|
+
bus: options[:bus],
|
411
|
+
path: options[:path]
|
404
412
|
}
|
405
413
|
|
406
414
|
@cdroms << cdrom
|
407
415
|
end
|
408
416
|
|
409
|
-
def _handle_disk_storage(options={})
|
417
|
+
def _handle_disk_storage(options = {})
|
410
418
|
options = {
|
411
|
-
:
|
412
|
-
:
|
413
|
-
:
|
414
|
-
:
|
415
|
-
:bus => 'virtio'
|
419
|
+
type: 'qcow2',
|
420
|
+
size: '10G', # matches the fog default
|
421
|
+
path: nil,
|
422
|
+
bus: 'virtio'
|
416
423
|
}.merge(options)
|
417
424
|
|
418
425
|
disk = {
|
419
|
-
:
|
420
|
-
:
|
421
|
-
:
|
422
|
-
:
|
423
|
-
:
|
424
|
-
:
|
425
|
-
:
|
426
|
-
:
|
426
|
+
device: options[:device],
|
427
|
+
type: options[:type],
|
428
|
+
size: options[:size],
|
429
|
+
path: options[:path],
|
430
|
+
bus: options[:bus],
|
431
|
+
cache: options[:cache] || 'default',
|
432
|
+
allow_existing: options[:allow_existing],
|
433
|
+
shareable: options[:shareable]
|
427
434
|
}
|
428
435
|
|
429
|
-
@disks << disk
|
436
|
+
@disks << disk # append
|
430
437
|
end
|
431
438
|
|
432
439
|
# code to generate URI from a config moved out of the connect action
|
@@ -435,30 +442,28 @@ module VagrantPlugins
|
|
435
442
|
# Setup connection uri.
|
436
443
|
uri = @driver.dup
|
437
444
|
virt_path = case uri
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
445
|
+
when 'qemu', 'openvz', 'uml', 'phyp', 'parallels', 'kvm'
|
446
|
+
'/system'
|
447
|
+
when '@en', 'esx'
|
448
|
+
'/'
|
449
|
+
when 'vbox', 'vmwarews', 'hyperv'
|
450
|
+
'/session'
|
451
|
+
else
|
452
|
+
raise "Require specify driver #{uri}"
|
446
453
|
end
|
447
454
|
if uri == 'kvm'
|
448
|
-
uri = 'qemu'
|
455
|
+
uri = 'qemu' # use qemu uri for kvm domain type
|
449
456
|
end
|
450
457
|
|
451
458
|
if @connect_via_ssh
|
452
459
|
uri << '+ssh://'
|
453
|
-
if @username
|
454
|
-
uri << @username + '@'
|
455
|
-
end
|
460
|
+
uri << @username + '@' if @username
|
456
461
|
|
457
|
-
if @host
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
+
uri << if @host
|
463
|
+
@host
|
464
|
+
else
|
465
|
+
'localhost'
|
466
|
+
end
|
462
467
|
else
|
463
468
|
uri << '://'
|
464
469
|
uri << @host if @host
|
@@ -475,8 +480,8 @@ module VagrantPlugins
|
|
475
480
|
uri << @id_ssh_key_file
|
476
481
|
end
|
477
482
|
# set path to libvirt socket
|
478
|
-
uri << "\&socket="
|
479
|
-
|
483
|
+
uri << "\&socket=" + @socket if @socket
|
484
|
+
uri
|
480
485
|
end
|
481
486
|
|
482
487
|
def finalize!
|
@@ -493,19 +498,24 @@ module VagrantPlugins
|
|
493
498
|
@management_network_mode = 'nat' if @management_network_mode == UNSET_VALUE
|
494
499
|
@management_network_mac = nil if @management_network_mac == UNSET_VALUE
|
495
500
|
@management_network_guest_ipv6 = 'yes' if @management_network_guest_ipv6 == UNSET_VALUE
|
501
|
+
@management_network_autostart = false if @management_network_autostart == UNSET_VALUE
|
496
502
|
|
497
503
|
# generate a URI if none is supplied
|
498
|
-
@uri = _generate_uri
|
504
|
+
@uri = _generate_uri if @uri == UNSET_VALUE
|
499
505
|
|
500
506
|
# Domain specific settings.
|
501
507
|
@uuid = '' if @uuid == UNSET_VALUE
|
502
508
|
@memory = 512 if @memory == UNSET_VALUE
|
503
509
|
@cpus = 1 if @cpus == UNSET_VALUE
|
504
510
|
@cpu_mode = 'host-model' if @cpu_mode == UNSET_VALUE
|
505
|
-
@cpu_model =
|
511
|
+
@cpu_model = if (@cpu_model == UNSET_VALUE) && (@cpu_mode == 'custom')
|
512
|
+
'qemu64'
|
513
|
+
elsif @cpu_mode != 'custom'
|
514
|
+
''
|
515
|
+
end
|
506
516
|
@cpu_fallback = 'allow' if @cpu_fallback == UNSET_VALUE
|
507
517
|
@cpu_features = [] if @cpu_features == UNSET_VALUE
|
508
|
-
@numa_nodes = @numa_nodes == UNSET_VALUE ? nil : _generate_numa
|
518
|
+
@numa_nodes = @numa_nodes == UNSET_VALUE ? nil : _generate_numa
|
509
519
|
@loader = nil if @loader == UNSET_VALUE
|
510
520
|
@machine_type = nil if @machine_type == UNSET_VALUE
|
511
521
|
@machine_arch = nil if @machine_arch == UNSET_VALUE
|
@@ -522,7 +532,7 @@ module VagrantPlugins
|
|
522
532
|
@graphics_autoport = 'yes' if @graphics_port == UNSET_VALUE
|
523
533
|
@graphics_autoport = 'no' if @graphics_port != UNSET_VALUE
|
524
534
|
if (@graphics_type != 'vnc' && @graphics_type != 'spice') ||
|
525
|
-
|
535
|
+
@graphics_passwd == UNSET_VALUE
|
526
536
|
@graphics_passwd = nil
|
527
537
|
end
|
528
538
|
@graphics_port = 5900 if @graphics_port == UNSET_VALUE
|
@@ -542,13 +552,21 @@ module VagrantPlugins
|
|
542
552
|
|
543
553
|
# Storage
|
544
554
|
@disks = [] if @disks == UNSET_VALUE
|
555
|
+
@disks.map! do |disk|
|
556
|
+
disk[:device] = _get_device(@disks) if disk[:device].nil?
|
557
|
+
disk
|
558
|
+
end
|
545
559
|
@cdroms = [] if @cdroms == UNSET_VALUE
|
560
|
+
@cdroms.map! do |cdrom|
|
561
|
+
cdrom[:dev] = _get_cdrom_dev(@cdroms) if cdrom[:dev].nil?
|
562
|
+
cdrom
|
563
|
+
end
|
546
564
|
|
547
565
|
# Inputs
|
548
|
-
@inputs = [{:
|
566
|
+
@inputs = [{ type: 'mouse', bus: 'ps2' }] if @inputs == UNSET_VALUE
|
549
567
|
|
550
568
|
# Channels
|
551
|
-
@channels = [
|
569
|
+
@channels = [] if @channels == UNSET_VALUE
|
552
570
|
|
553
571
|
# PCI device passthrough
|
554
572
|
@pcis = [] if @pcis == UNSET_VALUE
|
@@ -559,18 +577,25 @@ module VagrantPlugins
|
|
559
577
|
# USB device passthrough
|
560
578
|
@usbs = [] if @usbs == UNSET_VALUE
|
561
579
|
|
580
|
+
# Redirected devices
|
581
|
+
@redirdevs = [] if @redirdevs == UNSET_VALUE
|
582
|
+
@redirfilters = [] if @redirfilters == UNSET_VALUE
|
583
|
+
|
562
584
|
# Suspend mode
|
563
|
-
@suspend_mode =
|
585
|
+
@suspend_mode = 'pause' if @suspend_mode == UNSET_VALUE
|
564
586
|
|
565
587
|
# Autostart
|
566
588
|
@autostart = false if @autostart == UNSET_VALUE
|
589
|
+
|
590
|
+
# Attach mgmt network
|
591
|
+
@mgmt_attach = true if @mgmt_attach == UNSET_VALUE
|
567
592
|
end
|
568
593
|
|
569
594
|
def validate(machine)
|
570
595
|
errors = _detected_errors
|
571
596
|
|
572
597
|
machine.provider_config.disks.each do |disk|
|
573
|
-
if disk[:path]
|
598
|
+
if disk[:path] && (disk[:path][0] == '/')
|
574
599
|
errors << "absolute volume paths like '#{disk[:path]}' not yet supported"
|
575
600
|
end
|
576
601
|
end
|
@@ -581,7 +606,7 @@ module VagrantPlugins
|
|
581
606
|
end
|
582
607
|
end
|
583
608
|
|
584
|
-
|
609
|
+
{ 'Libvirt Provider' => errors }
|
585
610
|
end
|
586
611
|
|
587
612
|
def merge(other)
|
@@ -589,6 +614,9 @@ module VagrantPlugins
|
|
589
614
|
c = disks.dup
|
590
615
|
c += other.disks
|
591
616
|
result.disks = c
|
617
|
+
c = cdroms.dup
|
618
|
+
c += other.cdroms
|
619
|
+
result.cdroms = c
|
592
620
|
end
|
593
621
|
end
|
594
622
|
end
|
@@ -4,7 +4,6 @@ require 'log4r'
|
|
4
4
|
module VagrantPlugins
|
5
5
|
module ProviderLibvirt
|
6
6
|
class Driver
|
7
|
-
|
8
7
|
# store the connection at the process level
|
9
8
|
#
|
10
9
|
# possibly this should be a connection pool using the connection
|
@@ -34,7 +33,7 @@ module VagrantPlugins
|
|
34
33
|
|
35
34
|
# Setup command for retrieving IP address for newly created machine
|
36
35
|
# with some MAC address. Get it from dnsmasq leases table
|
37
|
-
ip_command = %q
|
36
|
+
ip_command = %q( awk "/$mac/ {print \$1}" /proc/net/arp )
|
38
37
|
conn_attr[:libvirt_ip_command] = ip_command
|
39
38
|
|
40
39
|
@logger.info("Connecting to Libvirt (#{uri}) ...")
|
@@ -42,7 +41,7 @@ module VagrantPlugins
|
|
42
41
|
@@connection = Fog::Compute.new(conn_attr)
|
43
42
|
rescue Fog::Errors::Error => e
|
44
43
|
raise Errors::FogLibvirtConnectionError,
|
45
|
-
|
44
|
+
error_message: e.message
|
46
45
|
end
|
47
46
|
|
48
47
|
@@connection
|
@@ -81,19 +80,19 @@ module VagrantPlugins
|
|
81
80
|
ip_address = nil
|
82
81
|
begin
|
83
82
|
domain.wait_for(2) do
|
84
|
-
addresses.each_pair do |
|
83
|
+
addresses.each_pair do |_type, ip|
|
85
84
|
# Multiple leases are separated with a newline, return only
|
86
85
|
# the most recent address
|
87
|
-
ip_address = ip[0].split("\n").first
|
86
|
+
ip_address = ip[0].split("\n").first unless ip[0].nil?
|
88
87
|
end
|
89
|
-
ip_address
|
88
|
+
!ip_address.nil?
|
90
89
|
end
|
91
90
|
rescue Fog::Errors::TimeoutError
|
92
|
-
@logger.info(
|
91
|
+
@logger.info('Timeout at waiting for an ip address for machine %s' % machine.name)
|
93
92
|
end
|
94
93
|
|
95
|
-
|
96
|
-
@logger.info(
|
94
|
+
unless ip_address
|
95
|
+
@logger.info('No arp table entry found for machine %s' % machine.name)
|
97
96
|
return nil
|
98
97
|
end
|
99
98
|
|
@@ -110,11 +109,9 @@ module VagrantPlugins
|
|
110
109
|
end
|
111
110
|
|
112
111
|
# TODO: terminated no longer appears to be a valid fog state, remove?
|
113
|
-
if domain.nil? || domain.state.to_sym == :terminated
|
114
|
-
return :not_created
|
115
|
-
end
|
112
|
+
return :not_created if domain.nil? || domain.state.to_sym == :terminated
|
116
113
|
|
117
|
-
|
114
|
+
domain.state.tr('-', '_').to_sym
|
118
115
|
end
|
119
116
|
end
|
120
117
|
end
|
@@ -33,7 +33,6 @@ module VagrantPlugins
|
|
33
33
|
error_key(:image_upload_error)
|
34
34
|
end
|
35
35
|
|
36
|
-
|
37
36
|
# Box exceptions
|
38
37
|
class NoBoxVolume < VagrantLibvirtError
|
39
38
|
error_key(:no_box_volume)
|
@@ -51,7 +50,6 @@ module VagrantPlugins
|
|
51
50
|
error_key(:wrong_box_format)
|
52
51
|
end
|
53
52
|
|
54
|
-
|
55
53
|
# Fog libvirt exceptions
|
56
54
|
class FogError < VagrantLibvirtError
|
57
55
|
error_key(:fog_error)
|
@@ -110,6 +108,10 @@ module VagrantPlugins
|
|
110
108
|
error_key(:tunnel_port_not_defined)
|
111
109
|
end
|
112
110
|
|
111
|
+
class ManagementNetworkRequired < VagrantLibvirtError
|
112
|
+
error_key(:management_network_required)
|
113
|
+
end
|
114
|
+
|
113
115
|
# Other exceptions
|
114
116
|
class InterfaceSlotNotAvailable < VagrantLibvirtError
|
115
117
|
error_key(:interface_slot_not_available)
|
@@ -142,7 +144,6 @@ module VagrantPlugins
|
|
142
144
|
class DeleteSnapshotError < VagrantLibvirtError
|
143
145
|
error_key(:delete_snapshot_error)
|
144
146
|
end
|
145
|
-
|
146
147
|
end
|
147
148
|
end
|
148
149
|
end
|
@@ -29,21 +29,20 @@ module VagrantPlugins
|
|
29
29
|
hook.after Vagrant::Action::Builtin::BoxRemove, Action.remove_libvirt_image
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
32
|
guest_capability('linux', 'mount_p9_shared_folder') do
|
34
33
|
require_relative 'cap/mount_p9'
|
35
34
|
Cap::MountP9
|
36
35
|
end
|
37
36
|
|
38
37
|
provider_capability(:libvirt, :nic_mac_addresses) do
|
39
|
-
require_relative
|
38
|
+
require_relative 'cap/nic_mac_addresses'
|
40
39
|
Cap::NicMacAddresses
|
41
40
|
end
|
42
41
|
|
43
42
|
# lower priority than nfs or rsync
|
44
43
|
# https://github.com/vagrant-libvirt/vagrant-libvirt/pull/170
|
45
|
-
synced_folder(
|
46
|
-
require_relative
|
44
|
+
synced_folder('9p', 4) do
|
45
|
+
require_relative 'cap/synced_folder'
|
47
46
|
VagrantPlugins::SyncedFolder9p::SyncedFolder
|
48
47
|
end
|
49
48
|
|
@@ -71,7 +70,7 @@ module VagrantPlugins
|
|
71
70
|
# Some constants, such as "true" resolve to booleans, so the
|
72
71
|
# above error checking doesn't catch it. This will check to make
|
73
72
|
# sure that the log level is an integer, as Log4r requires.
|
74
|
-
level = nil
|
73
|
+
level = nil unless level.is_a?(Integer)
|
75
74
|
|
76
75
|
# Set the logging level on all "vagrant" namespaced
|
77
76
|
# logs as long as we have a valid level.
|
@@ -88,7 +87,6 @@ module VagrantPlugins
|
|
88
87
|
# from the parent logger.
|
89
88
|
setup_logging
|
90
89
|
setup_i18n
|
91
|
-
|
92
90
|
end
|
93
91
|
end
|
94
92
|
end
|