vagrant-libvirt 0.10.8 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +44 -7
- data/lib/vagrant-libvirt/action/create_domain.rb +45 -22
- data/lib/vagrant-libvirt/action/create_domain_volume.rb +3 -0
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +15 -5
- data/lib/vagrant-libvirt/action/create_networks.rb +2 -6
- data/lib/vagrant-libvirt/action/destroy_domain.rb +2 -10
- data/lib/vagrant-libvirt/action/forward_ports.rb +1 -1
- data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +7 -5
- data/lib/vagrant-libvirt/action/resolve_disk_settings.rb +2 -0
- data/lib/vagrant-libvirt/action/snapshot_delete.rb +1 -1
- data/lib/vagrant-libvirt/action/snapshot_restore.rb +1 -1
- data/lib/vagrant-libvirt/action/snapshot_save.rb +1 -2
- data/lib/vagrant-libvirt/action/start_domain.rb +149 -62
- data/lib/vagrant-libvirt/action/wait_till_up.rb +2 -2
- data/lib/vagrant-libvirt/action.rb +18 -13
- data/lib/vagrant-libvirt/cap/mount_9p.rb +9 -1
- data/lib/vagrant-libvirt/cap/snapshots.rb +1 -1
- data/lib/vagrant-libvirt/config.rb +198 -26
- data/lib/vagrant-libvirt/driver.rb +94 -55
- data/lib/vagrant-libvirt/provider.rb +4 -4
- data/lib/vagrant-libvirt/templates/domain.xml.erb +73 -27
- data/lib/vagrant-libvirt/templates/public_interface.xml.erb +6 -3
- data/lib/vagrant-libvirt/util/network_util.rb +5 -10
- data/lib/vagrant-libvirt/version +1 -1
- data/locales/en.yml +2 -0
- data/spec/acceptance/additional_storage_spec.rb +1 -4
- data/spec/acceptance/networking_spec.rb +41 -0
- data/spec/acceptance/package_domain_spec.rb +2 -2
- data/spec/acceptance/provider_settings_spec.rb +1 -1
- data/spec/acceptance/simple_vm_provision_via_shell_spec.rb +1 -1
- data/spec/acceptance/snapshots_spec.rb +1 -1
- data/spec/acceptance/two_disks_spec.rb +1 -1
- data/spec/acceptance/use_qemu_agent_for_connectivity_spec.rb +1 -1
- data/spec/spec_helper.rb +31 -8
- data/spec/support/acceptance/isolated_environment.rb +1 -1
- data/spec/support/environment_helper.rb +1 -1
- data/spec/support/libvirt_acceptance_context.rb +15 -1
- data/spec/support/{sharedcontext.rb → unit_context.rb} +20 -5
- data/spec/unit/action/clean_machine_folder_spec.rb +1 -2
- data/spec/unit/action/cleanup_on_failure_spec.rb +1 -2
- data/spec/unit/action/create_domain_spec/additional_disks_domain.xml +4 -2
- data/spec/unit/action/create_domain_spec/custom_disk_settings.xml +4 -2
- data/spec/unit/action/create_domain_spec/default_domain.xml +4 -2
- data/spec/unit/action/create_domain_spec/sysinfo.xml +4 -2
- data/spec/unit/action/create_domain_spec/sysinfo_only_required.xml +4 -2
- data/spec/unit/action/create_domain_spec/two_disk_settings.xml +4 -2
- data/spec/unit/action/create_domain_spec.rb +51 -3
- data/spec/unit/action/create_domain_volume_spec.rb +2 -4
- data/spec/unit/action/destroy_domain_spec/additional_disks_domain.xml +1 -0
- data/spec/unit/action/destroy_domain_spec/box_multiple_disks.xml +1 -0
- data/spec/unit/action/destroy_domain_spec/box_multiple_disks_and_additional_and_custom_disks.xml +1 -0
- data/spec/unit/action/destroy_domain_spec/box_multiple_disks_and_additional_and_custom_disks_no_aliases.xml +1 -0
- data/spec/unit/action/destroy_domain_spec/box_multiple_disks_and_additional_disks.xml +1 -0
- data/spec/unit/action/destroy_domain_spec/cdrom_domain.xml +1 -0
- data/spec/unit/action/destroy_domain_spec.rb +1 -18
- data/spec/unit/action/forward_ports_spec.rb +1 -3
- data/spec/unit/action/halt_domain_spec.rb +2 -3
- data/spec/unit/action/handle_box_image_spec.rb +3 -4
- data/spec/unit/action/package_domain_spec.rb +2 -3
- data/spec/unit/action/prepare_nfs_settings_spec.rb +25 -9
- data/spec/unit/action/remove_libvirt_image_spec.rb +1 -2
- data/spec/unit/action/resolve_disk_settings_spec/default_domain.xml +1 -0
- data/spec/unit/action/resolve_disk_settings_spec/default_no_aliases.xml +1 -0
- data/spec/unit/action/resolve_disk_settings_spec/multi_volume_box.xml +1 -0
- data/spec/unit/action/resolve_disk_settings_spec/multi_volume_box_additional_and_custom_no_aliases.xml +1 -0
- data/spec/unit/action/resolve_disk_settings_spec/multi_volume_box_additional_storage.xml +1 -0
- data/spec/unit/action/resolve_disk_settings_spec.rb +1 -1
- data/spec/unit/action/set_boot_order_spec/default.xml +1 -0
- data/spec/unit/action/set_boot_order_spec/explicit_boot_order.xml +1 -0
- data/spec/unit/action/set_boot_order_spec.rb +1 -3
- data/spec/unit/action/set_name_of_domain_spec.rb +3 -1
- data/spec/unit/action/shutdown_domain_spec.rb +4 -3
- data/spec/unit/action/start_domain_spec/clock_timer_removed.xml +1 -1
- data/spec/unit/action/start_domain_spec/clock_timer_rtc.xml +1 -1
- data/spec/unit/action/start_domain_spec/clock_timer_rtc_tsc.xml +1 -1
- data/spec/unit/action/start_domain_spec/default.xml +1 -1
- data/spec/unit/action/start_domain_spec/default_added_tpm_path.xml +1 -1
- data/spec/unit/action/start_domain_spec/default_added_tpm_version.xml +1 -1
- data/spec/unit/action/start_domain_spec/default_with_different_formatting.xml +1 -1
- data/spec/unit/action/start_domain_spec/existing.xml +2 -1
- data/spec/unit/action/start_domain_spec/existing_added_nvram.xml +2 -1
- data/spec/unit/action/start_domain_spec/existing_reordered.xml +2 -1
- data/spec/unit/action/start_domain_spec/nvram_domain.xml +1 -0
- data/spec/unit/action/start_domain_spec/nvram_domain_other_setting.xml +2 -1
- data/spec/unit/action/start_domain_spec/nvram_domain_removed.xml +2 -1
- data/spec/unit/action/start_domain_spec.rb +192 -3
- data/spec/unit/action/wait_till_up_spec.rb +3 -5
- data/spec/unit/action_spec.rb +403 -10
- data/spec/unit/cap/mount_9p_spec.rb +75 -0
- data/spec/unit/cap/synced_folder_9p_spec.rb +1 -2
- data/spec/unit/cap/synced_folder_virtiofs_spec.rb +1 -2
- data/spec/unit/config_spec.rb +365 -25
- data/spec/unit/driver_spec.rb +217 -80
- data/spec/unit/plugin_spec.rb +6 -3
- data/spec/unit/templates/domain_all_settings.xml +26 -4
- data/spec/unit/templates/domain_cpu_mode_passthrough.xml +4 -2
- data/spec/unit/templates/domain_custom_cpu_model.xml +4 -2
- data/spec/unit/templates/domain_defaults.xml +4 -2
- data/spec/unit/templates/domain_scsi_bus_storage.xml +4 -2
- data/spec/unit/templates/domain_scsi_device_storage.xml +4 -2
- data/spec/unit/templates/domain_scsi_multiple_controllers_storage.xml +4 -2
- data/spec/unit/templates/domain_spec.rb +11 -3
- data/spec/unit/templates/tpm/version_1.2.xml +4 -2
- data/spec/unit/templates/tpm/version_2.0.xml +4 -2
- data/spec/unit/util/byte_number_spec.rb +1 -1
- data/spec/unit/util/network_util_spec/default.xml +16 -0
- data/spec/unit/util/network_util_spec/hostdev.xml +6 -0
- data/spec/unit/util/network_util_spec/vagrant-libvirt.xml +16 -0
- data/spec/unit/util/network_util_spec.rb +59 -0
- data/spec/unit/util/resolvers_spec.rb +1 -1
- metadata +85 -73
data/spec/spec_helper.rb
CHANGED
@@ -38,13 +38,27 @@ rescue LoadError
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
require 'rspec'
|
42
|
+
|
41
43
|
RSpec.configure do |config|
|
42
44
|
require 'tmpdir'
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
if ENV['VAGRANT_LIBVIRT_VAGRANT_HOME'].nil?
|
47
|
+
# set VAGRANT_HOME before any thing that requires vagrant is loaded to prevent
|
48
|
+
# the global plugin manager from trying to use the default VAGRANT_HOME.
|
49
|
+
temp_dir = Dir.mktmpdir("rspec-")
|
50
|
+
ENV['VAGRANT_HOME'] = temp_dir
|
51
|
+
|
52
|
+
config.after(:suite) do
|
53
|
+
FileUtils.remove_entry temp_dir
|
54
|
+
end
|
55
|
+
else
|
56
|
+
ENV['VAGRANT_HOME'] = ENV['VAGRANT_LIBVIRT_VAGRANT_HOME']
|
57
|
+
end
|
58
|
+
|
59
|
+
# acceptance tests need the boxes dir to exist to allow symlinking of isolated
|
60
|
+
# environments while allowing the boxes to be cached.
|
61
|
+
FileUtils.mkdir_p(File.join(ENV['VAGRANT_HOME'], 'boxes'))
|
48
62
|
|
49
63
|
# ensure that setting of LIBVIRT_DEFAULT_URI in the environment is not picked
|
50
64
|
# up directly by tests, instead they must set as needed. Some build envs will
|
@@ -53,10 +67,6 @@ RSpec.configure do |config|
|
|
53
67
|
ENV.delete('LIBVIRT_DEFAULT_URI')
|
54
68
|
end
|
55
69
|
|
56
|
-
config.after(:suite) do
|
57
|
-
FileUtils.remove_entry temp_dir
|
58
|
-
end
|
59
|
-
|
60
70
|
config.mock_with :rspec do |mocks|
|
61
71
|
mocks.verify_partial_doubles = true
|
62
72
|
end
|
@@ -69,6 +79,19 @@ RSpec.configure do |config|
|
|
69
79
|
end
|
70
80
|
end
|
71
81
|
|
82
|
+
begin
|
83
|
+
require 'test-prof'
|
84
|
+
|
85
|
+
TestProf.configure do |config|
|
86
|
+
# use unique filenames for reports (by simply appending current timestamp)
|
87
|
+
config.timestamps = true
|
88
|
+
|
89
|
+
# color output
|
90
|
+
config.color = true
|
91
|
+
end
|
92
|
+
rescue LoadError
|
93
|
+
end
|
94
|
+
|
72
95
|
require 'vagrant-spec/unit'
|
73
96
|
|
74
97
|
Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each { |f| require f }
|
@@ -30,7 +30,7 @@ module VagrantPlugins
|
|
30
30
|
|
31
31
|
# Execute, logging out the stdout/stderr as we get it
|
32
32
|
@logger.info("Executing: #{[command].concat(args).inspect}")
|
33
|
-
Vagrant::Spec::Subprocess.
|
33
|
+
Vagrant::Spec::Subprocess.new(command, *args, **options).execute do |type, data|
|
34
34
|
@logger.debug("#{type}: #{data}") if type == :stdout || type == :stderr
|
35
35
|
yield type, data if block_given?
|
36
36
|
end
|
@@ -20,7 +20,7 @@ class EnvironmentHelper
|
|
20
20
|
1024
|
21
21
|
end
|
22
22
|
|
23
|
-
%w(cpus cpu_mode loader nvram boot_order machine_type disk_bus disk_device nested volume_cache kernel cmd_line initrd graphics_type graphics_autoport graphics_port graphics_ip graphics_passwd video_type video_vram keymap storage_pool_name disks cdroms driver).each do |name|
|
23
|
+
%w(cpus cpu_mode loader nvram boot_order machine_type disk_bus disk_device nested volume_cache kernel cmd_line initrd graphics_type graphics_autoport graphics_port graphics_websocket graphics_ip graphics_passwd video_type video_vram keymap storage_pool_name disks cdroms floppies driver).each do |name|
|
24
24
|
define_method(name.to_sym) do
|
25
25
|
nil
|
26
26
|
end
|
@@ -21,8 +21,10 @@ shared_context 'libvirt_acceptance' do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
before(:each) do
|
24
|
+
vagrant_home = ENV.fetch('VAGRANT_HOME', File.expand_path('~/.vagrant.d'))
|
24
25
|
# allow execution environment to cache boxes used
|
25
|
-
symlink_boxes(
|
26
|
+
symlink_boxes(vagrant_home, environment)
|
27
|
+
copy_vagrantfile(vagrant_home, environment)
|
26
28
|
end
|
27
29
|
|
28
30
|
after(:each) do
|
@@ -51,6 +53,7 @@ shared_context 'libvirt_acceptance' do
|
|
51
53
|
def duplicate_environment(env, *args)
|
52
54
|
dup_env = new_environment(*args)
|
53
55
|
symlink_boxes(env.homedir, dup_env)
|
56
|
+
copy_vagrantfile(vagrant_home, environment)
|
54
57
|
|
55
58
|
dup_env
|
56
59
|
end
|
@@ -61,4 +64,15 @@ shared_context 'libvirt_acceptance' do
|
|
61
64
|
# allow use the same boxes location as source environment
|
62
65
|
File.symlink File.realpath(File.join(vagrant_home, 'boxes')), File.join(target_env.homedir, 'boxes')
|
63
66
|
end
|
67
|
+
|
68
|
+
def copy_vagrantfile(vagrant_home, target_env)
|
69
|
+
return if vagrant_home.nil?
|
70
|
+
|
71
|
+
# allows for a helper Vagrantfile to force specific provider options if testing
|
72
|
+
# environment needs them
|
73
|
+
vagrantfile = File.join(vagrant_home, 'Vagrantfile')
|
74
|
+
if File.exists?(vagrantfile) and !File.exists?(File.join(target_env.homedir, 'Vagrantfile'))
|
75
|
+
FileUtils.cp(vagrantfile, target_env.homedir)
|
76
|
+
end
|
77
|
+
end
|
64
78
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative '../spec_helper'
|
4
4
|
|
5
5
|
shared_context 'unit' do
|
6
6
|
include_context 'vagrant-unit'
|
@@ -22,21 +22,36 @@ shared_context 'unit' do
|
|
22
22
|
test_env.vagrantfile vagrantfile
|
23
23
|
test_env
|
24
24
|
end
|
25
|
-
let(:env) { { env: iso_env, machine: machine, ui: ui, root_path: '/rootpath' } }
|
26
|
-
let(:conf) { Vagrant::Config::V2::DummyConfig.new }
|
27
|
-
let(:ui) { Vagrant::UI::Silent.new }
|
28
25
|
let(:iso_env) { test_env.create_vagrant_env ui_class: Vagrant::UI::Basic }
|
29
26
|
let(:machine) { iso_env.machine(:test, :libvirt) }
|
27
|
+
let(:ui) { Vagrant::UI::Silent.new }
|
28
|
+
let(:env) { { env: iso_env, machine: machine, ui: ui, root_path: '/rootpath' } }
|
29
|
+
|
30
30
|
# Mock the communicator to prevent SSH commands for being executed.
|
31
31
|
let(:communicator) { double('communicator') }
|
32
32
|
# Mock the guest operating system.
|
33
33
|
let(:guest) { double('guest') }
|
34
34
|
let(:app) { ->(env) {} }
|
35
|
-
let(:plugin) { register_plugin }
|
36
35
|
|
37
36
|
before (:each) do
|
38
37
|
allow(machine).to receive(:guest).and_return(guest)
|
39
38
|
allow(machine).to receive(:communicate).and_return(communicator)
|
40
39
|
allow(machine).to receive(:ui).and_return(ui)
|
41
40
|
end
|
41
|
+
|
42
|
+
around do |example|
|
43
|
+
Dir.mktmpdir do |tmpdir|
|
44
|
+
original_home = ENV['HOME']
|
45
|
+
|
46
|
+
begin
|
47
|
+
virtual_home = File.expand_path(File.join(tmpdir, 'home'))
|
48
|
+
Dir.mkdir(virtual_home)
|
49
|
+
ENV['HOME'] = virtual_home
|
50
|
+
|
51
|
+
example.run
|
52
|
+
ensure
|
53
|
+
ENV['HOME'] = original_home
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
42
57
|
end
|
@@ -10,6 +10,7 @@
|
|
10
10
|
</cpu>
|
11
11
|
<os>
|
12
12
|
<type>hvm</type>
|
13
|
+
<bootmenu enable='no'/>
|
13
14
|
<kernel></kernel>
|
14
15
|
<initrd></initrd>
|
15
16
|
<cmdline></cmdline>
|
@@ -40,8 +41,9 @@
|
|
40
41
|
<console type='pty'>
|
41
42
|
<target port='0'/>
|
42
43
|
</console>
|
43
|
-
<input type='mouse' bus='ps2'
|
44
|
-
|
44
|
+
<input type='mouse' bus='ps2'>
|
45
|
+
</input>
|
46
|
+
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
45
47
|
<video>
|
46
48
|
<model type='cirrus' vram='16384' heads='1'/>
|
47
49
|
</video>
|
@@ -10,6 +10,7 @@
|
|
10
10
|
</cpu>
|
11
11
|
<os>
|
12
12
|
<type>hvm</type>
|
13
|
+
<bootmenu enable='no'/>
|
13
14
|
<kernel></kernel>
|
14
15
|
<initrd></initrd>
|
15
16
|
<cmdline></cmdline>
|
@@ -34,8 +35,9 @@
|
|
34
35
|
<console type='pty'>
|
35
36
|
<target port='0'/>
|
36
37
|
</console>
|
37
|
-
<input type='mouse' bus='ps2'
|
38
|
-
|
38
|
+
<input type='mouse' bus='ps2'>
|
39
|
+
</input>
|
40
|
+
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
39
41
|
<video>
|
40
42
|
<model type='cirrus' vram='16384' heads='1'/>
|
41
43
|
</video>
|
@@ -10,6 +10,7 @@
|
|
10
10
|
</cpu>
|
11
11
|
<os>
|
12
12
|
<type>hvm</type>
|
13
|
+
<bootmenu enable='no'/>
|
13
14
|
<kernel></kernel>
|
14
15
|
<initrd></initrd>
|
15
16
|
<cmdline></cmdline>
|
@@ -34,8 +35,9 @@
|
|
34
35
|
<console type='pty'>
|
35
36
|
<target port='0'/>
|
36
37
|
</console>
|
37
|
-
<input type='mouse' bus='ps2'
|
38
|
-
|
38
|
+
<input type='mouse' bus='ps2'>
|
39
|
+
</input>
|
40
|
+
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
39
41
|
<video>
|
40
42
|
<model type='cirrus' vram='16384' heads='1'/>
|
41
43
|
</video>
|
@@ -10,6 +10,7 @@
|
|
10
10
|
</cpu>
|
11
11
|
<os>
|
12
12
|
<type>hvm</type>
|
13
|
+
<bootmenu enable='no'/>
|
13
14
|
<kernel></kernel>
|
14
15
|
<initrd></initrd>
|
15
16
|
<cmdline></cmdline>
|
@@ -57,8 +58,9 @@
|
|
57
58
|
<console type='pty'>
|
58
59
|
<target port='0'/>
|
59
60
|
</console>
|
60
|
-
<input type='mouse' bus='ps2'
|
61
|
-
|
61
|
+
<input type='mouse' bus='ps2'>
|
62
|
+
</input>
|
63
|
+
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
62
64
|
<video>
|
63
65
|
<model type='cirrus' vram='16384' heads='1'/>
|
64
66
|
</video>
|
@@ -10,6 +10,7 @@
|
|
10
10
|
</cpu>
|
11
11
|
<os>
|
12
12
|
<type>hvm</type>
|
13
|
+
<bootmenu enable='no'/>
|
13
14
|
<kernel></kernel>
|
14
15
|
<initrd></initrd>
|
15
16
|
<cmdline></cmdline>
|
@@ -40,8 +41,9 @@
|
|
40
41
|
<console type='pty'>
|
41
42
|
<target port='0'/>
|
42
43
|
</console>
|
43
|
-
<input type='mouse' bus='ps2'
|
44
|
-
|
44
|
+
<input type='mouse' bus='ps2'>
|
45
|
+
</input>
|
46
|
+
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
45
47
|
<video>
|
46
48
|
<model type='cirrus' vram='16384' heads='1'/>
|
47
49
|
</video>
|
@@ -10,6 +10,7 @@
|
|
10
10
|
</cpu>
|
11
11
|
<os>
|
12
12
|
<type>hvm</type>
|
13
|
+
<bootmenu enable='no'/>
|
13
14
|
<kernel></kernel>
|
14
15
|
<initrd></initrd>
|
15
16
|
<cmdline></cmdline>
|
@@ -40,8 +41,9 @@
|
|
40
41
|
<console type='pty'>
|
41
42
|
<target port='0'/>
|
42
43
|
</console>
|
43
|
-
<input type='mouse' bus='ps2'
|
44
|
-
|
44
|
+
<input type='mouse' bus='ps2'>
|
45
|
+
</input>
|
46
|
+
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
45
47
|
<video>
|
46
48
|
<model type='cirrus' vram='16384' heads='1'/>
|
47
49
|
</video>
|
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'support/sharedcontext'
|
5
|
-
require 'support/libvirt_context'
|
3
|
+
require_relative '../../spec_helper'
|
6
4
|
|
7
5
|
require 'fog/libvirt/models/compute/volume'
|
8
6
|
|
@@ -64,6 +62,24 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
|
|
64
62
|
expect(subject.call(env)).to be_nil
|
65
63
|
end
|
66
64
|
|
65
|
+
context 'graphics autoport disabled' do
|
66
|
+
let(:vagrantfile_providerconfig) do
|
67
|
+
<<-EOF
|
68
|
+
libvirt.graphics_port = 5900
|
69
|
+
libvirt.graphics_websocket = 5700
|
70
|
+
EOF
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should emit the graphics port and websocket' do
|
74
|
+
expect(servers).to receive(:create).and_return(machine)
|
75
|
+
expect(volumes).to_not receive(:create) # additional disks only
|
76
|
+
expect(ui).to receive(:info).with(' -- Graphics Port: 5900')
|
77
|
+
expect(ui).to receive(:info).with(' -- Graphics Websocket: 5700')
|
78
|
+
|
79
|
+
expect(subject.call(env)).to be_nil
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
67
83
|
context 'additional disks' do
|
68
84
|
let(:disks) do
|
69
85
|
[
|
@@ -171,6 +187,38 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
|
|
171
187
|
end
|
172
188
|
end
|
173
189
|
|
190
|
+
context 'launchSecurity' do
|
191
|
+
let(:vagrantfile_providerconfig) do
|
192
|
+
<<-EOF
|
193
|
+
libvirt.launchsecurity :type => 'sev', :cbitpos => 47, :reducedPhysBits => 1, :policy => "0x0003"
|
194
|
+
EOF
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'should emit the settings to the ui' do
|
198
|
+
expect(ui).to receive(:info).with(/ -- Launch security: type=sev, cbitpos=47, reducedPhysBits=1, policy=0x0003/)
|
199
|
+
expect(servers).to receive(:create).and_return(machine)
|
200
|
+
|
201
|
+
expect(subject.call(env)).to be_nil
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
context 'memtunes' do
|
206
|
+
let(:vagrantfile_providerconfig) do
|
207
|
+
<<-EOF
|
208
|
+
libvirt.memtune :type => 'hard_limit', :value => 250000
|
209
|
+
libvirt.memtune :type => 'soft_limit', :value => 200000
|
210
|
+
EOF
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'should emit the settings to the ui' do
|
214
|
+
expect(ui).to receive(:info).with(/ -- Memory Tuning: hard_limit: unit='KiB', value: 250000/)
|
215
|
+
expect(ui).to receive(:info).with(/ -- Memory Tuning: soft_limit: unit='KiB', value: 200000/)
|
216
|
+
expect(servers).to receive(:create).and_return(machine)
|
217
|
+
|
218
|
+
expect(subject.call(env)).to be_nil
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
174
222
|
context 'sysinfo' do
|
175
223
|
let(:domain_xml_file) { 'sysinfo.xml' }
|
176
224
|
let(:vagrantfile_providerconfig) do
|
@@ -1,12 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'support/sharedcontext'
|
5
|
-
require 'support/libvirt_context'
|
3
|
+
require_relative '../../spec_helper'
|
6
4
|
|
7
5
|
require 'fog/libvirt/models/compute/volume'
|
8
6
|
|
9
|
-
require 'vagrant-libvirt/action/
|
7
|
+
require 'vagrant-libvirt/action/create_domain_volume'
|
10
8
|
require 'vagrant-libvirt/util/byte_number'
|
11
9
|
|
12
10
|
|
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'support/sharedcontext'
|
5
|
-
require 'support/libvirt_context'
|
3
|
+
require_relative '../../spec_helper'
|
6
4
|
|
7
5
|
require 'vagrant-libvirt/action/destroy_domain'
|
8
6
|
|
@@ -19,14 +17,10 @@ describe VagrantPlugins::ProviderLibvirt::Action::DestroyDomain do
|
|
19
17
|
|
20
18
|
let(:domain_xml) { File.read(File.join(File.dirname(__FILE__), File.basename(__FILE__, '.rb'), domain_xml_file)) }
|
21
19
|
|
22
|
-
let(:destroy_method) { double('destroy_method') }
|
23
|
-
|
24
20
|
before do
|
25
21
|
allow(machine.provider).to receive('driver').and_return(driver)
|
26
22
|
allow(driver).to receive(:connection).and_return(connection)
|
27
23
|
allow(logger).to receive(:info)
|
28
|
-
allow(domain).to receive(:method).with(:destroy).and_return(destroy_method)
|
29
|
-
allow(destroy_method).to receive(:parameters).and_return([[:opt, :options, :flags]])
|
30
24
|
end
|
31
25
|
|
32
26
|
describe '#call' do
|
@@ -205,17 +199,6 @@ describe VagrantPlugins::ProviderLibvirt::Action::DestroyDomain do
|
|
205
199
|
expect(domain).to receive(:destroy).with(destroy_volumes: true, flags: VagrantPlugins::ProviderLibvirt::Util::DomainFlags::VIR_DOMAIN_UNDEFINE_KEEP_NVRAM)
|
206
200
|
expect(subject.call(env)).to be_nil
|
207
201
|
end
|
208
|
-
|
209
|
-
context 'when fog does not support destroy with flags' do
|
210
|
-
before do
|
211
|
-
expect(destroy_method).to receive(:parameters).and_return([[:opt, :options]])
|
212
|
-
end
|
213
|
-
|
214
|
-
it 'skips setting additional destroy flags' do
|
215
|
-
expect(domain).to receive(:destroy).with(destroy_volumes: true)
|
216
|
-
expect(subject.call(env)).to be_nil
|
217
|
-
end
|
218
|
-
end
|
219
202
|
end
|
220
203
|
|
221
204
|
context 'when has CDROMs attached' do
|
@@ -1,8 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require 'support/libvirt_context'
|
3
|
+
require_relative '../../spec_helper'
|
4
|
+
|
6
5
|
require 'vagrant-libvirt/action/halt_domain'
|
7
6
|
|
8
7
|
describe VagrantPlugins::ProviderLibvirt::Action::HaltDomain do
|
@@ -1,11 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative '../../spec_helper'
|
4
|
+
|
4
5
|
require 'json'
|
5
|
-
require 'support/sharedcontext'
|
6
|
-
require 'support/libvirt_context'
|
7
6
|
|
8
|
-
require 'vagrant-libvirt/action/
|
7
|
+
require 'vagrant-libvirt/action/handle_box_image'
|
9
8
|
require 'vagrant-libvirt/util/byte_number'
|
10
9
|
|
11
10
|
|
@@ -1,9 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'support/sharedcontext'
|
3
|
+
require_relative '../../spec_helper'
|
5
4
|
|
6
|
-
require 'vagrant-libvirt/action/
|
5
|
+
require 'vagrant-libvirt/action/package_domain'
|
7
6
|
|
8
7
|
describe VagrantPlugins::ProviderLibvirt::Action::PackageDomain do
|
9
8
|
subject { described_class.new(app, env) }
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'support/sharedcontext'
|
3
|
+
require_relative '../../spec_helper'
|
5
4
|
|
6
5
|
require 'vagrant-libvirt/action/prepare_nfs_settings'
|
7
6
|
|
@@ -35,7 +34,6 @@ describe VagrantPlugins::ProviderLibvirt::Action::PrepareNFSSettings do
|
|
35
34
|
let(:udp_socket) { double('udp_socket') }
|
36
35
|
|
37
36
|
before do
|
38
|
-
allow(::TCPSocket).to receive(:new).and_return(socket)
|
39
37
|
allow(socket).to receive(:close)
|
40
38
|
|
41
39
|
allow(::UDPSocket).to receive(:open).and_return(udp_socket)
|
@@ -43,17 +41,35 @@ describe VagrantPlugins::ProviderLibvirt::Action::PrepareNFSSettings do
|
|
43
41
|
end
|
44
42
|
|
45
43
|
it 'should retrieve the guest IP address' do
|
46
|
-
|
47
|
-
expect(::TCPSocket).to receive(:new)
|
48
|
-
# force reaching later code
|
49
|
-
times_called += 1
|
50
|
-
times_called < 2 ? raise("StandardError") : socket
|
51
|
-
end
|
44
|
+
expect(::TCPSocket).to receive(:new).with('192.168.1.2', 'ssh').and_raise(StandardError)
|
45
|
+
expect(::TCPSocket).to receive(:new).with('192.168.2.2', 'ssh').and_return(socket)
|
52
46
|
expect(machine).to receive(:ssh_info).and_return({:host => '192.168.1.2'})
|
53
47
|
expect(communicator).to receive(:execute).and_yield(:stdout, "192.168.1.2\n192.168.2.2")
|
54
48
|
|
55
49
|
expect(subject.call(env)).to be_nil
|
56
50
|
end
|
51
|
+
|
52
|
+
it 'should use the ip if connection refused' do
|
53
|
+
expect(::TCPSocket).to receive(:new).with('192.168.1.2', 'ssh').and_raise(Errno::ECONNREFUSED)
|
54
|
+
expect(machine).to receive(:ssh_info).and_return({:host => '192.168.1.2'})
|
55
|
+
|
56
|
+
expect(subject.call(env)).to be_nil
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should use the ssh port defined' do
|
60
|
+
expect(::TCPSocket).to receive(:new).with('192.168.1.2', '2022').and_return(socket)
|
61
|
+
expect(machine).to receive(:ssh_info).and_return({:host => '192.168.1.2', :port => '2022'})
|
62
|
+
|
63
|
+
expect(subject.call(env)).to be_nil
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should raise an exception if machine ip not found' do
|
67
|
+
expect(::TCPSocket).to receive(:new).with('192.168.1.2', 'ssh').and_raise(StandardError)
|
68
|
+
expect(machine).to receive(:ssh_info).and_return({:host => '192.168.1.2'})
|
69
|
+
expect(communicator).to receive(:execute).and_yield(:stdout, "192.168.1.2")
|
70
|
+
|
71
|
+
expect { subject.call(env) }.to raise_error(::Vagrant::Errors::NFSNoHostonlyNetwork)
|
72
|
+
end
|
57
73
|
end
|
58
74
|
end
|
59
75
|
end
|