vagrant-libvirt 0.5.0 → 0.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af89387fcdeb6518bd31879ac2eaa00373c3af1c02613b389868eb6c656b5f2b
4
- data.tar.gz: 82fa3560eb88abac51088e894d8e475bbf4dbcda4b10596b43e7fc41d158945a
3
+ metadata.gz: 4af147b9b5fb6d00d46b0027da6314153012a8fe8c77e64ba0a497ccb46151fa
4
+ data.tar.gz: 052ea81b672906f4b2c2476c0f7e84f4f0e40f45fb00d70239a68f25c94311a2
5
5
  SHA512:
6
- metadata.gz: 53d1714279eaa3ed9c0434b891bad6bc03b4f52a0c2a5aed6e0736cefa89a3f66243ec3d04e2bf1bb707f76169e2f799ffa98e63f3cfdc3c91ee0d56e5332695
7
- data.tar.gz: 15ea6d1ce672545f14f3886a6d945f2349c85cca61a63604abf30f5a716b9665c65ea181fd2dcb96c39321567725911b230d22d1c589c888a2b05ec9c7715b13
6
+ metadata.gz: 12662ab4dd96312b36cb5afa24d35b6558f247e53bbfb89903d748fb7c59e4cef2847c75d5025e8b8b39b92f5914b44647ff80e8aa3ac0e829f95648538540ee
7
+ data.tar.gz: fe1005190e1904f64fe60a4dddeadc867a7898c59b5762fa3db03d106b37091e1a5335a453c1b39728bb715603c1a18c1ea22d560a8da66fd7cb4c52e42fe8a0
data/README.md CHANGED
@@ -1389,6 +1389,24 @@ Name of network "foreman_managed" is key for define boot order
1389
1389
  end
