vagrant-libvirt 0.10.5 → 0.10.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vagrant-libvirt/action/start_domain.rb +7 -19
- data/lib/vagrant-libvirt/util/xml.rb +47 -0
- data/lib/vagrant-libvirt/version +1 -1
- data/spec/unit/action/start_domain_spec.rb +23 -0
- metadata +76 -75
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67234309e889d2254d68de7a257d1bf051bb507afcfc0ff03c28906dcceae43d
|
4
|
+
data.tar.gz: 1b0f05ff1fd494b46b99715ba500a20237e2262e2de0066ddfb07c46fac5d192
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb86380ba32e7c6d93856e3d6f168a3ea93d7bb4c532063764239f2875ea9371ca6c113f3a54671c90ba51a8b38166c271794932c1ce104981f40ab45be93de2
|
7
|
+
data.tar.gz: 035da37488d87c895b8f92b3bd0f616db26447edcbc7ee88fd7d4aa8b33c9f077893aef63ce6fd01e5f961349d938218aa749f0717be69becc4a2363656ac3ef
|
@@ -2,14 +2,16 @@
|
|
2
2
|
|
3
3
|
require 'log4r'
|
4
4
|
|
5
|
-
require 'compare-xml'
|
6
5
|
require 'rexml/document'
|
7
6
|
|
7
|
+
require 'vagrant-libvirt/util/xml'
|
8
|
+
|
8
9
|
module VagrantPlugins
|
9
10
|
module ProviderLibvirt
|
10
11
|
module Action
|
11
12
|
# Just start the domain.
|
12
13
|
class StartDomain
|
14
|
+
|
13
15
|
def initialize(app, _env)
|
14
16
|
@logger = Log4r::Logger.new('vagrant_libvirt::action::start_domain')
|
15
17
|
@app = app
|
@@ -427,27 +429,13 @@ module VagrantPlugins
|
|
427
429
|
|
428
430
|
begin
|
429
431
|
# need to check whether the updated XML contains all the changes requested
|
432
|
+
proposed = VagrantPlugins::ProviderLibvirt::Util::Xml.new(new_xml)
|
433
|
+
applied = VagrantPlugins::ProviderLibvirt::Util::Xml.new(libvirt_domain.xml_desc(1))
|
430
434
|
|
431
|
-
|
432
|
-
# eliminate differences for subsequent comparison by diffy
|
433
|
-
applied_xml_descr = REXML::Document.new(libvirt_domain.xml_desc(1))
|
434
|
-
applied_xml = String.new
|
435
|
-
applied_xml_descr.write(applied_xml)
|
436
|
-
|
437
|
-
proposed = Nokogiri::XML(new_xml, &:noblanks)
|
438
|
-
applied = Nokogiri::XML(applied_xml, &:noblanks)
|
439
|
-
|
440
|
-
if CompareXML.equivalent?(proposed, applied, { force_children: true })
|
435
|
+
if proposed != applied
|
441
436
|
require 'diffy'
|
442
437
|
|
443
|
-
|
444
|
-
# the output with diffy appears to be clearer
|
445
|
-
pretty_proposed = StringIO.new
|
446
|
-
pretty_applied = StringIO.new
|
447
|
-
proposed.write_xml_to(pretty_proposed, indent: 2)
|
448
|
-
applied.write_xml_to(pretty_applied, indent: 2)
|
449
|
-
|
450
|
-
diff = Diffy::Diff.new(pretty_proposed.string, pretty_applied.string, :context => 3).to_s(:text)
|
438
|
+
diff = Diffy::Diff.new(proposed, applied, :context => 3).to_s(:text)
|
451
439
|
|
452
440
|
error_msg = "Libvirt failed to fully update the domain with the specified XML. Result differs from requested:\n" +
|
453
441
|
"--- requested\n+++ result\n#{diff}\n" +
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'xmlsimple'
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module ProviderLibvirt
|
7
|
+
module Util
|
8
|
+
class Xml
|
9
|
+
attr_reader :xml
|
10
|
+
|
11
|
+
def initialize(xmlstr)
|
12
|
+
@xml = compact_content(XmlSimple.xml_in(xmlstr, {'NormaliseSpace' => 2}))
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_str
|
16
|
+
XmlSimple.xml_out(@xml)
|
17
|
+
end
|
18
|
+
|
19
|
+
def ==(other)
|
20
|
+
@xml == other.xml
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# content elements that are empty are preserved by xml-simple and will result
|
26
|
+
# in the structures being considered different even if functionality the same
|
27
|
+
# strip any empty ones to avoid.
|
28
|
+
def compact_content(node)
|
29
|
+
if node.is_a?(Array)
|
30
|
+
node.map! do |element|
|
31
|
+
compact_content(element)
|
32
|
+
end
|
33
|
+
elsif node.is_a?(Hash)
|
34
|
+
if node['content'] and node['content'].empty?
|
35
|
+
node.delete('content')
|
36
|
+
end
|
37
|
+
node.each do |k, v|
|
38
|
+
node[k] = compact_content(v)
|
39
|
+
end
|
40
|
+
else
|
41
|
+
return node
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/vagrant-libvirt/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.10.
|
1
|
+
0.10.6
|
@@ -72,7 +72,30 @@ describe VagrantPlugins::ProviderLibvirt::Action::StartDomain do
|
|
72
72
|
|
73
73
|
expect(subject.call(env)).to be_nil
|
74
74
|
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'when xml not applied' do
|
78
|
+
let(:test_file) { 'default_with_different_formatting.xml' }
|
79
|
+
let(:updated_domain_xml) {
|
80
|
+
new_xml = domain_xml.dup
|
81
|
+
new_xml.gsub!(/<cpu .*<\/cpu>/m, '<cpu mode="host-passthrough"/>')
|
82
|
+
new_xml
|
83
|
+
}
|
84
|
+
let(:vagrantfile_providerconfig) do
|
85
|
+
<<-EOF
|
86
|
+
libvirt.cpu_mode = "host-passthrough"
|
87
|
+
EOF
|
88
|
+
end
|
75
89
|
|
90
|
+
it 'should error and revert the update' do
|
91
|
+
expect(ui).to receive(:error)
|
92
|
+
expect(connection).to receive(:define_domain).and_return(libvirt_domain)
|
93
|
+
expect(connection).to receive(:define_domain).with(domain_xml) # undo
|
94
|
+
expect(libvirt_domain).to receive(:xml_desc).and_return(domain_xml, updated_domain_xml)
|
95
|
+
expect(domain).to_not receive(:start)
|
96
|
+
|
97
|
+
expect { subject.call(env) }.to raise_error(VagrantPlugins::ProviderLibvirt::Errors::FogError)
|
98
|
+
end
|
76
99
|
end
|
77
100
|
|
78
101
|
context 'when any setting changed' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-libvirt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Stanek
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2022-08-
|
14
|
+
date: 2022-08-30 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: fog-libvirt
|
@@ -56,7 +56,7 @@ dependencies:
|
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '0'
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
|
-
name:
|
59
|
+
name: xml-simple
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
61
61
|
requirements:
|
62
62
|
- - ">="
|
@@ -236,6 +236,7 @@ files:
|
|
236
236
|
- lib/vagrant-libvirt/util/timer.rb
|
237
237
|
- lib/vagrant-libvirt/util/ui.rb
|
238
238
|
- lib/vagrant-libvirt/util/unindent.rb
|
239
|
+
- lib/vagrant-libvirt/util/xml.rb
|
239
240
|
- lib/vagrant-libvirt/version
|
240
241
|
- lib/vagrant-libvirt/version.rb
|
241
242
|
- locales/en.yml
|
@@ -349,98 +350,98 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
349
350
|
- !ruby/object:Gem::Version
|
350
351
|
version: '0'
|
351
352
|
requirements: []
|
352
|
-
rubygems_version: 3.
|
353
|
+
rubygems_version: 3.2.3
|
353
354
|
signing_key:
|
354
355
|
specification_version: 4
|
355
356
|
summary: libvirt provider for Vagrant.
|
356
357
|
test_files:
|
357
|
-
- spec/
|
358
|
-
- spec/
|
359
|
-
- spec/
|
360
|
-
- spec/
|
358
|
+
- spec/acceptance/additional_storage_spec.rb
|
359
|
+
- spec/acceptance/package_domain_spec.rb
|
360
|
+
- spec/acceptance/provider_settings_spec.rb
|
361
|
+
- spec/acceptance/simple_vm_provision_via_shell_spec.rb
|
362
|
+
- spec/acceptance/snapshots_spec.rb
|
363
|
+
- spec/acceptance/support-skeletons/package_complex/Vagrantfile.testbox
|
364
|
+
- spec/acceptance/support-skeletons/package_complex/scripts/sysprep.sh
|
365
|
+
- spec/acceptance/support-skeletons/package_simple/Vagrantfile.testbox
|
366
|
+
- spec/acceptance/two_disks_spec.rb
|
367
|
+
- spec/acceptance/use_qemu_agent_for_connectivity_spec.rb
|
368
|
+
- spec/spec_helper.rb
|
369
|
+
- spec/support/acceptance/configuration.rb
|
370
|
+
- spec/support/acceptance/context.rb
|
371
|
+
- spec/support/acceptance/isolated_environment.rb
|
372
|
+
- spec/support/binding_proc.rb
|
373
|
+
- spec/support/environment_helper.rb
|
374
|
+
- spec/support/libvirt_acceptance_context.rb
|
375
|
+
- spec/support/libvirt_context.rb
|
376
|
+
- spec/support/matchers/have_file_content.rb
|
377
|
+
- spec/support/sharedcontext.rb
|
378
|
+
- spec/support/temporary_dir.rb
|
379
|
+
- spec/unit/action/clean_machine_folder_spec.rb
|
380
|
+
- spec/unit/action/cleanup_on_failure_spec.rb
|
381
|
+
- spec/unit/action/create_domain_spec/additional_disks_domain.xml
|
382
|
+
- spec/unit/action/create_domain_spec/custom_disk_settings.xml
|
383
|
+
- spec/unit/action/create_domain_spec/default_domain.xml
|
384
|
+
- spec/unit/action/create_domain_spec/default_user_storage_pool.xml
|
385
|
+
- spec/unit/action/create_domain_spec/sysinfo.xml
|
386
|
+
- spec/unit/action/create_domain_spec/sysinfo_only_required.xml
|
387
|
+
- spec/unit/action/create_domain_spec/two_disk_settings.xml
|
388
|
+
- spec/unit/action/create_domain_spec.rb
|
389
|
+
- spec/unit/action/create_domain_volume_spec/one_disk_in_storage.xml
|
390
|
+
- spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_0.xml
|
391
|
+
- spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_1.xml
|
392
|
+
- spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_2.xml
|
393
|
+
- spec/unit/action/create_domain_volume_spec.rb
|
394
|
+
- spec/unit/action/destroy_domain_spec/additional_disks_domain.xml
|
361
395
|
- spec/unit/action/destroy_domain_spec/box_multiple_disks.xml
|
396
|
+
- spec/unit/action/destroy_domain_spec/box_multiple_disks_and_additional_and_custom_disks.xml
|
362
397
|
- spec/unit/action/destroy_domain_spec/box_multiple_disks_and_additional_and_custom_disks_no_aliases.xml
|
363
398
|
- spec/unit/action/destroy_domain_spec/box_multiple_disks_and_additional_disks.xml
|
364
399
|
- spec/unit/action/destroy_domain_spec/cdrom_domain.xml
|
365
|
-
- spec/unit/action/destroy_domain_spec
|
366
|
-
- spec/unit/action/
|
367
|
-
- spec/unit/action/
|
368
|
-
- spec/unit/action/
|
400
|
+
- spec/unit/action/destroy_domain_spec.rb
|
401
|
+
- spec/unit/action/forward_ports_spec.rb
|
402
|
+
- spec/unit/action/halt_domain_spec.rb
|
403
|
+
- spec/unit/action/handle_box_image_spec.rb
|
404
|
+
- spec/unit/action/package_domain_spec.rb
|
405
|
+
- spec/unit/action/prepare_nfs_settings_spec.rb
|
406
|
+
- spec/unit/action/remove_libvirt_image_spec.rb
|
407
|
+
- spec/unit/action/resolve_disk_settings_spec/default_domain.xml
|
369
408
|
- spec/unit/action/resolve_disk_settings_spec/default_no_aliases.xml
|
409
|
+
- spec/unit/action/resolve_disk_settings_spec/default_system_storage_pool.xml
|
410
|
+
- spec/unit/action/resolve_disk_settings_spec/multi_volume_box.xml
|
370
411
|
- spec/unit/action/resolve_disk_settings_spec/multi_volume_box_additional_and_custom_no_aliases.xml
|
371
412
|
- spec/unit/action/resolve_disk_settings_spec/multi_volume_box_additional_storage.xml
|
372
|
-
- spec/unit/action/resolve_disk_settings_spec
|
373
|
-
- spec/unit/action/
|
374
|
-
- spec/unit/action/
|
375
|
-
- spec/unit/action/start_domain_spec/nvram_domain_removed.xml
|
376
|
-
- spec/unit/action/start_domain_spec/default.xml
|
377
|
-
- spec/unit/action/start_domain_spec/default_added_tpm_version.xml
|
378
|
-
- spec/unit/action/start_domain_spec/default_with_different_formatting.xml
|
379
|
-
- spec/unit/action/start_domain_spec/nvram_domain_other_setting.xml
|
380
|
-
- spec/unit/action/start_domain_spec/clock_timer_rtc.xml
|
413
|
+
- spec/unit/action/resolve_disk_settings_spec.rb
|
414
|
+
- spec/unit/action/set_name_of_domain_spec.rb
|
415
|
+
- spec/unit/action/shutdown_domain_spec.rb
|
381
416
|
- spec/unit/action/start_domain_spec/clock_timer_removed.xml
|
417
|
+
- spec/unit/action/start_domain_spec/clock_timer_rtc.xml
|
382
418
|
- spec/unit/action/start_domain_spec/clock_timer_rtc_tsc.xml
|
383
|
-
- spec/unit/action/start_domain_spec/
|
419
|
+
- spec/unit/action/start_domain_spec/default.xml
|
384
420
|
- spec/unit/action/start_domain_spec/default_added_tpm_path.xml
|
421
|
+
- spec/unit/action/start_domain_spec/default_added_tpm_version.xml
|
422
|
+
- spec/unit/action/start_domain_spec/default_with_different_formatting.xml
|
423
|
+
- spec/unit/action/start_domain_spec/existing.xml
|
385
424
|
- spec/unit/action/start_domain_spec/existing_added_nvram.xml
|
386
|
-
- spec/unit/action/
|
387
|
-
- spec/unit/action/
|
388
|
-
- spec/unit/action/
|
389
|
-
- spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_0.xml
|
390
|
-
- spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_1.xml
|
391
|
-
- spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_2.xml
|
392
|
-
- spec/unit/action/create_domain_volume_spec/one_disk_in_storage.xml
|
425
|
+
- spec/unit/action/start_domain_spec/nvram_domain.xml
|
426
|
+
- spec/unit/action/start_domain_spec/nvram_domain_other_setting.xml
|
427
|
+
- spec/unit/action/start_domain_spec/nvram_domain_removed.xml
|
393
428
|
- spec/unit/action/start_domain_spec.rb
|
394
|
-
- spec/unit/action/clean_machine_folder_spec.rb
|
395
|
-
- spec/unit/action/destroy_domain_spec.rb
|
396
429
|
- spec/unit/action/wait_till_up_spec.rb
|
397
|
-
- spec/unit/
|
398
|
-
- spec/unit/
|
399
|
-
- spec/unit/
|
400
|
-
- spec/unit/
|
401
|
-
- spec/unit/
|
402
|
-
- spec/unit/
|
403
|
-
- spec/unit/
|
404
|
-
- spec/unit/
|
405
|
-
- spec/unit/
|
406
|
-
- spec/unit/
|
407
|
-
- spec/unit/action/create_domain_spec/default_domain.xml
|
408
|
-
- spec/unit/action/create_domain_spec/sysinfo.xml
|
409
|
-
- spec/unit/action/create_domain_spec/additional_disks_domain.xml
|
410
|
-
- spec/unit/templates/domain_scsi_multiple_controllers_storage.xml
|
430
|
+
- spec/unit/action_spec.rb
|
431
|
+
- spec/unit/cap/synced_folder_9p_spec.rb
|
432
|
+
- spec/unit/cap/synced_folder_virtiofs_spec.rb
|
433
|
+
- spec/unit/config_spec.rb
|
434
|
+
- spec/unit/driver_spec.rb
|
435
|
+
- spec/unit/plugin_spec.rb
|
436
|
+
- spec/unit/templates/domain_all_settings.xml
|
437
|
+
- spec/unit/templates/domain_cpu_mode_passthrough.xml
|
438
|
+
- spec/unit/templates/domain_custom_cpu_model.xml
|
439
|
+
- spec/unit/templates/domain_defaults.xml
|
411
440
|
- spec/unit/templates/domain_scsi_bus_storage.xml
|
412
441
|
- spec/unit/templates/domain_scsi_device_storage.xml
|
413
|
-
- spec/unit/templates/
|
442
|
+
- spec/unit/templates/domain_scsi_multiple_controllers_storage.xml
|
414
443
|
- spec/unit/templates/domain_spec.rb
|
415
|
-
- spec/unit/templates/tpm/version_2.0.xml
|
416
444
|
- spec/unit/templates/tpm/version_1.2.xml
|
417
|
-
- spec/unit/templates/
|
418
|
-
- spec/unit/templates/domain_defaults.xml
|
419
|
-
- spec/unit/templates/domain_custom_cpu_model.xml
|
420
|
-
- spec/unit/cap/synced_folder_virtiofs_spec.rb
|
421
|
-
- spec/unit/cap/synced_folder_9p_spec.rb
|
422
|
-
- spec/unit/plugin_spec.rb
|
423
|
-
- spec/unit/driver_spec.rb
|
445
|
+
- spec/unit/templates/tpm/version_2.0.xml
|
424
446
|
- spec/unit/util/byte_number_spec.rb
|
425
447
|
- spec/unit/util/resolvers_spec.rb
|
426
|
-
- spec/support/temporary_dir.rb
|
427
|
-
- spec/support/environment_helper.rb
|
428
|
-
- spec/support/sharedcontext.rb
|
429
|
-
- spec/support/matchers/have_file_content.rb
|
430
|
-
- spec/support/libvirt_acceptance_context.rb
|
431
|
-
- spec/support/acceptance/configuration.rb
|
432
|
-
- spec/support/acceptance/isolated_environment.rb
|
433
|
-
- spec/support/acceptance/context.rb
|
434
|
-
- spec/support/libvirt_context.rb
|
435
|
-
- spec/support/binding_proc.rb
|
436
|
-
- spec/acceptance/provider_settings_spec.rb
|
437
|
-
- spec/acceptance/two_disks_spec.rb
|
438
|
-
- spec/acceptance/package_domain_spec.rb
|
439
|
-
- spec/acceptance/snapshots_spec.rb
|
440
|
-
- spec/acceptance/additional_storage_spec.rb
|
441
|
-
- spec/acceptance/simple_vm_provision_via_shell_spec.rb
|
442
|
-
- spec/acceptance/use_qemu_agent_for_connectivity_spec.rb
|
443
|
-
- spec/acceptance/support-skeletons/package_simple/Vagrantfile.testbox
|
444
|
-
- spec/acceptance/support-skeletons/package_complex/Vagrantfile.testbox
|
445
|
-
- spec/acceptance/support-skeletons/package_complex/scripts/sysprep.sh
|
446
|
-
- spec/spec_helper.rb
|