vagrant-libvirt 0.5.3 → 0.6.0
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/README.md +110 -18
- data/lib/vagrant-libvirt/action/clean_machine_folder.rb +2 -0
- data/lib/vagrant-libvirt/action/create_domain.rb +8 -1
- data/lib/vagrant-libvirt/action/create_domain_volume.rb +5 -0
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +8 -2
- data/lib/vagrant-libvirt/action/create_networks.rb +12 -8
- data/lib/vagrant-libvirt/action/destroy_domain.rb +2 -0
- data/lib/vagrant-libvirt/action/destroy_networks.rb +2 -0
- data/lib/vagrant-libvirt/action/forward_ports.rb +7 -5
- data/lib/vagrant-libvirt/action/halt_domain.rb +4 -34
- data/lib/vagrant-libvirt/action/handle_box_image.rb +3 -3
- data/lib/vagrant-libvirt/action/handle_storage_pool.rb +7 -1
- data/lib/vagrant-libvirt/action/is_created.rb +2 -0
- data/lib/vagrant-libvirt/action/is_running.rb +2 -0
- data/lib/vagrant-libvirt/action/is_suspended.rb +2 -0
- data/lib/vagrant-libvirt/action/message_already_created.rb +2 -0
- data/lib/vagrant-libvirt/action/message_not_created.rb +2 -0
- data/lib/vagrant-libvirt/action/message_not_running.rb +2 -0
- data/lib/vagrant-libvirt/action/message_not_suspended.rb +2 -0
- data/lib/vagrant-libvirt/action/message_will_not_destroy.rb +2 -0
- data/lib/vagrant-libvirt/action/package_domain.rb +133 -68
- data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +2 -0
- data/lib/vagrant-libvirt/action/prepare_nfs_valid_ids.rb +2 -0
- data/lib/vagrant-libvirt/action/prune_nfs_exports.rb +2 -0
- data/lib/vagrant-libvirt/action/read_mac_addresses.rb +2 -0
- data/lib/vagrant-libvirt/action/remove_libvirt_image.rb +2 -0
- data/lib/vagrant-libvirt/action/remove_stale_volume.rb +2 -0
- data/lib/vagrant-libvirt/action/resume_domain.rb +2 -0
- data/lib/vagrant-libvirt/action/set_boot_order.rb +2 -0
- data/lib/vagrant-libvirt/action/set_name_of_domain.rb +3 -1
- data/lib/vagrant-libvirt/action/share_folders.rb +2 -0
- data/lib/vagrant-libvirt/action/shutdown_domain.rb +49 -0
- data/lib/vagrant-libvirt/action/start_domain.rb +26 -17
- data/lib/vagrant-libvirt/action/suspend_domain.rb +2 -0
- data/lib/vagrant-libvirt/action/wait_till_up.rb +2 -0
- data/lib/vagrant-libvirt/action.rb +34 -4
- data/lib/vagrant-libvirt/cap/mount_9p.rb +2 -0
- data/lib/vagrant-libvirt/cap/mount_virtiofs.rb +2 -0
- data/lib/vagrant-libvirt/cap/nic_mac_addresses.rb +2 -0
- data/lib/vagrant-libvirt/cap/public_address.rb +2 -0
- data/lib/vagrant-libvirt/cap/synced_folder_9p.rb +5 -2
- data/lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb +5 -2
- data/lib/vagrant-libvirt/config.rb +49 -25
- data/lib/vagrant-libvirt/driver.rb +67 -12
- data/lib/vagrant-libvirt/errors.rb +2 -0
- data/lib/vagrant-libvirt/plugin.rb +2 -0
- data/lib/vagrant-libvirt/provider.rb +2 -0
- data/lib/vagrant-libvirt/templates/domain.xml.erb +4 -2
- data/lib/vagrant-libvirt/templates/public_interface.xml.erb +1 -0
- data/lib/vagrant-libvirt/util/collection.rb +2 -0
- data/lib/vagrant-libvirt/util/erb_template.rb +2 -0
- data/lib/vagrant-libvirt/util/error_codes.rb +2 -0
- data/lib/vagrant-libvirt/util/network_util.rb +3 -0
- data/lib/vagrant-libvirt/util/nfs.rb +2 -0
- data/lib/vagrant-libvirt/util/storage_util.rb +1 -0
- data/lib/vagrant-libvirt/util/timer.rb +2 -0
- data/lib/vagrant-libvirt/util/ui.rb +1 -0
- data/lib/vagrant-libvirt/util.rb +2 -0
- data/lib/vagrant-libvirt/version +1 -1
- data/lib/vagrant-libvirt/version.rb +2 -0
- data/lib/vagrant-libvirt.rb +2 -0
- data/locales/en.yml +2 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/binding_proc.rb +2 -0
- data/spec/support/environment_helper.rb +2 -0
- data/spec/support/libvirt_context.rb +2 -0
- data/spec/support/matchers/have_file_content.rb +2 -0
- data/spec/support/sharedcontext.rb +3 -0
- data/spec/support/temporary_dir.rb +12 -0
- data/spec/unit/action/clean_machine_folder_spec.rb +2 -0
- data/spec/unit/action/create_domain_spec/additional_disks_domain.xml +7 -0
- data/spec/unit/action/create_domain_spec/default_domain.xml +6 -0
- data/spec/unit/action/create_domain_spec.rb +62 -30
- data/spec/unit/action/create_domain_volume_spec.rb +4 -0
- data/spec/unit/action/destroy_domain_spec.rb +8 -2
- data/spec/unit/action/forward_ports_spec.rb +2 -0
- data/spec/unit/action/halt_domain_spec.rb +30 -57
- data/spec/unit/action/handle_box_image_spec.rb +6 -4
- data/spec/unit/action/package_domain_spec.rb +304 -0
- data/spec/unit/action/set_name_of_domain_spec.rb +2 -0
- data/spec/unit/action/shutdown_domain_spec.rb +131 -0
- data/spec/unit/action/start_domain_spec/existing.xml +62 -0
- data/spec/unit/action/start_domain_spec.rb +18 -28
- data/spec/unit/action/wait_till_up_spec.rb +2 -0
- data/spec/unit/action_spec.rb +96 -0
- data/spec/unit/config_spec.rb +52 -2
- data/spec/unit/driver_spec.rb +155 -0
- data/spec/unit/templates/domain_all_settings.xml +4 -0
- data/spec/unit/templates/domain_spec.rb +2 -0
- data/spec/unit/util/byte_number_spec.rb +2 -0
- metadata +53 -41
@@ -1,8 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'support/sharedcontext'
|
3
5
|
require 'support/libvirt_context'
|
4
6
|
|
5
7
|
require 'vagrant-libvirt/errors'
|
8
|
+
require 'vagrant-libvirt/util/byte_number'
|
6
9
|
require 'vagrant-libvirt/action/create_domain'
|
7
10
|
|
8
11
|
describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
|
@@ -14,6 +17,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
|
|
14
17
|
let(:libvirt_client) { double('libvirt_client') }
|
15
18
|
let(:servers) { double('servers') }
|
16
19
|
let(:volumes) { double('volumes') }
|
20
|
+
let(:domain_volume) { double('domain_volume') }
|
17
21
|
|
18
22
|
let(:domain_xml) { File.read(File.join(File.dirname(__FILE__), File.basename(__FILE__, '.rb'), domain_xml_file)) }
|
19
23
|
let(:storage_pool_xml) { File.read(File.join(File.dirname(__FILE__), File.basename(__FILE__, '.rb'), storage_pool_xml_file)) }
|
@@ -27,8 +31,15 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
|
|
27
31
|
|
28
32
|
allow(connection).to receive(:servers).and_return(servers)
|
29
33
|
allow(connection).to receive(:volumes).and_return(volumes)
|
34
|
+
allow(volumes).to receive(:all).and_return([domain_volume])
|
35
|
+
allow(domain_volume).to receive(:pool_name).and_return('default')
|
36
|
+
allow(domain_volume).to receive(:[]).with('name').and_return('vagrant-test_default.img')
|
37
|
+
allow(domain_volume).to receive(:path).and_return('/var/lib/libvirt/images/vagrant-test_default.img')
|
38
|
+
allow(machine).to receive_message_chain("box.name") { 'vagrant-libvirt/test' }
|
30
39
|
|
31
40
|
allow(logger).to receive(:info)
|
41
|
+
allow(logger).to receive(:debug)
|
42
|
+
allow(ui).to receive(:info)
|
32
43
|
|
33
44
|
env[:domain_name] = "vagrant-test_default"
|
34
45
|
|
@@ -36,7 +47,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
|
|
36
47
|
env[:box_volumes].push({
|
37
48
|
:path=>"/test/box.img",
|
38
49
|
:name=>"test_vagrant_box_image_1.1.1_0.img",
|
39
|
-
:virtual_size=>5
|
50
|
+
:virtual_size=> ByteNumber.new(5),
|
40
51
|
})
|
41
52
|
# should be ignored for system session and used for user session
|
42
53
|
allow(Process).to receive(:uid).and_return(9999)
|
@@ -44,35 +55,44 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
|
|
44
55
|
end
|
45
56
|
|
46
57
|
context 'connection => qemu:///system' do
|
47
|
-
|
48
|
-
let(:domain_xml_file) { 'default_domain.xml' }
|
49
|
-
let(:storage_pool_xml_file) { 'default_system_storage_pool.xml' }
|
58
|
+
let(:domain_xml_file) { 'default_domain.xml' }
|
50
59
|
|
60
|
+
context 'default pool' do
|
51
61
|
it 'should execute correctly' do
|
52
|
-
expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
|
53
|
-
expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
|
54
62
|
expect(servers).to receive(:create).with(xml: domain_xml).and_return(machine)
|
55
63
|
expect(volumes).to_not receive(:create) # additional disks only
|
56
64
|
|
57
65
|
expect(subject.call(env)).to be_nil
|
58
66
|
end
|
59
67
|
|
60
|
-
context '
|
68
|
+
context 'with no box' do
|
69
|
+
let(:storage_pool_xml_file) { 'default_system_storage_pool.xml' }
|
61
70
|
let(:vagrantfile) do
|
62
71
|
<<-EOF
|
63
72
|
Vagrant.configure('2') do |config|
|
64
73
|
config.vm.define :test
|
65
|
-
config.vm.provider :libvirt do |libvirt|
|
66
|
-
libvirt.storage :file, :size => '20G'
|
67
|
-
end
|
68
74
|
end
|
69
75
|
EOF
|
70
76
|
end
|
71
77
|
|
78
|
+
it 'should query for the storage pool path' do
|
79
|
+
expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
|
80
|
+
expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
|
81
|
+
expect(servers).to receive(:create).and_return(machine)
|
82
|
+
|
83
|
+
expect(subject.call(env)).to be_nil
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'additional disks' do
|
88
|
+
let(:vagrantfile_providerconfig) do
|
89
|
+
<<-EOF
|
90
|
+
libvirt.storage :file, :size => '20G'
|
91
|
+
EOF
|
92
|
+
end
|
93
|
+
|
72
94
|
context 'volume create failed' do
|
73
95
|
it 'should raise an exception' do
|
74
|
-
expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
|
75
|
-
expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
|
76
96
|
expect(volumes).to receive(:create).and_raise(Libvirt::Error)
|
77
97
|
|
78
98
|
expect{ subject.call(env) }.to raise_error(VagrantPlugins::ProviderLibvirt::Errors::FogCreateDomainVolumeError)
|
@@ -83,8 +103,6 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
|
|
83
103
|
let(:domain_xml_file) { 'additional_disks_domain.xml' }
|
84
104
|
|
85
105
|
it 'should complete' do
|
86
|
-
expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
|
87
|
-
expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
|
88
106
|
expect(volumes).to receive(:create).with(
|
89
107
|
hash_including(
|
90
108
|
:path => "/var/lib/libvirt/images/vagrant-test_default-vdb.qcow2",
|
@@ -102,6 +120,14 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
|
|
102
120
|
end
|
103
121
|
|
104
122
|
context 'no default pool' do
|
123
|
+
let(:vagrantfile) do
|
124
|
+
<<-EOF
|
125
|
+
Vagrant.configure('2') do |config|
|
126
|
+
config.vm.define :test
|
127
|
+
end
|
128
|
+
EOF
|
129
|
+
end
|
130
|
+
|
105
131
|
it 'should raise an exception' do
|
106
132
|
expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(nil)
|
107
133
|
|
@@ -111,45 +137,51 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
|
|
111
137
|
end
|
112
138
|
|
113
139
|
context 'connection => qemu:///session' do
|
114
|
-
let(:
|
140
|
+
let(:vagrantfile_providerconfig) do
|
115
141
|
<<-EOF
|
116
|
-
|
117
|
-
config.vm.define :test
|
118
|
-
config.vm.provider :libvirt do |libvirt|
|
119
|
-
libvirt.qemu_use_session = true
|
120
|
-
end
|
121
|
-
end
|
142
|
+
libvirt.qemu_use_session = true
|
122
143
|
EOF
|
123
144
|
end
|
124
145
|
|
125
146
|
context 'default pool' do
|
126
|
-
let(:storage_pool_xml_file) { 'default_user_storage_pool.xml' }
|
127
|
-
|
128
147
|
it 'should execute correctly' do
|
129
|
-
expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
|
130
|
-
expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
|
131
148
|
expect(servers).to receive(:create).and_return(machine)
|
132
149
|
|
133
150
|
expect(subject.call(env)).to be_nil
|
134
151
|
end
|
135
152
|
|
136
|
-
context '
|
153
|
+
context 'with no box' do
|
154
|
+
let(:storage_pool_xml_file) { 'default_user_storage_pool.xml' }
|
137
155
|
let(:vagrantfile) do
|
138
156
|
<<-EOF
|
139
157
|
Vagrant.configure('2') do |config|
|
140
158
|
config.vm.define :test
|
141
159
|
config.vm.provider :libvirt do |libvirt|
|
142
|
-
|
143
|
-
libvirt.storage :file, :size => '20G'
|
160
|
+
#{vagrantfile_providerconfig}
|
144
161
|
end
|
145
162
|
end
|
146
163
|
EOF
|
147
164
|
end
|
148
165
|
|
166
|
+
it 'should query for the storage pool path' do
|
167
|
+
expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
|
168
|
+
expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
|
169
|
+
expect(servers).to receive(:create).and_return(machine)
|
170
|
+
|
171
|
+
expect(subject.call(env)).to be_nil
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
context 'additional disks' do
|
176
|
+
let(:vagrantfile_providerconfig) do
|
177
|
+
<<-EOF
|
178
|
+
libvirt.qemu_use_session = true
|
179
|
+
libvirt.storage :file, :size => '20G'
|
180
|
+
EOF
|
181
|
+
end
|
182
|
+
|
149
183
|
context 'volume create succeeded' do
|
150
184
|
it 'should complete' do
|
151
|
-
expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
|
152
|
-
expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
|
153
185
|
expect(volumes).to receive(:create).with(
|
154
186
|
hash_including(
|
155
187
|
:path => "/var/lib/libvirt/images/vagrant-test_default-vdb.qcow2",
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'support/sharedcontext'
|
3
5
|
require 'support/libvirt_context'
|
@@ -32,6 +34,8 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomainVolume do
|
|
32
34
|
allow(all).to receive(:first).and_return(box_volume)
|
33
35
|
allow(box_volume).to receive(:id).and_return(nil)
|
34
36
|
env[:domain_name] = 'test'
|
37
|
+
|
38
|
+
allow(logger).to receive(:debug)
|
35
39
|
end
|
36
40
|
|
37
41
|
context 'when one disk' do
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'support/sharedcontext'
|
3
5
|
require 'support/libvirt_context'
|
@@ -10,14 +12,18 @@ describe VagrantPlugins::ProviderLibvirt::Action::DestroyDomain do
|
|
10
12
|
include_context 'unit'
|
11
13
|
include_context 'libvirt'
|
12
14
|
|
15
|
+
let(:driver) { double('driver') }
|
13
16
|
let(:libvirt_domain) { double('libvirt_domain') }
|
14
17
|
let(:libvirt_client) { double('libvirt_client') }
|
15
18
|
let(:servers) { double('servers') }
|
16
19
|
|
20
|
+
before do
|
21
|
+
allow(machine.provider).to receive('driver').and_return(driver)
|
22
|
+
allow(driver).to receive(:connection).and_return(connection)
|
23
|
+
end
|
24
|
+
|
17
25
|
describe '#call' do
|
18
26
|
before do
|
19
|
-
allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver)
|
20
|
-
.to receive(:connection).and_return(connection)
|
21
27
|
allow(connection).to receive(:client).and_return(libvirt_client)
|
22
28
|
allow(libvirt_client).to receive(:lookup_domain_by_uuid)
|
23
29
|
.and_return(libvirt_domain)
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'support/sharedcontext'
|
3
5
|
require 'support/libvirt_context'
|
4
|
-
require 'vagrant-libvirt/action/
|
6
|
+
require 'vagrant-libvirt/action/halt_domain'
|
5
7
|
|
6
8
|
describe VagrantPlugins::ProviderLibvirt::Action::HaltDomain do
|
7
9
|
subject { described_class.new(app, env) }
|
@@ -9,81 +11,52 @@ describe VagrantPlugins::ProviderLibvirt::Action::HaltDomain do
|
|
9
11
|
include_context 'unit'
|
10
12
|
include_context 'libvirt'
|
11
13
|
|
14
|
+
let(:driver) { double('driver') }
|
12
15
|
let(:libvirt_domain) { double('libvirt_domain') }
|
13
16
|
let(:servers) { double('servers') }
|
14
17
|
|
18
|
+
before do
|
19
|
+
allow(machine.provider).to receive('driver').and_return(driver)
|
20
|
+
allow(driver).to receive(:created?).and_return(true)
|
21
|
+
allow(driver).to receive(:connection).and_return(connection)
|
22
|
+
end
|
23
|
+
|
15
24
|
describe '#call' do
|
16
25
|
before do
|
17
|
-
allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver)
|
18
|
-
.to receive(:connection).and_return(connection)
|
19
26
|
allow(connection).to receive(:servers).and_return(servers)
|
20
27
|
allow(servers).to receive(:get).and_return(domain)
|
21
|
-
|
22
|
-
expect(ui).to receive(:info).with('Halting domain...')
|
28
|
+
allow(ui).to receive(:info).with('Halting domain...')
|
23
29
|
end
|
24
30
|
|
25
|
-
context
|
26
|
-
|
27
|
-
|
28
|
-
expect(domain).to receive(:wait_for).with(60).and_return(false)
|
29
|
-
expect(subject.call(env)).to be_nil
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'when halt fails' do
|
33
|
-
before do
|
34
|
-
expect(logger).to receive(:info).with('Trying Libvirt graceful shutdown.')
|
35
|
-
expect(guest).to receive(:capability).with(:halt).and_raise(IOError)
|
36
|
-
expect(domain).to receive(:state).and_return('running')
|
37
|
-
end
|
31
|
+
context "when state is not running" do
|
32
|
+
before { expect(driver).to receive(:state).at_least(1).
|
33
|
+
and_return(:not_created) }
|
38
34
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
expect(subject.call(env)).to be_nil
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'when shutdown fails' do
|
46
|
-
it "should call power off" do
|
47
|
-
expect(logger).to receive(:error).with('Failed to shutdown cleanly. Calling force poweroff.')
|
48
|
-
expect(domain).to receive(:shutdown).and_raise(IOError)
|
49
|
-
expect(domain).to receive(:poweroff)
|
50
|
-
expect(subject.call(env)).to be_nil
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'when shutdown exceeds the timeout' do
|
55
|
-
it "should call poweroff" do
|
56
|
-
expect(logger).to receive(:info).with('VM is still running. Calling force poweroff.')
|
57
|
-
expect(domain).to receive(:shutdown).and_raise(Timeout::Error)
|
58
|
-
expect(domain).to receive(:poweroff)
|
59
|
-
expect(subject.call(env)).to be_nil
|
60
|
-
end
|
61
|
-
end
|
35
|
+
it "should not poweroff when state is not running" do
|
36
|
+
expect(domain).not_to receive(:poweroff)
|
37
|
+
subject.call(env)
|
62
38
|
end
|
63
39
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
expect(guest).to receive(:capability).with(:halt).and_raise(Timeout::Error)
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should call poweroff" do
|
71
|
-
expect(logger).to receive(:info).with('VM is still running. Calling force poweroff.')
|
72
|
-
expect(domain).to receive(:poweroff)
|
73
|
-
expect(subject.call(env)).to be_nil
|
74
|
-
end
|
40
|
+
it "should not print halting message" do
|
41
|
+
expect(ui).not_to receive(:info)
|
42
|
+
subject.call(env)
|
75
43
|
end
|
76
44
|
end
|
77
45
|
|
78
|
-
context
|
46
|
+
context "when state is running" do
|
79
47
|
before do
|
80
|
-
|
81
|
-
expect(env).to receive(:[]).with(:force_halt).and_return(true)
|
48
|
+
expect(driver).to receive(:state).and_return(:running)
|
82
49
|
end
|
83
50
|
|
84
|
-
it "should
|
51
|
+
it "should poweroff" do
|
85
52
|
expect(domain).to receive(:poweroff)
|
86
|
-
|
53
|
+
subject.call(env)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should print halting message" do
|
57
|
+
allow(domain).to receive(:poweroff)
|
58
|
+
expect(ui).to receive(:info).with('Halting domain...')
|
59
|
+
subject.call(env)
|
87
60
|
end
|
88
61
|
end
|
89
62
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'json'
|
3
5
|
require 'support/sharedcontext'
|
@@ -77,7 +79,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
|
|
77
79
|
]
|
78
80
|
}
|
79
81
|
allow(env[:machine]).to receive_message_chain("box.directory.join") do |arg|
|
80
|
-
'/test/'
|
82
|
+
'/test/' + arg.to_s
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|
@@ -197,7 +199,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
|
|
197
199
|
],
|
198
200
|
]}
|
199
201
|
allow(env[:machine]).to receive_message_chain("box.directory.join") do |arg|
|
200
|
-
'/test/'
|
202
|
+
'/test/' + arg.to_s
|
201
203
|
end
|
202
204
|
allow(status).to receive(:success?).and_return(true)
|
203
205
|
allow(Open3).to receive(:capture3).with('qemu-img', 'info', '--output=json', '/test/box.img').and_return([
|
@@ -334,7 +336,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
|
|
334
336
|
]
|
335
337
|
}
|
336
338
|
allow(env[:machine]).to receive_message_chain("box.directory.join") do |arg|
|
337
|
-
'/test/'
|
339
|
+
'/test/' + arg.to_s
|
338
340
|
end
|
339
341
|
end
|
340
342
|
|
@@ -354,7 +356,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
|
|
354
356
|
allow(env[:machine]).to receive_message_chain("box.version") { '1.1.1' }
|
355
357
|
allow(env[:machine]).to receive_message_chain("box.metadata") { box_metadata }
|
356
358
|
allow(env[:machine]).to receive_message_chain("box.directory.join") do |arg|
|
357
|
-
'/test/'
|
359
|
+
'/test/' + arg.to_s
|
358
360
|
end
|
359
361
|
allow(status).to receive(:success?).and_return(true)
|
360
362
|
allow(Open3).to receive(:capture3).with('qemu-img', 'info', "--output=json", '/test/box.img').and_return([
|