vagrant-libvirt 0.7.0 → 0.8.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 +25 -9
- data/lib/vagrant-libvirt/action/cleanup_on_failure.rb +76 -0
- data/lib/vagrant-libvirt/action/create_domain.rb +45 -23
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +5 -1
- data/lib/vagrant-libvirt/action/create_networks.rb +13 -0
- data/lib/vagrant-libvirt/action/destroy_domain.rb +106 -21
- data/lib/vagrant-libvirt/action/destroy_networks.rb +1 -1
- data/lib/vagrant-libvirt/action/forward_ports.rb +12 -11
- data/lib/vagrant-libvirt/action/wait_till_up.rb +6 -32
- data/lib/vagrant-libvirt/action.rb +67 -80
- data/lib/vagrant-libvirt/config.rb +45 -33
- data/lib/vagrant-libvirt/driver.rb +3 -1
- data/lib/vagrant-libvirt/errors.rb +8 -0
- data/lib/vagrant-libvirt/templates/domain.xml.erb +223 -226
- data/lib/vagrant-libvirt/templates/private_network.xml.erb +4 -1
- data/lib/vagrant-libvirt/util/network_util.rb +13 -2
- data/lib/vagrant-libvirt/util/resolvers.rb +80 -0
- data/lib/vagrant-libvirt/version +1 -1
- data/locales/en.yml +13 -0
- data/spec/spec_helper.rb +33 -28
- data/spec/support/libvirt_context.rb +3 -3
- data/spec/unit/action/cleanup_on_failure_spec.rb +131 -0
- data/spec/unit/action/create_domain_spec/additional_disks_domain.xml +6 -18
- data/spec/unit/action/create_domain_spec/custom_disk_settings.xml +43 -0
- data/spec/unit/action/create_domain_spec/default_domain.xml +6 -18
- data/spec/unit/action/create_domain_spec/two_disk_settings.xml +49 -0
- data/spec/unit/action/create_domain_spec.rb +51 -7
- data/spec/unit/action/create_domain_volume_spec.rb +5 -3
- data/spec/unit/action/destroy_domain_spec/additional_disks_domain.xml +47 -0
- data/spec/unit/action/destroy_domain_spec/box_multiple_disks.xml +55 -0
- data/spec/unit/action/destroy_domain_spec/box_multiple_disks_and_additional_and_custom_disks.xml +72 -0
- data/spec/unit/action/destroy_domain_spec/box_multiple_disks_and_additional_and_custom_disks_no_aliases.xml +67 -0
- data/spec/unit/action/destroy_domain_spec/box_multiple_disks_and_additional_disks.xml +67 -0
- data/spec/unit/action/destroy_domain_spec/cdrom_domain.xml +48 -0
- data/spec/unit/action/destroy_domain_spec.rb +134 -30
- data/spec/unit/action/forward_ports_spec.rb +10 -2
- data/spec/unit/action/prepare_nfs_settings_spec.rb +4 -0
- data/spec/unit/action/start_domain_spec/clock_timer_rtc.xml +6 -18
- data/spec/unit/action/start_domain_spec/default.xml +6 -18
- data/spec/unit/action/start_domain_spec/default_added_tpm_path.xml +6 -18
- data/spec/unit/action/start_domain_spec/default_added_tpm_version.xml +6 -18
- data/spec/unit/action/start_domain_spec/existing.xml +1 -1
- data/spec/unit/action/wait_till_up_spec.rb +2 -42
- data/spec/unit/action_spec.rb +2 -0
- data/spec/unit/config_spec.rb +85 -26
- data/spec/unit/driver_spec.rb +17 -8
- data/spec/unit/provider_spec.rb +11 -0
- data/spec/unit/templates/domain_all_settings.xml +52 -79
- data/spec/unit/templates/domain_cpu_mode_passthrough.xml +39 -0
- data/spec/unit/templates/domain_custom_cpu_model.xml +6 -18
- data/spec/unit/templates/domain_defaults.xml +6 -18
- data/spec/unit/templates/domain_spec.rb +36 -13
- data/spec/unit/templates/tpm/version_1.2.xml +6 -18
- data/spec/unit/templates/tpm/version_2.0.xml +6 -18
- data/spec/unit/util/resolvers_spec.rb +116 -0
- metadata +62 -64
@@ -5,15 +5,11 @@
|
|
5
5
|
<uuid/>
|
6
6
|
<memory/>
|
7
7
|
<vcpu>1</vcpu>
|
8
|
-
|
9
|
-
|
10
8
|
<cpu mode='host-model'>
|
11
|
-
|
9
|
+
<model fallback='allow'/>
|
12
10
|
</cpu>
|
13
|
-
|
14
|
-
|
15
11
|
<os>
|
16
|
-
|
12
|
+
<type>hvm</type>
|
17
13
|
<kernel/>
|
18
14
|
<initrd/>
|
19
15
|
<cmdline/>
|
@@ -25,24 +21,16 @@
|
|
25
21
|
</features>
|
26
22
|
<clock offset='utc'/>
|
27
23
|
<devices>
|
28
|
-
|
29
|
-
|
30
24
|
<serial type='pty'>
|
31
25
|
<target port='0'/>
|
32
26
|
</serial>
|
33
27
|
<console type='pty'>
|
34
28
|
<target port='0'/>
|
35
29
|
</console>
|
36
|
-
|
37
|
-
|
38
30
|
<input bus='ps2' type='mouse'/>
|
39
|
-
|
40
|
-
|
41
|
-
<
|
42
|
-
|
43
|
-
</video>
|
44
|
-
|
45
|
-
|
31
|
+
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'/>
|
32
|
+
<video>
|
33
|
+
<model heads='1' type='cirrus' vram='16384'/>
|
34
|
+
</video>
|
46
35
|
</devices>
|
47
|
-
|
48
36
|
</domain>
|
@@ -5,15 +5,11 @@
|
|
5
5
|
<uuid/>
|
6
6
|
<memory/>
|
7
7
|
<vcpu>1</vcpu>
|
8
|
-
|
9
|
-
|
10
8
|
<cpu mode='host-model'>
|
11
|
-
|
9
|
+
<model fallback='allow'/>
|
12
10
|
</cpu>
|
13
|
-
|
14
|
-
|
15
11
|
<os>
|
16
|
-
|
12
|
+
<type>hvm</type>
|
17
13
|
<kernel/>
|
18
14
|
<initrd/>
|
19
15
|
<cmdline/>
|
@@ -25,24 +21,16 @@
|
|
25
21
|
</features>
|
26
22
|
<clock offset='utc'/>
|
27
23
|
<devices>
|
28
|
-
|
29
|
-
|
30
24
|
<serial type='pty'>
|
31
25
|
<target port='0'/>
|
32
26
|
</serial>
|
33
27
|
<console type='pty'>
|
34
28
|
<target port='0'/>
|
35
29
|
</console>
|
36
|
-
|
37
|
-
|
38
30
|
<input bus='ps2' type='mouse'/>
|
39
|
-
|
40
|
-
|
41
|
-
<
|
42
|
-
|
43
|
-
</video>
|
44
|
-
|
45
|
-
|
31
|
+
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'/>
|
32
|
+
<video>
|
33
|
+
<model heads='1' type='cirrus' vram='16384'/>
|
34
|
+
</video>
|
46
35
|
<tpm model='tpm-tis'><backend type='passthrough'><device path='/dev/tpm0'/></backend></tpm></devices>
|
47
|
-
|
48
36
|
</domain>
|
@@ -5,15 +5,11 @@
|
|
5
5
|
<uuid/>
|
6
6
|
<memory/>
|
7
7
|
<vcpu>1</vcpu>
|
8
|
-
|
9
|
-
|
10
8
|
<cpu mode='host-model'>
|
11
|
-
|
9
|
+
<model fallback='allow'/>
|
12
10
|
</cpu>
|
13
|
-
|
14
|
-
|
15
11
|
<os>
|
16
|
-
|
12
|
+
<type>hvm</type>
|
17
13
|
<kernel/>
|
18
14
|
<initrd/>
|
19
15
|
<cmdline/>
|
@@ -25,24 +21,16 @@
|
|
25
21
|
</features>
|
26
22
|
<clock offset='utc'/>
|
27
23
|
<devices>
|
28
|
-
|
29
|
-
|
30
24
|
<serial type='pty'>
|
31
25
|
<target port='0'/>
|
32
26
|
</serial>
|
33
27
|
<console type='pty'>
|
34
28
|
<target port='0'/>
|
35
29
|
</console>
|
36
|
-
|
37
|
-
|
38
30
|
<input bus='ps2' type='mouse'/>
|
39
|
-
|
40
|
-
|
41
|
-
<
|
42
|
-
|
43
|
-
</video>
|
44
|
-
|
45
|
-
|
31
|
+
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'/>
|
32
|
+
<video>
|
33
|
+
<model heads='1' type='cirrus' vram='16384'/>
|
34
|
+
</video>
|
46
35
|
<tpm model='tpm-crb'><backend type='emulator' version='2.0'/></tpm></devices>
|
47
|
-
|
48
36
|
</domain>
|
@@ -52,7 +52,7 @@
|
|
52
52
|
</graphics>
|
53
53
|
<audio id='1' type='none'/>
|
54
54
|
<video>
|
55
|
-
<model type='cirrus' vram='
|
55
|
+
<model type='cirrus' vram='16384' heads='1' primary='yes'/>
|
56
56
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
|
57
57
|
</video>
|
58
58
|
<memballoon model='virtio'>
|
@@ -24,6 +24,8 @@ describe VagrantPlugins::ProviderLibvirt::Action::WaitTillUp do
|
|
24
24
|
allow(driver).to receive(:state).and_return(:running)
|
25
25
|
# return some information for domain when needed
|
26
26
|
allow(domain).to receive(:mac).and_return('9C:D5:53:F1:5A:E7')
|
27
|
+
|
28
|
+
allow(machine.provider_config).to receive(:qemu_use_session).and_return(false)
|
27
29
|
end
|
28
30
|
|
29
31
|
context 'when machine does not exist' do
|
@@ -86,46 +88,4 @@ describe VagrantPlugins::ProviderLibvirt::Action::WaitTillUp do
|
|
86
88
|
end
|
87
89
|
end
|
88
90
|
end
|
89
|
-
|
90
|
-
describe '#recover' do
|
91
|
-
before do
|
92
|
-
allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver).to receive(:get_domain).and_return(machine)
|
93
|
-
allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver).to receive(:state)
|
94
|
-
.and_return(:not_created)
|
95
|
-
allow(env).to receive(:[]).and_call_original
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'should do nothing by default' do
|
99
|
-
expect(env).to_not receive(:[]).with(:action_runner) # cleanup
|
100
|
-
expect(subject.recover(env)).to be_nil
|
101
|
-
end
|
102
|
-
|
103
|
-
context 'with machine coming up' do
|
104
|
-
before do
|
105
|
-
allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver).to receive(:state)
|
106
|
-
.and_return(:running)
|
107
|
-
env[:destroy_on_error] = true
|
108
|
-
end
|
109
|
-
|
110
|
-
context 'and user has disabled destroy on failure' do
|
111
|
-
before do
|
112
|
-
env[:destroy_on_error] = false
|
113
|
-
end
|
114
|
-
|
115
|
-
it 'skips terminate on failure' do
|
116
|
-
expect(env).to_not receive(:[]).with(:action_runner) # cleanup
|
117
|
-
expect(subject.recover(env)).to be_nil
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
context 'and using default settings' do
|
122
|
-
let(:runner) { double('runner') }
|
123
|
-
it 'deletes VM on failure' do
|
124
|
-
expect(env).to receive(:[]).with(:action_runner).and_return(runner) # cleanup
|
125
|
-
expect(runner).to receive(:run)
|
126
|
-
expect(subject.recover(env)).to be_nil
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
91
|
end
|
data/spec/unit/action_spec.rb
CHANGED
@@ -27,6 +27,8 @@ describe VagrantPlugins::ProviderLibvirt::Action do
|
|
27
27
|
allow(logger).to receive(:info)
|
28
28
|
allow(logger).to receive(:debug)
|
29
29
|
allow(logger).to receive(:error)
|
30
|
+
|
31
|
+
allow(connection.client).to receive(:libversion).and_return(6_002_000)
|
30
32
|
end
|
31
33
|
|
32
34
|
def allow_action_env_result(action, *responses)
|
data/spec/unit/config_spec.rb
CHANGED
@@ -171,55 +171,55 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|
171
171
|
# ignore LIBVIRT_DEFAULT_URI due to explicit settings
|
172
172
|
[ # when uri explicitly set
|
173
173
|
{:uri => 'qemu:///system'},
|
174
|
-
{:uri =>
|
174
|
+
{:uri => %r{qemu:///(system|session)}},
|
175
175
|
{
|
176
|
-
:env => {'LIBVIRT_DEFAULT_URI' => 'qemu
|
176
|
+
:env => {'LIBVIRT_DEFAULT_URI' => 'qemu:///custom'},
|
177
177
|
}
|
178
178
|
],
|
179
179
|
[ # when host explicitly set
|
180
180
|
{:host => 'remote'},
|
181
|
-
{:uri =>
|
181
|
+
{:uri => %r{qemu://remote/(system|session)}},
|
182
182
|
{
|
183
|
-
:env => {'LIBVIRT_DEFAULT_URI' => 'qemu
|
183
|
+
:env => {'LIBVIRT_DEFAULT_URI' => 'qemu:///custom'},
|
184
184
|
}
|
185
185
|
],
|
186
186
|
[ # when connect_via_ssh explicitly set
|
187
187
|
{:connect_via_ssh => true},
|
188
|
-
{:uri =>
|
188
|
+
{:uri => %r{qemu\+ssh://localhost/(system|session)\?no_verify=1}},
|
189
189
|
{
|
190
|
-
:env => {'LIBVIRT_DEFAULT_URI' => 'qemu
|
190
|
+
:env => {'LIBVIRT_DEFAULT_URI' => 'qemu:///custom'},
|
191
191
|
}
|
192
192
|
],
|
193
193
|
[ # when username explicitly set without ssh
|
194
194
|
{:username => 'my_user' },
|
195
|
-
{:uri =>
|
195
|
+
{:uri => %r{qemu:///(system|session)}, :username => 'my_user'},
|
196
196
|
{
|
197
|
-
:env => {'LIBVIRT_DEFAULT_URI' => 'qemu
|
197
|
+
:env => {'LIBVIRT_DEFAULT_URI' => 'qemu:///custom'},
|
198
198
|
}
|
199
199
|
],
|
200
200
|
[ # when username explicitly set with host but without ssh
|
201
201
|
{:username => 'my_user', :host => 'remote'},
|
202
|
-
{:uri =>
|
202
|
+
{:uri => %r{qemu://remote/(system|session)}, :username => 'my_user'},
|
203
203
|
{
|
204
|
-
:env => {'LIBVIRT_DEFAULT_URI' => 'qemu
|
204
|
+
:env => {'LIBVIRT_DEFAULT_URI' => 'qemu:///custom'},
|
205
205
|
}
|
206
206
|
],
|
207
207
|
[ # when password explicitly set
|
208
208
|
{:password => 'some_password'},
|
209
|
-
{:uri =>
|
209
|
+
{:uri => %r{qemu:///(system|session)}, :password => 'some_password'},
|
210
210
|
{
|
211
|
-
:env => {'LIBVIRT_DEFAULT_URI' => 'qemu
|
211
|
+
:env => {'LIBVIRT_DEFAULT_URI' => 'qemu:///custom'},
|
212
212
|
}
|
213
213
|
],
|
214
214
|
|
215
215
|
# driver settings
|
216
216
|
[ # set to kvm only
|
217
217
|
{:driver => 'kvm'},
|
218
|
-
{:uri =>
|
218
|
+
{:uri => %r{qemu:///(system|session)}},
|
219
219
|
],
|
220
220
|
[ # set to qemu only
|
221
221
|
{:driver => 'qemu'},
|
222
|
-
{:uri =>
|
222
|
+
{:uri => %r{qemu:///(system|session)}},
|
223
223
|
],
|
224
224
|
[ # set to qemu with session enabled
|
225
225
|
{:driver => 'qemu', :qemu_use_session => true},
|
@@ -241,29 +241,29 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|
241
241
|
# connect_via_ssh settings
|
242
242
|
[ # enabled
|
243
243
|
{:connect_via_ssh => true},
|
244
|
-
{:uri =>
|
244
|
+
{:uri => %r{qemu\+ssh://localhost/(system|session)\?no_verify=1}},
|
245
245
|
],
|
246
246
|
[ # enabled with user
|
247
247
|
{:connect_via_ssh => true, :username => 'my_user'},
|
248
|
-
{:uri =>
|
248
|
+
{:uri => %r{qemu\+ssh://my_user@localhost/(system|session)\?no_verify=1}},
|
249
249
|
],
|
250
250
|
[ # enabled with host
|
251
251
|
{:connect_via_ssh => true, :host => 'remote_server'},
|
252
|
-
{:uri =>
|
252
|
+
{:uri => %r{qemu\+ssh://remote_server/(system|session)\?no_verify=1}},
|
253
253
|
],
|
254
254
|
|
255
255
|
# id_ssh_key_file behaviour
|
256
256
|
[ # set should take given value
|
257
257
|
{:connect_via_ssh => true, :id_ssh_key_file => '/path/to/keyfile'},
|
258
|
-
{:uri =>
|
258
|
+
{:uri => %r{qemu\+ssh://localhost/(system|session)\?no_verify=1&keyfile=/path/to/keyfile}, :connect_via_ssh => true},
|
259
259
|
],
|
260
260
|
[ # set should infer use of ssh
|
261
261
|
{:id_ssh_key_file => '/path/to/keyfile'},
|
262
|
-
{:uri =>
|
262
|
+
{:uri => %r{qemu\+ssh://localhost/(system|session)\?no_verify=1&keyfile=/path/to/keyfile}, :connect_via_ssh => true},
|
263
263
|
],
|
264
264
|
[ # connect_via_ssh should enable default but ignore due to not existing
|
265
265
|
{:connect_via_ssh => true},
|
266
|
-
{:uri =>
|
266
|
+
{:uri => %r{qemu\+ssh://localhost/(system|session)\?no_verify=1}, :id_ssh_key_file => nil},
|
267
267
|
{
|
268
268
|
:setup => ProcWithBinding.new {
|
269
269
|
expect(File).to receive(:file?).with("/home/tests/.ssh/id_rsa").and_return(false)
|
@@ -272,7 +272,7 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|
272
272
|
],
|
273
273
|
[ # connect_via_ssh should enable default and include due to existing
|
274
274
|
{:connect_via_ssh => true},
|
275
|
-
{:uri =>
|
275
|
+
{:uri => %r{qemu\+ssh://localhost/(system|session)\?no_verify=1&keyfile=/home/tests/\.ssh/id_rsa}, :id_ssh_key_file => '/home/tests/.ssh/id_rsa'},
|
276
276
|
{
|
277
277
|
:setup => ProcWithBinding.new {
|
278
278
|
expect(File).to receive(:file?).with("/home/tests/.ssh/id_rsa").and_return(true)
|
@@ -283,7 +283,7 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|
283
283
|
# socket behaviour
|
284
284
|
[ # set
|
285
285
|
{:socket => '/var/run/libvirt/libvirt-sock'},
|
286
|
-
{:uri =>
|
286
|
+
{:uri => %r{qemu:///(system|session)\?socket=/var/run/libvirt/libvirt-sock}},
|
287
287
|
],
|
288
288
|
].each do |inputs, outputs, options|
|
289
289
|
opts = {}
|
@@ -317,7 +317,8 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|
317
317
|
hash["#{name.to_s[1..-1]}".to_sym] =subject.instance_variable_get(name)
|
318
318
|
end
|
319
319
|
end
|
320
|
-
|
320
|
+
|
321
|
+
expect(got).to match(outputs.inject({}) { |h, (k, v)| h[k] = v.is_a?(Regexp) ? a_string_matching(v) : v; h })
|
321
322
|
end
|
322
323
|
end
|
323
324
|
|
@@ -531,6 +532,47 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|
531
532
|
end
|
532
533
|
end
|
533
534
|
end
|
535
|
+
|
536
|
+
context '@channels' do
|
537
|
+
it 'should be empty by default' do
|
538
|
+
subject.finalize!
|
539
|
+
|
540
|
+
expect(subject.channels).to be_empty
|
541
|
+
end
|
542
|
+
|
543
|
+
context 'when qemu_use_agent is set' do
|
544
|
+
before do
|
545
|
+
subject.qemu_use_agent = true
|
546
|
+
end
|
547
|
+
|
548
|
+
it 'should inject a qemu agent channel' do
|
549
|
+
subject.finalize!
|
550
|
+
|
551
|
+
expect(subject.channels).to_not be_empty
|
552
|
+
expect(subject.channels).to match([a_hash_including({:target_name => 'org.qemu.guest_agent.0'})])
|
553
|
+
end
|
554
|
+
|
555
|
+
context 'when agent channel already added' do
|
556
|
+
it 'should not modify the channels' do
|
557
|
+
subject.channel :type => 'unix', :target_name => 'org.qemu.guest_agent.0', :target_type => 'virtio'
|
558
|
+
|
559
|
+
subject.finalize!
|
560
|
+
|
561
|
+
expect(subject.channels.length).to eq(1)
|
562
|
+
end
|
563
|
+
|
564
|
+
context 'when agent channel explicitly disbaled' do
|
565
|
+
it 'should not include an agent channel' do
|
566
|
+
subject.channel :type => 'unix', :target_name => 'org.qemu.guest_agent.0', :disabled => true
|
567
|
+
|
568
|
+
subject.finalize!
|
569
|
+
|
570
|
+
expect(subject.channels).to be_empty
|
571
|
+
end
|
572
|
+
end
|
573
|
+
end
|
574
|
+
end
|
575
|
+
end
|
534
576
|
end
|
535
577
|
|
536
578
|
def assert_invalid
|
@@ -566,7 +608,9 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|
566
608
|
|
567
609
|
context 'with mac defined' do
|
568
610
|
let (:vm) { double('vm') }
|
569
|
-
before
|
611
|
+
before do
|
612
|
+
machine.config.instance_variable_get("@keys")[:vm] = vm
|
613
|
+
end
|
570
614
|
|
571
615
|
it 'is valid with valid mac' do
|
572
616
|
expect(vm).to receive(:networks).and_return([[:public, { mac: 'aa:bb:cc:dd:ee:ff' }]])
|
@@ -585,6 +629,21 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|
585
629
|
assert_invalid
|
586
630
|
end
|
587
631
|
end
|
632
|
+
|
633
|
+
context 'with cpu_mode and cpu_model defined' do
|
634
|
+
it 'should discard model if mode is passthrough' do
|
635
|
+
subject.cpu_mode = 'host-passthrough'
|
636
|
+
subject.cpu_model = 'qemu64'
|
637
|
+
assert_valid
|
638
|
+
expect(subject.cpu_model).to be_empty
|
639
|
+
end
|
640
|
+
|
641
|
+
it 'should allow custom mode with model' do
|
642
|
+
subject.cpu_mode = 'custom'
|
643
|
+
subject.cpu_model = 'qemu64'
|
644
|
+
assert_valid
|
645
|
+
end
|
646
|
+
end
|
588
647
|
end
|
589
648
|
|
590
649
|
describe '#merge' do
|
@@ -606,11 +665,11 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|
606
665
|
end
|
607
666
|
|
608
667
|
context 'without devices given' do
|
609
|
-
it 'should merge disks
|
668
|
+
it 'should merge disks without assigning devices automatically' do
|
610
669
|
one.storage(:file)
|
611
670
|
two.storage(:file)
|
612
671
|
subject.finalize!
|
613
|
-
expect(subject.disks).
|
672
|
+
expect(subject.disks).to_not include(include(device: 'vdb'),
|
614
673
|
include(device: 'vdc'))
|
615
674
|
end
|
616
675
|
end
|
data/spec/unit/driver_spec.rb
CHANGED
@@ -35,10 +35,10 @@ describe VagrantPlugins::ProviderLibvirt::Driver do
|
|
35
35
|
# name for the test machines above.
|
36
36
|
let(:machine) { iso_env.machine(:test1, :libvirt) }
|
37
37
|
let(:machine2) { iso_env.machine(:test2, :libvirt) }
|
38
|
-
let(:connection1) { double("connection 1") }
|
39
|
-
let(:connection2) { double("connection 2") }
|
40
|
-
let(:system_connection1) { double("system connection 1") }
|
41
|
-
let(:system_connection2) { double("system connection 2") }
|
38
|
+
let(:connection1) { double("connection 1") }
|
39
|
+
let(:connection2) { double("connection 2") }
|
40
|
+
let(:system_connection1) { double("system connection 1") }
|
41
|
+
let(:system_connection2) { double("system connection 2") }
|
42
42
|
|
43
43
|
# make it easier for distros that want to switch the default value for
|
44
44
|
# qemu_use_session to true by ensuring it is explicitly false for tests.
|
@@ -177,7 +177,7 @@ describe VagrantPlugins::ProviderLibvirt::Driver do
|
|
177
177
|
end
|
178
178
|
|
179
179
|
context 'when qemu_use_session is enabled' do
|
180
|
-
let(:networks) { [instance_double(
|
180
|
+
let(:networks) { [instance_double(::Fog::Libvirt::Compute::Real)] }
|
181
181
|
let(:dhcp_leases) {
|
182
182
|
{
|
183
183
|
"iface" =>"virbr0",
|
@@ -245,12 +245,21 @@ describe VagrantPlugins::ProviderLibvirt::Driver do
|
|
245
245
|
end,
|
246
246
|
}
|
247
247
|
],
|
248
|
+
[
|
249
|
+
nil,
|
250
|
+
:unknown,
|
251
|
+
{
|
252
|
+
:setup => ProcWithBinding.new do
|
253
|
+
expect(domain).to receive(:state).and_return('unknown').at_least(:once)
|
254
|
+
end,
|
255
|
+
}
|
256
|
+
],
|
248
257
|
[
|
249
258
|
'terminated',
|
250
259
|
:not_created,
|
251
260
|
{
|
252
261
|
:setup => ProcWithBinding.new do
|
253
|
-
expect(domain).to receive(:state).and_return('terminated')
|
262
|
+
expect(domain).to receive(:state).and_return('terminated').at_least(:once)
|
254
263
|
end,
|
255
264
|
}
|
256
265
|
],
|
@@ -259,7 +268,7 @@ describe VagrantPlugins::ProviderLibvirt::Driver do
|
|
259
268
|
:inaccessible,
|
260
269
|
{
|
261
270
|
:setup => ProcWithBinding.new do
|
262
|
-
expect(domain).to receive(:state).and_return('running').
|
271
|
+
expect(domain).to receive(:state).and_return('running').at_least(:once)
|
263
272
|
expect(subject).to receive(:get_domain_ipaddress).and_raise(Fog::Errors::TimeoutError)
|
264
273
|
end,
|
265
274
|
}
|
@@ -269,7 +278,7 @@ describe VagrantPlugins::ProviderLibvirt::Driver do
|
|
269
278
|
:running,
|
270
279
|
{
|
271
280
|
:setup => ProcWithBinding.new do
|
272
|
-
expect(domain).to receive(:state).and_return('running').
|
281
|
+
expect(domain).to receive(:state).and_return('running').at_least(:once)
|
273
282
|
expect(subject).to receive(:get_domain_ipaddress).and_return('192.168.121.2')
|
274
283
|
end,
|
275
284
|
}
|