vagrant-libvirt 0.1.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +530 -100
- data/lib/vagrant-libvirt/action.rb +7 -1
- data/lib/vagrant-libvirt/action/clean_machine_folder.rb +28 -0
- data/lib/vagrant-libvirt/action/create_domain.rb +78 -22
- data/lib/vagrant-libvirt/action/create_domain_volume.rb +57 -57
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +1 -3
- data/lib/vagrant-libvirt/action/create_networks.rb +11 -4
- data/lib/vagrant-libvirt/action/destroy_domain.rb +1 -1
- data/lib/vagrant-libvirt/action/forward_ports.rb +40 -40
- data/lib/vagrant-libvirt/action/halt_domain.rb +25 -9
- data/lib/vagrant-libvirt/action/handle_box_image.rb +163 -72
- data/lib/vagrant-libvirt/action/is_running.rb +1 -3
- data/lib/vagrant-libvirt/action/is_suspended.rb +4 -4
- data/lib/vagrant-libvirt/action/package_domain.rb +10 -4
- data/lib/vagrant-libvirt/action/start_domain.rb +86 -29
- data/lib/vagrant-libvirt/action/wait_till_up.rb +8 -52
- data/lib/vagrant-libvirt/cap/{mount_p9.rb → mount_9p.rb} +2 -2
- data/lib/vagrant-libvirt/cap/mount_virtiofs.rb +37 -0
- data/lib/vagrant-libvirt/cap/public_address.rb +16 -0
- data/lib/vagrant-libvirt/cap/{synced_folder.rb → synced_folder_9p.rb} +4 -5
- data/lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb +109 -0
- data/lib/vagrant-libvirt/config.rb +257 -34
- data/lib/vagrant-libvirt/driver.rb +49 -32
- data/lib/vagrant-libvirt/errors.rb +24 -1
- data/lib/vagrant-libvirt/plugin.rb +19 -5
- data/lib/vagrant-libvirt/provider.rb +2 -9
- data/lib/vagrant-libvirt/templates/domain.xml.erb +40 -10
- data/lib/vagrant-libvirt/templates/private_network.xml.erb +1 -1
- data/lib/vagrant-libvirt/templates/public_interface.xml.erb +5 -1
- data/lib/vagrant-libvirt/util.rb +1 -0
- data/lib/vagrant-libvirt/util/erb_template.rb +6 -7
- data/lib/vagrant-libvirt/util/network_util.rb +21 -3
- data/lib/vagrant-libvirt/util/ui.rb +23 -0
- data/lib/vagrant-libvirt/version +1 -0
- data/lib/vagrant-libvirt/version.rb +72 -1
- data/locales/en.yml +12 -0
- data/spec/spec_helper.rb +37 -3
- data/spec/support/binding_proc.rb +24 -0
- data/spec/support/libvirt_context.rb +3 -1
- data/spec/support/matchers/have_file_content.rb +63 -0
- data/spec/support/sharedcontext.rb +7 -3
- data/spec/unit/action/clean_machine_folder_spec.rb +48 -0
- data/spec/unit/action/create_domain_spec.rb +166 -0
- data/spec/unit/action/create_domain_spec/default_system_storage_pool.xml +17 -0
- data/spec/unit/action/create_domain_spec/default_user_storage_pool.xml +17 -0
- data/spec/unit/action/create_domain_volume_spec.rb +102 -0
- data/spec/unit/action/create_domain_volume_spec/one_disk_in_storage.xml +21 -0
- data/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_0.xml +21 -0
- data/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_1.xml +21 -0
- data/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_2.xml +21 -0
- data/spec/unit/action/destroy_domain_spec.rb +3 -3
- data/spec/unit/action/forward_ports_spec.rb +202 -0
- data/spec/unit/action/halt_domain_spec.rb +90 -0
- data/spec/unit/action/handle_box_image_spec.rb +363 -0
- data/spec/unit/action/set_name_of_domain_spec.rb +2 -2
- data/spec/unit/action/start_domain_spec.rb +231 -0
- data/spec/unit/action/start_domain_spec/clock_timer_rtc.xml +50 -0
- data/spec/unit/action/start_domain_spec/default.xml +48 -0
- data/spec/unit/action/start_domain_spec/default_added_tpm_path.xml +48 -0
- data/spec/unit/action/start_domain_spec/default_added_tpm_version.xml +48 -0
- data/spec/unit/action/wait_till_up_spec.rb +22 -21
- data/spec/unit/config_spec.rb +438 -0
- data/spec/unit/provider_spec.rb +11 -0
- data/spec/unit/templates/domain_all_settings.xml +16 -3
- data/spec/unit/templates/domain_custom_cpu_model.xml +4 -1
- data/spec/unit/templates/domain_defaults.xml +4 -1
- data/spec/unit/templates/domain_spec.rb +102 -3
- data/spec/unit/templates/tpm/version_1.2.xml +54 -0
- data/spec/unit/templates/tpm/version_2.0.xml +53 -0
- metadata +108 -16
- data/lib/vagrant-libvirt/action/halt_confirm.rb +0 -20
@@ -49,6 +49,7 @@ module VagrantPlugins
|
|
49
49
|
|
50
50
|
b2.use StartDomain
|
51
51
|
b2.use WaitTillUp
|
52
|
+
b2.use WaitForCommunicator, [:running]
|
52
53
|
|
53
54
|
b2.use ForwardPorts
|
54
55
|
b2.use SetHostname
|
@@ -107,6 +108,7 @@ module VagrantPlugins
|
|
107
108
|
# Machine should gain IP address when comming up,
|
108
109
|
# so wait for dhcp lease and store IP into machines data_dir.
|
109
110
|
b3.use WaitTillUp
|
111
|
+
b3.use WaitForCommunicator, [:running]
|
110
112
|
|
111
113
|
b3.use ForwardPorts
|
112
114
|
b3.use PrepareNFSSettings
|
@@ -179,6 +181,7 @@ module VagrantPlugins
|
|
179
181
|
# Try to remove stale volumes anyway
|
180
182
|
b2.use SetNameOfDomain
|
181
183
|
b2.use RemoveStaleVolume if env[:machine].config.vm.box
|
184
|
+
b2.use CleanMachineFolder, quiet: true
|
182
185
|
b2.use MessageNotCreated unless env[:result]
|
183
186
|
|
184
187
|
next
|
@@ -186,11 +189,12 @@ module VagrantPlugins
|
|
186
189
|
|
187
190
|
b2.use Call, DestroyConfirm do |env2, b3|
|
188
191
|
if env2[:result]
|
192
|
+
b3.use ProvisionerCleanup, :before
|
189
193
|
b3.use ClearForwardedPorts
|
190
194
|
b3.use PruneNFSExports
|
191
195
|
b3.use DestroyDomain
|
192
196
|
b3.use DestroyNetworks
|
193
|
-
b3.use
|
197
|
+
b3.use CleanMachineFolder
|
194
198
|
else
|
195
199
|
b3.use MessageWillNotDestroy
|
196
200
|
end
|
@@ -324,6 +328,7 @@ module VagrantPlugins
|
|
324
328
|
autoload :CreateDomainVolume, action_root.join('create_domain_volume')
|
325
329
|
autoload :CreateNetworkInterfaces, action_root.join('create_network_interfaces')
|
326
330
|
autoload :CreateNetworks, action_root.join('create_networks')
|
331
|
+
autoload :CleanMachineFolder, action_root.join('clean_machine_folder')
|
327
332
|
autoload :DestroyDomain, action_root.join('destroy_domain')
|
328
333
|
autoload :DestroyNetworks, action_root.join('destroy_networks')
|
329
334
|
autoload :ForwardPorts, action_root.join('forward_ports')
|
@@ -366,6 +371,7 @@ module VagrantPlugins
|
|
366
371
|
autoload :SyncedFolders, 'vagrant/action/builtin/synced_folders'
|
367
372
|
autoload :SyncedFolderCleanup, 'vagrant/action/builtin/synced_folder_cleanup'
|
368
373
|
autoload :ProvisionerCleanup, 'vagrant/action/builtin/provisioner_cleanup'
|
374
|
+
autoload :WaitForCommunicator, 'vagrant/action/builtin/wait_for_communicator'
|
369
375
|
end
|
370
376
|
end
|
371
377
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ProviderLibvirt
|
5
|
+
module Action
|
6
|
+
class CleanMachineFolder
|
7
|
+
|
8
|
+
def initialize(app, env, options=nil)
|
9
|
+
@logger = Log4r::Logger.new('vagrant_libvirt::action::create_domain')
|
10
|
+
@app = app
|
11
|
+
@ui = env[:ui]
|
12
|
+
@quiet = (options || {}).fetch(:quiet, false)
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(env)
|
16
|
+
machine_folder = env[:machine].data_dir
|
17
|
+
|
18
|
+
@ui.info("Deleting the machine folder") unless @quiet
|
19
|
+
|
20
|
+
@logger.debug("Recursively removing: #{machine_folder}")
|
21
|
+
FileUtils.rm_rf(machine_folder, :secure => true)
|
22
|
+
|
23
|
+
@app.call(env)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -5,6 +5,7 @@ module VagrantPlugins
|
|
5
5
|
module Action
|
6
6
|
class CreateDomain
|
7
7
|
include VagrantPlugins::ProviderLibvirt::Util::ErbTemplate
|
8
|
+
include VagrantPlugins::ProviderLibvirt::Util::StorageUtil
|
8
9
|
|
9
10
|
def initialize(app, _env)
|
10
11
|
@logger = Log4r::Logger.new('vagrant_libvirt::action::create_domain')
|
@@ -31,6 +32,8 @@ module VagrantPlugins
|
|
31
32
|
|
32
33
|
# Gather some info about domain
|
33
34
|
@name = env[:domain_name]
|
35
|
+
@title = config.title
|
36
|
+
@description = config.description
|
34
37
|
@uuid = config.uuid
|
35
38
|
@cpus = config.cpus.to_i
|
36
39
|
@cpuset = config.cpuset
|
@@ -39,6 +42,8 @@ module VagrantPlugins
|
|
39
42
|
@nodeset = config.nodeset
|
40
43
|
@features = config.features
|
41
44
|
@features_hyperv = config.features_hyperv
|
45
|
+
@clock_offset = config.clock_offset
|
46
|
+
@clock_timers = config.clock_timers
|
42
47
|
@shares = config.shares
|
43
48
|
@cpu_mode = config.cpu_mode
|
44
49
|
@cpu_model = config.cpu_model
|
@@ -50,11 +55,12 @@ module VagrantPlugins
|
|
50
55
|
@machine_arch = config.machine_arch
|
51
56
|
@disk_bus = config.disk_bus
|
52
57
|
@disk_device = config.disk_device
|
58
|
+
@disk_driver_opts = config.disk_driver_opts
|
53
59
|
@nested = config.nested
|
54
60
|
@memory_size = config.memory.to_i * 1024
|
55
61
|
@memory_backing = config.memory_backing
|
56
62
|
@management_network_mac = config.management_network_mac
|
57
|
-
@domain_volume_cache = config.volume_cache
|
63
|
+
@domain_volume_cache = config.volume_cache || 'default'
|
58
64
|
@kernel = config.kernel
|
59
65
|
@cmd_line = config.cmd_line
|
60
66
|
@emulator_path = config.emulator_path
|
@@ -78,6 +84,7 @@ module VagrantPlugins
|
|
78
84
|
@tpm_model = config.tpm_model
|
79
85
|
@tpm_type = config.tpm_type
|
80
86
|
@tpm_path = config.tpm_path
|
87
|
+
@tpm_version = config.tpm_version
|
81
88
|
|
82
89
|
# Boot order
|
83
90
|
@boot_order = config.boot_order
|
@@ -85,6 +92,7 @@ module VagrantPlugins
|
|
85
92
|
# Storage
|
86
93
|
@storage_pool_name = config.storage_pool_name
|
87
94
|
@snapshot_pool_name = config.snapshot_pool_name
|
95
|
+
@domain_volumes = []
|
88
96
|
@disks = config.disks
|
89
97
|
@cdroms = config.cdroms
|
90
98
|
|
@@ -134,26 +142,30 @@ module VagrantPlugins
|
|
134
142
|
else
|
135
143
|
pool_name = @storage_pool_name
|
136
144
|
end
|
137
|
-
@logger.debug "Search for
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
145
|
+
@logger.debug "Search for volumes in pool: #{pool_name}"
|
146
|
+
env[:box_volumes].each_index do |index|
|
147
|
+
suffix_index = index > 0 ? "_#{index}" : ''
|
148
|
+
domain_volume = env[:machine].provider.driver.connection.volumes.all(
|
149
|
+
name: "#{@name}#{suffix_index}.img"
|
150
|
+
).find { |x| x.pool_name == pool_name }
|
151
|
+
raise Errors::DomainVolumeExists if domain_volume.nil?
|
152
|
+
@domain_volumes.push({
|
153
|
+
:dev => (index+1).vdev.to_s,
|
154
|
+
:cache => @domain_volume_cache,
|
155
|
+
:bus => @disk_bus,
|
156
|
+
:path => domain_volume.path,
|
157
|
+
:virtual_size => env[:box_volumes][index][:virtual_size]
|
158
|
+
})
|
159
|
+
end
|
143
160
|
end
|
144
161
|
|
145
162
|
# If we have a box, take the path from the domain volume and set our storage_prefix.
|
146
163
|
# If not, we dump the storage pool xml to get its defined path.
|
147
164
|
# the default storage prefix is typically: /var/lib/libvirt/images/
|
148
|
-
if
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
storage_pool = env[:machine].provider.driver.connection.client.lookup_storage_pool_by_name(@storage_pool_name)
|
153
|
-
raise Errors::NoStoragePool if storage_pool.nil?
|
154
|
-
xml = Nokogiri::XML(storage_pool.xml_desc)
|
155
|
-
storage_prefix = xml.xpath('/pool/target/path').inner_text.to_s + '/'
|
156
|
-
end
|
165
|
+
if env[:machine].config.vm.box
|
166
|
+
storage_prefix = File.dirname(@domain_volumes[0][:path]) + '/' # steal
|
167
|
+
else
|
168
|
+
storage_prefix = get_disk_storage_prefix(env, @storage_pool_name)
|
157
169
|
end
|
158
170
|
|
159
171
|
@disks.each do |disk|
|
@@ -167,6 +179,16 @@ module VagrantPlugins
|
|
167
179
|
|
168
180
|
disk[:absolute_path] = storage_prefix + disk[:path]
|
169
181
|
|
182
|
+
if not disk[:pool].nil?
|
183
|
+
disk_pool_name = disk[:pool]
|
184
|
+
@logger.debug "Overriding pool name with: #{disk_pool_name}"
|
185
|
+
disk_storage_prefix = get_disk_storage_prefix(env, disk_pool_name)
|
186
|
+
disk[:absolute_path] = disk_storage_prefix + disk[:path]
|
187
|
+
@logger.debug "Overriding disk path with: #{disk[:absolute_path]}"
|
188
|
+
else
|
189
|
+
disk_pool_name = @storage_pool_name
|
190
|
+
end
|
191
|
+
|
170
192
|
# make the disk. equivalent to:
|
171
193
|
# qemu-img create -f qcow2 <path> 5g
|
172
194
|
begin
|
@@ -175,8 +197,10 @@ module VagrantPlugins
|
|
175
197
|
format_type: disk[:type],
|
176
198
|
path: disk[:absolute_path],
|
177
199
|
capacity: disk[:size],
|
200
|
+
owner: storage_uid(env),
|
201
|
+
group: storage_gid(env),
|
178
202
|
#:allocation => ?,
|
179
|
-
pool_name:
|
203
|
+
pool_name: disk_pool_name
|
180
204
|
)
|
181
205
|
rescue Libvirt::Error => e
|
182
206
|
# It is hard to believe that e contains just a string
|
@@ -186,7 +210,7 @@ module VagrantPlugins
|
|
186
210
|
if e.message == msg and disk[:allow_existing]
|
187
211
|
disk[:preexisting] = true
|
188
212
|
else
|
189
|
-
raise Errors::
|
213
|
+
raise Errors::FogCreateDomainVolumeError,
|
190
214
|
error_message: e.message
|
191
215
|
end
|
192
216
|
end
|
@@ -195,6 +219,8 @@ module VagrantPlugins
|
|
195
219
|
# Output the settings we're going to use to the user
|
196
220
|
env[:ui].info(I18n.t('vagrant_libvirt.creating_domain'))
|
197
221
|
env[:ui].info(" -- Name: #{@name}")
|
222
|
+
env[:ui].info(" -- Title: #{@title}") if @title != ''
|
223
|
+
env[:ui].info(" -- Description: #{@description}") if @description != ''
|
198
224
|
env[:ui].info(" -- Forced UUID: #{@uuid}") if @uuid != ''
|
199
225
|
env[:ui].info(" -- Domain type: #{@domain_type}")
|
200
226
|
env[:ui].info(" -- Cpus: #{@cpus}")
|
@@ -211,7 +237,15 @@ module VagrantPlugins
|
|
211
237
|
env[:ui].info(" -- Feature: #{feature}")
|
212
238
|
end
|
213
239
|
@features_hyperv.each do |feature|
|
214
|
-
|
240
|
+
if feature[:name] == 'spinlocks'
|
241
|
+
env[:ui].info(" -- Feature (HyperV): name=#{feature[:name]}, state=#{feature[:state]}, retries=#{feature[:retries]}")
|
242
|
+
else
|
243
|
+
env[:ui].info(" -- Feature (HyperV): name=#{feature[:name]}, state=#{feature[:state]}")
|
244
|
+
end
|
245
|
+
end
|
246
|
+
env[:ui].info(" -- Clock offset: #{@clock_offset}")
|
247
|
+
@clock_timers.each do |timer|
|
248
|
+
env[:ui].info(" -- Clock timer: #{timer.map { |k,v| "#{k}=#{v}"}.join(', ')}")
|
215
249
|
end
|
216
250
|
env[:ui].info(" -- Memory: #{@memory_size / 1024}M")
|
217
251
|
unless @nodeset.nil?
|
@@ -230,8 +264,16 @@ module VagrantPlugins
|
|
230
264
|
env[:ui].info(" -- Base box: #{env[:machine].box.name}")
|
231
265
|
end
|
232
266
|
env[:ui].info(" -- Storage pool: #{@storage_pool_name}")
|
233
|
-
|
234
|
-
|
267
|
+
@domain_volumes.each do |volume|
|
268
|
+
env[:ui].info(" -- Image(#{volume[:device]}): #{volume[:path]}, #{volume[:virtual_size]}G")
|
269
|
+
end
|
270
|
+
|
271
|
+
if not @disk_driver_opts.empty?
|
272
|
+
env[:ui].info(" -- Disk driver opts: #{@disk_driver_opts.reject { |k,v| v.nil? }.map { |k,v| "#{k}='#{v}'"}.join(' ')}")
|
273
|
+
else
|
274
|
+
env[:ui].info(" -- Disk driver opts: cache='#{@domain_volume_cache}'")
|
275
|
+
end
|
276
|
+
|
235
277
|
env[:ui].info(" -- Kernel: #{@kernel}")
|
236
278
|
env[:ui].info(" -- Initrd: #{@initrd}")
|
237
279
|
env[:ui].info(" -- Graphics Type: #{@graphics_type}")
|
@@ -242,7 +284,13 @@ module VagrantPlugins
|
|
242
284
|
env[:ui].info(" -- Video VRAM: #{@video_vram}")
|
243
285
|
env[:ui].info(" -- Sound Type: #{@sound_type}")
|
244
286
|
env[:ui].info(" -- Keymap: #{@keymap}")
|
245
|
-
env[:ui].info(" -- TPM
|
287
|
+
env[:ui].info(" -- TPM Backend: #{@tpm_type}")
|
288
|
+
if @tpm_type == 'emulator'
|
289
|
+
env[:ui].info(" -- TPM Model: #{@tpm_model}")
|
290
|
+
env[:ui].info(" -- TPM Version: #{@tpm_version}")
|
291
|
+
else
|
292
|
+
env[:ui].info(" -- TPM Path: #{@tpm_path}")
|
293
|
+
end
|
246
294
|
|
247
295
|
@boot_order.each do |device|
|
248
296
|
env[:ui].info(" -- Boot device: #{device}")
|
@@ -362,6 +410,14 @@ module VagrantPlugins
|
|
362
410
|
|
363
411
|
@app.call(env)
|
364
412
|
end
|
413
|
+
|
414
|
+
private
|
415
|
+
def get_disk_storage_prefix(env, disk_pool_name)
|
416
|
+
disk_storage_pool = env[:machine].provider.driver.connection.client.lookup_storage_pool_by_name(disk_pool_name)
|
417
|
+
raise Errors::NoStoragePool if disk_storage_pool.nil?
|
418
|
+
xml = Nokogiri::XML(disk_storage_pool.xml_desc)
|
419
|
+
disk_storage_prefix = xml.xpath('/pool/target/path').inner_text.to_s + '/'
|
420
|
+
end
|
365
421
|
end
|
366
422
|
end
|
367
423
|
end
|
@@ -18,74 +18,74 @@ module VagrantPlugins
|
|
18
18
|
def call(env)
|
19
19
|
env[:ui].info(I18n.t('vagrant_libvirt.creating_domain_volume'))
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
env[:box_volumes].each_index do |index|
|
22
|
+
suffix_index = index > 0 ? "_#{index}" : ''
|
23
|
+
# Get config options.
|
24
|
+
config = env[:machine].provider_config
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
+
# This is name of newly created image for vm.
|
27
|
+
@name = "#{env[:domain_name]}#{suffix_index}.img"
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
# Verify the volume doesn't exist already.
|
30
|
+
domain_volume = env[:machine].provider.driver.connection.volumes.all(
|
31
|
+
name: @name
|
32
|
+
).first
|
33
|
+
raise Errors::DomainVolumeExists if domain_volume && domain_volume.id
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
# Get path to backing image - box volume.
|
36
|
+
box_volume = env[:machine].provider.driver.connection.volumes.all(
|
37
|
+
name: env[:box_volumes][index][:name]
|
38
|
+
).first
|
39
|
+
@backing_file = box_volume.path
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
+
# Virtual size of image. Take value worked out by HandleBoxImage
|
42
|
+
@capacity = env[:box_volumes][index][:virtual_size] # G
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
44
|
+
# Create new volume from xml template. Fog currently doesn't support
|
45
|
+
# volume snapshots directly.
|
46
|
+
begin
|
47
|
+
xml = Nokogiri::XML::Builder.new do |xml|
|
48
|
+
xml.volume do
|
49
|
+
xml.name(@name)
|
50
|
+
xml.capacity(@capacity, unit: 'G')
|
51
|
+
xml.target do
|
52
|
+
xml.format(type: 'qcow2')
|
53
|
+
xml.permissions do
|
54
|
+
xml.owner storage_uid(env)
|
55
|
+
xml.group storage_gid(env)
|
56
|
+
xml.label 'virt_image_t'
|
57
|
+
end
|
56
58
|
end
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
xml.label 'virt_image_t'
|
59
|
+
xml.backingStore do
|
60
|
+
xml.path(@backing_file)
|
61
|
+
xml.format(type: 'qcow2')
|
62
|
+
xml.permissions do
|
63
|
+
xml.owner storage_uid(env)
|
64
|
+
xml.group storage_gid(env)
|
65
|
+
xml.label 'virt_image_t'
|
66
|
+
end
|
66
67
|
end
|
67
68
|
end
|
69
|
+
end.to_xml(
|
70
|
+
save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION |
|
71
|
+
Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS |
|
72
|
+
Nokogiri::XML::Node::SaveOptions::FORMAT
|
73
|
+
)
|
74
|
+
if config.snapshot_pool_name != config.storage_pool_name
|
75
|
+
pool_name = config.snapshot_pool_name
|
76
|
+
else
|
77
|
+
pool_name = config.storage_pool_name
|
68
78
|
end
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
pool_name = config.storage_pool_name
|
79
|
+
@logger.debug "Using pool #{pool_name} for base box snapshot"
|
80
|
+
domain_volume = env[:machine].provider.driver.connection.volumes.create(
|
81
|
+
xml: xml,
|
82
|
+
pool_name: pool_name
|
83
|
+
)
|
84
|
+
rescue Fog::Errors::Error => e
|
85
|
+
raise Errors::FogDomainVolumeCreateError,
|
86
|
+
error_message: e.message
|
78
87
|
end
|
79
|
-
@logger.debug "Using pool #{pool_name} for base box snapshot"
|
80
|
-
domain_volume = env[:machine].provider.driver.connection.volumes.create(
|
81
|
-
xml: xml,
|
82
|
-
pool_name: pool_name
|
83
|
-
)
|
84
|
-
rescue Fog::Errors::Error => e
|
85
|
-
raise Errors::FogDomainVolumeCreateError,
|
86
|
-
error_message: e.message
|
87
88
|
end
|
88
|
-
|
89
89
|
@app.call(env)
|
90
90
|
end
|
91
91
|
end
|
@@ -95,6 +95,7 @@ module VagrantPlugins
|
|
95
95
|
template_name = 'public_interface'
|
96
96
|
@logger.info("Setting up public interface using device #{@device} in mode #{@mode}")
|
97
97
|
@ovs = iface_configuration.fetch(:ovs, false)
|
98
|
+
@ovs_interfaceid = iface_configuration.fetch(:ovs_interfaceid, false)
|
98
99
|
@trust_guest_rx_filters = iface_configuration.fetch(:trust_guest_rx_filters, false)
|
99
100
|
# configuration for udp or tcp tunnel interfaces (p2p conn btwn guest OSes)
|
100
101
|
elsif iface_configuration.fetch(:tunnel_type, nil)
|
@@ -213,9 +214,6 @@ module VagrantPlugins
|
|
213
214
|
network[:type] = :dhcp
|
214
215
|
end
|
215
216
|
|
216
|
-
# do not run configure_networks for tcp tunnel interfaces
|
217
|
-
next if options.fetch(:tunnel_type, nil)
|
218
|
-
|
219
217
|
networks_to_configure << network
|
220
218
|
end
|
221
219
|
|
@@ -54,6 +54,8 @@ module VagrantPlugins
|
|
54
54
|
env[:machine].provider.driver.connection.client
|
55
55
|
)
|
56
56
|
|
57
|
+
current_network = @available_networks.detect { |network| network[:name] == @options[:network_name] }
|
58
|
+
|
57
59
|
# Prepare a hash describing network for this specific interface.
|
58
60
|
@interface_network = {
|
59
61
|
name: nil,
|
@@ -64,11 +66,11 @@ module VagrantPlugins
|
|
64
66
|
domain_name: nil,
|
65
67
|
ipv6_address: options[:ipv6_address] || nil,
|
66
68
|
ipv6_prefix: options[:ipv6_prefix] || nil,
|
67
|
-
created: false,
|
68
|
-
active: false,
|
69
|
+
created: current_network.nil? ? false : true,
|
70
|
+
active: current_network.nil? ? false : current_network[:active],
|
69
71
|
autostart: options[:autostart] || false,
|
70
72
|
guest_ipv6: @options[:guest_ipv6] || 'yes',
|
71
|
-
libvirt_network: nil
|
73
|
+
libvirt_network: current_network.nil? ? nil : current_network[:libvirt_network]
|
72
74
|
}
|
73
75
|
|
74
76
|
if @options[:ip]
|
@@ -255,7 +257,9 @@ module VagrantPlugins
|
|
255
257
|
|
256
258
|
# Do we need to create new network?
|
257
259
|
unless @interface_network[:created]
|
258
|
-
@interface_network[:name] =
|
260
|
+
@interface_network[:name] = @options[:network_name] ?
|
261
|
+
@options[:network_name] :
|
262
|
+
'vagrant-private-dhcp'
|
259
263
|
@interface_network[:network_address] = net_address
|
260
264
|
|
261
265
|
# Set IP address of network (actually bridge). It will be used as
|
@@ -297,6 +301,9 @@ module VagrantPlugins
|
|
297
301
|
|
298
302
|
@network_ipv6_address = @interface_network[:ipv6_address]
|
299
303
|
@network_ipv6_prefix = @interface_network[:ipv6_prefix]
|
304
|
+
|
305
|
+
@network_bridge_stp = @options[:bridge_stp].nil? || @options[:bridge_stp] ? 'on' : 'off'
|
306
|
+
@network_bridge_delay = @options[:bridge_delay] ? @options[:bridge_delay] : 0
|
300
307
|
|
301
308
|
@network_forward_mode = @options[:forward_mode]
|
302
309
|
if @options[:forward_device]
|