1390
1390
  ```
1391
1391
 
1392
+ An example VM that is PXE booted from the `br1` device (which must already be configured in the host machine), and if that fails, is booted from the disk:
1393
+
1394
+ ```ruby
1395
+ Vagrant.configure("2") do |config|
1396
+ config.vm.define :pxeclient do |pxeclient|
1397
+ pxeclient.vm.network :public_network,
1398
+ dev: 'br1',
1399
+ auto_config: false
1400
+ pxeclient.vm.provider :libvirt do |domain|
1401
+ boot_network = {'dev' => 'br1'}
1402
+ domain.storage :file, :size => '100G'
1403
+ domain.boot boot_network
1404
+ domain.boot 'hd'
1405
+ end
1406
+ end
1407
+ end
1408
+ ```
1409
+
1392
1410
  ## SSH Access To VM
1393
1411
 
1394
1412
  vagrant-libvirt supports vagrant's [standard ssh
@@ -19,6 +19,8 @@ module VagrantPlugins
19
19
 
20
20
  @logger.debug("Recursively removing: #{machine_folder}")
21
21
  FileUtils.rm_rf(machine_folder, :secure => true)
22
+ # need to recreate to prevent exception during a cancelled up
23
+ FileUtils.mkdir_p(machine_folder)
22
24
 
23
25
  @app.call(env)
24
26
  end
@@ -33,7 +33,8 @@ module VagrantPlugins
33
33
  # Gather some info about domain
34
34
  @name = env[:domain_name]
35
35
  @title = config.title
36
- @description = config.description
36
+ vagrantfile = File.join(env[:root_path], (env[:vagrantfile_name] || "Vagrantfile"))
37
+ @description = !config.description.empty? ? config.description : "Source: #{vagrantfile}"
37
38
  @uuid = config.uuid
38
39
  @cpus = config.cpus.to_i
39
40
  @cpuset = config.cpuset
@@ -86,9 +86,13 @@ module VagrantPlugins
86
86
 
87
87
  def search_network(nets, xml)
88
88
  str = '/domain/devices/interface'
89
- str += "[(@type='network' or @type='udp' or @type='bridge')"
89
+ str += "[(@type='network' or @type='udp' or @type='bridge' or @type='direct')"
90
90
  unless nets.empty?
91
- str += " and source[@network='#{nets.first['network']}']"
91
+ net = nets.first
92
+ network = net['network']
93
+ dev = net['dev']
94
+ str += " and source[@network='#{network}']" if network
95
+ str += " and source[@dev='#{dev}']" if dev
92
96
  end
93
97
  str += ']'
94
98
  @logger.debug(str)
@@ -1,3 +1,5 @@
1
+ require 'cgi'
2
+
1
3
  require 'vagrant'
2
4
 
3
5
  class Numeric
@@ -193,6 +195,7 @@ module VagrantPlugins
193
195
  @uri = UNSET_VALUE
194
196
  @driver = UNSET_VALUE
195
197
  @host = UNSET_VALUE
198
+ @port = UNSET_VALUE
196
199
  @connect_via_ssh = UNSET_VALUE
197
200
  @username = UNSET_VALUE
198
201
  @password = UNSET_VALUE
@@ -1016,7 +1019,12 @@ module VagrantPlugins
1016
1019
 
1017
1020
  # Extract host and username values from uri if provided, otherwise nil
1018
1021
  @host = uri.host
1022
+ @port = uri.port
1019
1023
  @username = uri.user
1024
+ if uri.query
1025
+ params = CGI.parse(uri.query)
1026
+ @id_ssh_key_file = params['keyfile'].first if params.has_key?('keyfile')
1027
+ end
1020
1028
 
1021
1029
  finalize_id_ssh_key_file
1022
1030
  end
@@ -1053,11 +1061,13 @@ module VagrantPlugins
1053
1061
  if @connect_via_ssh
1054
1062
  if @proxy_command == UNSET_VALUE
1055
1063
  proxy_command = "ssh '#{@host}' "
1064
+ proxy_command << "-p #{@port} " if @port
1056
1065
  proxy_command << "-l '#{@username}' " if @username
1057
1066
  proxy_command << "-i '#{@id_ssh_key_file}' " if @id_ssh_key_file
1058
1067
  proxy_command << '-W %h:%p'
1059
1068
  else
1060
1069
  inputs = { host: @host }
1070
+ inputs << { port: @port } if @port
1061
1071
  inputs[:username] = @username if @username
1062
1072
  inputs[:id_ssh_key_file] = @id_ssh_key_file if @id_ssh_key_file
1063
1073
 
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
@@ -9,12 +9,18 @@ describe VagrantPlugins::ProviderLibvirt::Action::CleanMachineFolder do
9
9
  include_context 'unit'
10
10
 
11
11
  describe '#call' do
12
+ before do
13
+ FileUtils.touch(File.join(machine.data_dir, "box.meta"))
14
+ end
15
+
12
16
  context 'with default options' do
13
17
  it 'should verbosely remove the folder' do
14
18
  expect(ui).to receive(:info).with('Deleting the machine folder')
15
- expect(FileUtils).to receive(:rm_rf).with(machine.data_dir, {:secure => true})
16
19
 
17
20
  expect(subject.call(env)).to be_nil
21
+
22
+ expect(File.exists?(machine.data_dir)).to eq(true)
23
+ expect(Dir.entries(machine.data_dir)).to match_array([".", ".."])
18
24
  end
19
25
  end
20
26
 
@@ -22,15 +28,17 @@ describe VagrantPlugins::ProviderLibvirt::Action::CleanMachineFolder do
22
28
  before do
23
29
  Dir.mktmpdir do |d|
24
30
  # returns a temporary directory that has been already deleted when running
25
- expect(machine).to receive(:data_dir).and_return(d.to_s).exactly(2).times
31
+ expect(machine).to receive(:data_dir).and_return(d.to_s).exactly(3).times
26
32
  end
27
33
  end
28
34
 
29
35
  it 'should remove the folder' do
30
36
  expect(ui).to receive(:info).with('Deleting the machine folder')
31
- expect(FileUtils).to receive(:rm_rf).with(machine.data_dir, {:secure => true})
32
37
 
33
38
  expect(subject.call(env)).to be_nil
39
+
40
+ expect(File.exists?(machine.data_dir)).to eq(true)
41
+ expect(Dir.entries(machine.data_dir)).to match_array([".", ".."])
34
42
  end
35
43
  end
36
44
 
@@ -39,9 +47,11 @@ describe VagrantPlugins::ProviderLibvirt::Action::CleanMachineFolder do
39
47
 
40
48
  it 'should quietly remove the folder' do
41
49
  expect(ui).to_not receive(:info).with('Deleting the machine folder')
42
- expect(FileUtils).to receive(:rm_rf).with(machine.data_dir, {:secure => true})
43
50
 
44
51
  expect(subject.call(env)).to be_nil
52
+
53
+ expect(File.exists?(machine.data_dir)).to eq(true)
54
+ expect(Dir.entries(machine.data_dir)).to match_array([".", ".."])
45
55
  end
46
56
  end
47
57
  end
@@ -15,7 +15,8 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
15
15
  let(:servers) { double('servers') }
16
16
  let(:volumes) { double('volumes') }
17
17
 
18
- let(:storage_pool_xml) { File.read(File.join(File.dirname(__FILE__), File.basename(__FILE__, '.rb'), test_file)) }
18
+ let(:domain_xml) { File.read(File.join(File.dirname(__FILE__), File.basename(__FILE__, '.rb'), domain_xml_file)) }
19
+ let(:storage_pool_xml) { File.read(File.join(File.dirname(__FILE__), File.basename(__FILE__, '.rb'), storage_pool_xml_file)) }
19
20
  let(:libvirt_storage_pool) { double('storage_pool') }
20
21
 
21
22
  describe '#call' do
@@ -44,12 +45,13 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
44
45
 
45
46
  context 'connection => qemu:///system' do
46
47
  context 'default pool' do
47
- let(:test_file) { 'default_system_storage_pool.xml' }
48
+ let(:domain_xml_file) { 'default_domain.xml' }
49
+ let(:storage_pool_xml_file) { 'default_system_storage_pool.xml' }
48
50
 
49
51
  it 'should execute correctly' do
50
52
  expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
51
53
  expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
52
- expect(servers).to receive(:create).and_return(machine)
54
+ expect(servers).to receive(:create).with(xml: domain_xml).and_return(machine)
53
55
  expect(volumes).to_not receive(:create) # additional disks only
54
56
 
55
57
  expect(subject.call(env)).to be_nil
@@ -78,6 +80,8 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
78
80
  end
79
81
 
80
82
  context 'volume create succeeded' do
83
+ let(:domain_xml_file) { 'additional_disks_domain.xml' }
84
+
81
85
  it 'should complete' do
82
86
  expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
83
87
  expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
@@ -89,7 +93,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
89
93
  :pool_name => "default",
90
94
  )
91
95
  )
92
- expect(servers).to receive(:create).and_return(machine)
96
+ expect(servers).to receive(:create).with(xml: domain_xml).and_return(machine)
93
97
 
94
98
  expect(subject.call(env)).to be_nil
95
99
  end
@@ -119,7 +123,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
119
123
  end
120
124
 
121
125
  context 'default pool' do
122
- let(:test_file) { 'default_user_storage_pool.xml' }
126
+ let(:storage_pool_xml_file) { 'default_user_storage_pool.xml' }
123
127
 
124
128
  it 'should execute correctly' do
125
129
  expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
@@ -0,0 +1,54 @@
1
+ <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
2
+ <name>vagrant-test_default</name>
3
+ <title></title>
4
+ <description>Source: /rootpath/Vagrantfile</description>
5
+ <uuid></uuid>
6
+ <memory>524288</memory>
7
+ <vcpu>1</vcpu>
8
+
9
+
10
+ <cpu mode='host-model'>
11
+ <model fallback='allow'></model>
12
+ </cpu>
13
+
14
+
15
+ <os>
16
+ <type>hvm</type>
17
+ <kernel></kernel>
18
+ <initrd></initrd>
19
+ <cmdline></cmdline>
20
+ </os>
21
+ <features>
22
+ <acpi/>
23
+ <apic/>
24
+ <pae/>
25
+ </features>
26
+ <clock offset='utc'>
27
+ </clock>
28
+ <devices>
29
+ <disk type='file' device='disk'>
30
+ <driver name='qemu' type='qcow2' cache='default'/>
31
+ <source file='/var/lib/libvirt/images/vagrant-test_default-vdb.qcow2'/>
32
+ <target dev='vdb' bus='virtio'/>
33
+ </disk>
34
+
35
+
36
+ <serial type='pty'>
37
+ <target port='0'/>
38
+ </serial>
39
+ <console type='pty'>
40
+ <target port='0'/>
41
+ </console>
42
+
43
+
44
+ <input type='mouse' bus='ps2'/>
45
+
46
+ <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us' />
47
+ <video>
48
+ <model type='cirrus' vram='9216' heads='1'/>
49
+ </video>
50
+
51
+
52
+ </devices>
53
+
54
+ </domain>
@@ -0,0 +1,49 @@
1
+ <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
2
+ <name>vagrant-test_default</name>
3
+ <title></title>
4
+ <description>Source: /rootpath/Vagrantfile</description>
5
+ <uuid></uuid>
6
+ <memory>524288</memory>
7
+ <vcpu>1</vcpu>
8
+
9
+
10
+ <cpu mode='host-model'>
11
+ <model fallback='allow'></model>
12
+ </cpu>
13
+
14
+
15
+ <os>
16
+ <type>hvm</type>
17
+ <kernel></kernel>
18
+ <initrd></initrd>
19
+ <cmdline></cmdline>
20
+ </os>
21
+ <features>
22
+ <acpi/>
23
+ <apic/>
24
+ <pae/>
25
+ </features>
26
+ <clock offset='utc'>
27
+ </clock>
28
+ <devices>
29
+
30
+
31
+ <serial type='pty'>
32
+ <target port='0'/>
33
+ </serial>
34
+ <console type='pty'>
35
+ <target port='0'/>
36
+ </console>
37
+
38
+
39
+ <input type='mouse' bus='ps2'/>
40
+
41
+ <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us' />
42
+ <video>
43
+ <model type='cirrus' vram='9216' heads='1'/>
44
+ </video>
45
+
46
+
47
+ </devices>
48
+
49
+ </domain>
@@ -358,6 +358,10 @@ describe VagrantPlugins::ProviderLibvirt::Config do
358
358
  {:connect_via_ssh => true, :host => 'remote', :username => 'myuser'},
359
359
  "ssh 'remote' -l 'myuser' -W %h:%p",
360
360
  ],
361
+ [ # remote contains port
362
+ {:connect_via_ssh => true, :host => 'remote:2222'},
363
+ "ssh 'remote' -p 2222 -W %h:%p",
364
+ ],
361
365
  [ # include user and default ssh key exists
362
366
  {:connect_via_ssh => true, :host => 'remote', :username => 'myuser'},
363
367
  "ssh 'remote' -l 'myuser' -i '/home/tests/.ssh/id_rsa' -W %h:%p",
@@ -390,7 +394,6 @@ describe VagrantPlugins::ProviderLibvirt::Config do
390
394
  [
391
395
  {:uri => 'qemu+ssh://remote/system?keyfile=/some/path/to/keyfile'},
392
396
  "ssh 'remote' -i '/some/path/to/keyfile' -W %h:%p",
393
- {:allow_failure => "keyfile not yet inferred from uri"},
394
397
  ],
395
398
 
396
399
  # provide custom template
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-libvirt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Stanek
8
8
  - Dima Vasilets
9
9
  - Brian Pitts
10
- autorequire:
10
+ - Darragh Bailey
11
+ autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2021-05-22 00:00:00.000000000 Z
14
+ date: 2021-05-28 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: rspec-core
@@ -157,6 +158,7 @@ email:
157
158
  - ls@elostech.cz
158
159
  - pronix.service@gmail.com
159
160
  - brian@polibyte.com
161
+ - daragh.bailey@gmail.com
160
162
  executables: []
161
163
  extensions: []
162
164
  extra_rdoc_files: []
@@ -233,6 +235,8 @@ files:
233
235
  - spec/support/sharedcontext.rb
234
236
  - spec/unit/action/clean_machine_folder_spec.rb
235
237
  - spec/unit/action/create_domain_spec.rb
238
+ - spec/unit/action/create_domain_spec/additional_disks_domain.xml
239
+ - spec/unit/action/create_domain_spec/default_domain.xml
236
240
  - spec/unit/action/create_domain_spec/default_system_storage_pool.xml
237
241
  - spec/unit/action/create_domain_spec/default_user_storage_pool.xml
238
242
  - spec/unit/action/create_domain_volume_spec.rb
@@ -252,7 +256,6 @@ files:
252
256
  - spec/unit/action/start_domain_spec/default_added_tpm_version.xml
253
257
  - spec/unit/action/wait_till_up_spec.rb
254
258
  - spec/unit/config_spec.rb
255
- - spec/unit/provider_spec.rb
256
259
  - spec/unit/templates/domain_all_settings.xml
257
260
  - spec/unit/templates/domain_custom_cpu_model.xml
258
261
  - spec/unit/templates/domain_defaults.xml
@@ -263,7 +266,7 @@ homepage: https://github.com/vagrant-libvirt/vagrant-libvirt
263
266
  licenses:
264
267
  - MIT
265
268
  metadata: {}
266
- post_install_message:
269
+ post_install_message:
267
270
  rdoc_options: []
268
271
  require_paths:
269
272
  - lib
@@ -278,43 +281,43 @@ required_rubygems_version: !ruby/object:Gem::Requirement
278
281
  - !ruby/object:Gem::Version
279
282
  version: '0'
280
283
  requirements: []
281
- rubyforge_project:
282
- rubygems_version: 2.7.11
283
- signing_key:
284
+ rubygems_version: 3.0.8
285
+ signing_key:
284
286
  specification_version: 4
285
287
  summary: libvirt provider for Vagrant.
286
288
  test_files:
287
- - spec/unit/action/start_domain_spec.rb
289
+ - spec/support/libvirt_context.rb
290
+ - spec/support/binding_proc.rb
291
+ - spec/support/sharedcontext.rb
292
+ - spec/support/matchers/have_file_content.rb
293
+ - spec/support/environment_helper.rb
294
+ - spec/unit/templates/domain_all_settings.xml
295
+ - spec/unit/templates/domain_custom_cpu_model.xml
296
+ - spec/unit/templates/domain_defaults.xml
297
+ - spec/unit/templates/domain_spec.rb
298
+ - spec/unit/templates/tpm/version_1.2.xml
299
+ - spec/unit/templates/tpm/version_2.0.xml
300
+ - spec/unit/action/create_domain_spec/additional_disks_domain.xml
301
+ - spec/unit/action/create_domain_spec/default_domain.xml
302
+ - spec/unit/action/create_domain_spec/default_system_storage_pool.xml
303
+ - spec/unit/action/create_domain_spec/default_user_storage_pool.xml
288
304
  - spec/unit/action/create_domain_spec.rb
289
- - spec/unit/action/forward_ports_spec.rb
290
305
  - spec/unit/action/wait_till_up_spec.rb
306
+ - spec/unit/action/forward_ports_spec.rb
307
+ - spec/unit/action/destroy_domain_spec.rb
308
+ - spec/unit/action/halt_domain_spec.rb
309
+ - spec/unit/action/start_domain_spec.rb
291
310
  - spec/unit/action/clean_machine_folder_spec.rb
292
- - spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_2.xml
293
- - spec/unit/action/create_domain_volume_spec/one_disk_in_storage.xml
311
+ - spec/unit/action/create_domain_volume_spec.rb
312
+ - spec/unit/action/set_name_of_domain_spec.rb
294
313
  - spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_1.xml
295
314
  - spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_0.xml
296
- - spec/unit/action/start_domain_spec/default_added_tpm_version.xml
315
+ - spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_2.xml
316
+ - spec/unit/action/create_domain_volume_spec/one_disk_in_storage.xml
317
+ - spec/unit/action/start_domain_spec/default_added_tpm_path.xml
297
318
  - spec/unit/action/start_domain_spec/clock_timer_rtc.xml
298
319
  - spec/unit/action/start_domain_spec/default.xml
299
- - spec/unit/action/start_domain_spec/default_added_tpm_path.xml
300
- - spec/unit/action/destroy_domain_spec.rb
301
- - spec/unit/action/create_domain_spec/default_system_storage_pool.xml
302
- - spec/unit/action/create_domain_spec/default_user_storage_pool.xml
320
+ - spec/unit/action/start_domain_spec/default_added_tpm_version.xml
303
321
  - spec/unit/action/handle_box_image_spec.rb
304
- - spec/unit/action/set_name_of_domain_spec.rb
305
- - spec/unit/action/halt_domain_spec.rb
306
- - spec/unit/action/create_domain_volume_spec.rb
307
322
  - spec/unit/config_spec.rb
308
- - spec/unit/provider_spec.rb
309
- - spec/unit/templates/domain_defaults.xml
310
- - spec/unit/templates/domain_all_settings.xml
311
- - spec/unit/templates/domain_spec.rb
312
- - spec/unit/templates/tpm/version_1.2.xml
313
- - spec/unit/templates/tpm/version_2.0.xml
314
- - spec/unit/templates/domain_custom_cpu_model.xml
315
- - spec/support/libvirt_context.rb
316
- - spec/support/matchers/have_file_content.rb
317
- - spec/support/environment_helper.rb
318
- - spec/support/binding_proc.rb
319
- - spec/support/sharedcontext.rb
320
323
  - spec/spec_helper.rb
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
- require 'support/sharedcontext'
3
-
4
- describe 'VagrantPlugins::ProviderLibvirt::Provider' do
5
- require 'vagrant-libvirt/provider'
6
-
7
- include_context 'unit'
8
-
9
- describe '#ssh_info' do
10
- end
11
- end