vagrant-libvirt 0.0.45 → 0.1.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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +253 -109
  3. data/lib/vagrant-libvirt/action.rb +2 -2
  4. data/lib/vagrant-libvirt/action/create_domain.rb +59 -29
  5. data/lib/vagrant-libvirt/action/create_domain_volume.rb +14 -8
  6. data/lib/vagrant-libvirt/action/create_network_interfaces.rb +7 -5
  7. data/lib/vagrant-libvirt/action/create_networks.rb +2 -2
  8. data/lib/vagrant-libvirt/action/destroy_domain.rb +1 -1
  9. data/lib/vagrant-libvirt/action/forward_ports.rb +6 -5
  10. data/lib/vagrant-libvirt/action/halt_domain.rb +1 -1
  11. data/lib/vagrant-libvirt/action/handle_box_image.rb +22 -57
  12. data/lib/vagrant-libvirt/action/handle_storage_pool.rb +4 -4
  13. data/lib/vagrant-libvirt/action/package_domain.rb +58 -12
  14. data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +3 -9
  15. data/lib/vagrant-libvirt/action/prune_nfs_exports.rb +18 -9
  16. data/lib/vagrant-libvirt/action/remove_libvirt_image.rb +2 -2
  17. data/lib/vagrant-libvirt/action/remove_stale_volume.rb +17 -11
  18. data/lib/vagrant-libvirt/action/set_boot_order.rb +2 -2
  19. data/lib/vagrant-libvirt/action/set_name_of_domain.rb +6 -9
  20. data/lib/vagrant-libvirt/action/start_domain.rb +2 -2
  21. data/lib/vagrant-libvirt/action/wait_till_up.rb +7 -9
  22. data/lib/vagrant-libvirt/cap/synced_folder.rb +3 -3
  23. data/lib/vagrant-libvirt/config.rb +62 -11
  24. data/lib/vagrant-libvirt/driver.rb +3 -3
  25. data/lib/vagrant-libvirt/errors.rb +5 -5
  26. data/lib/vagrant-libvirt/plugin.rb +2 -2
  27. data/lib/vagrant-libvirt/templates/domain.xml.erb +18 -5
  28. data/lib/vagrant-libvirt/util/network_util.rb +6 -1
  29. data/lib/vagrant-libvirt/util/nfs.rb +17 -0
  30. data/lib/vagrant-libvirt/version.rb +1 -1
  31. data/locales/en.yml +6 -6
  32. data/spec/unit/action/set_name_of_domain_spec.rb +1 -1
  33. data/spec/unit/templates/domain_all_settings.xml +12 -2
  34. data/spec/unit/templates/domain_spec.rb +10 -2
  35. metadata +21 -34
  36. data/.coveralls.yml +0 -1
  37. data/.github/issue_template.md +0 -37
  38. data/.gitignore +0 -21
  39. data/.travis.yml +0 -24
  40. data/Gemfile +0 -26
  41. data/Rakefile +0 -8
  42. data/example_box/README.md +0 -29
  43. data/example_box/Vagrantfile +0 -60
  44. data/example_box/metadata.json +0 -5
  45. data/lib/vagrant-libvirt/templates/default_storage_volume.xml.erb +0 -14
  46. data/tools/create_box.sh +0 -130
  47. data/tools/prepare_redhat_for_box.sh +0 -119
  48. data/vagrant-libvirt.gemspec +0 -51
@@ -19,11 +19,11 @@ module VagrantPlugins
19
19
  end
20
20
 
21
21
  def connection
22
- # If already connected to libvirt, just use it and don't connect
22
+ # If already connected to Libvirt, just use it and don't connect
23
23
  # again.
24
24
  return @@connection if @@connection
25
25
 
26
- # Get config options for libvirt provider.
26
+ # Get config options for Libvirt provider.
27
27
  config = @machine.provider_config
28
28
  uri = config.uri
29
29
 
@@ -50,7 +50,7 @@ module VagrantPlugins
50
50
  end
51
51
 
52
52
  def system_connection
53
- # If already connected to libvirt, just use it and don't connect
53
+ # If already connected to Libvirt, just use it and don't connect
54
54
  # again.
55
55
  return @@system_connection if @@system_connection
56
56
 
@@ -29,14 +29,14 @@ module VagrantPlugins
29
29
  error_key(:creating_storage_pool_error)
30
30
  end
31
31
 
32
- class CreatingVolumeError < VagrantLibvirtError
33
- error_key(:creating_volume_error)
34
- end
35
-
36
32
  class ImageUploadError < VagrantLibvirtError
37
33
  error_key(:image_upload_error)
38
34
  end
39
35
 
36
+ class ImageDownloadError < VagrantLibvirtError
37
+ error_key(:image_download_error)
38
+ end
39
+
40
40
  # Box exceptions
41
41
  class NoBoxVolume < VagrantLibvirtError
42
42
  error_key(:no_box_volume)
@@ -54,7 +54,7 @@ module VagrantPlugins
54
54
  error_key(:wrong_box_format)
55
55
  end
56
56
 
57
- # Fog libvirt exceptions
57
+ # Fog Libvirt exceptions
58
58
  class FogError < VagrantLibvirtError
59
59
  error_key(:fog_error)
60
60
  end
@@ -4,7 +4,7 @@ rescue LoadError
4
4
  raise 'The Vagrant Libvirt plugin must be run within Vagrant.'
5
5
  end
6
6
 
7
- # compatibility fix to define constant not available vagrant <1.6
7
+ # compatibility fix to define constant not available Vagrant <1.6
8
8
  ::Vagrant::MachineState::NOT_CREATED_ID ||= :not_created
9
9
 
10
10
  module VagrantPlugins
@@ -12,7 +12,7 @@ module VagrantPlugins
12
12
  class Plugin < Vagrant.plugin('2')
13
13
  name 'libvirt'
14
14
  description <<-DESC
15
- Vagrant plugin to manage VMs in libvirt.
15
+ Vagrant plugin to manage VMs in Libvirt.
16
16
  DESC
17
17
 
18
18
  config('libvirt', :provider) do
@@ -2,7 +2,7 @@
2
2
  <name><%= @name %></name>
3
3
  <uuid><%= @uuid %></uuid>
4
4
  <memory><%= @memory_size %></memory>
5
- <vcpu><%= @cpus %></vcpu>
5
+ <vcpu<% if @cpuset %> cpuset='<%= @cpuset %>'<% end %>><%= @cpus %></vcpu>
6
6
 
7
7
 
8
8
  <cpu mode='<%= @cpu_mode %>'>
@@ -33,6 +33,11 @@
33
33
  <% end %>
34
34
  </cpu>
35
35
 
36
+ <%- if @nodeset -%>
37
+ <numatune>
38
+ <memory nodeset='<%= @nodeset %>'/>
39
+ </numatune>
40
+ <%- end -%>
36
41
  <% unless @memory_backing.empty? %>
37
42
  <memoryBacking>
38
43
  <% @memory_backing.each do |backing| %>
@@ -40,6 +45,11 @@
40
45
  <% end %>
41
46
  </memoryBacking>
42
47
  <% end%>
48
+ <% if @shares %>
49
+ <cputune>
50
+ <shares><%= @shares %></shares>
51
+ </cputune>
52
+ <% end %>
43
53
 
44
54
  <os>
45
55
  <% if @machine_type %>
@@ -117,7 +127,7 @@
117
127
  <% if d[:serial] %>
118
128
  <serial><%= d[:serial] %></serial>
119
129
  <% end %>
120
- <%# this will get auto generated by libvirt
130
+ <%# this will get auto generated by Libvirt
121
131
  <address type='pci' domain='0x0000' bus='0x00' slot='???' function='0x0'/>
122
132
  -%>
123
133
  </disk>
@@ -190,7 +200,7 @@
190
200
  <% @pcis.each do |pci| %>
191
201
  <hostdev mode='subsystem' type='pci' managed='yes'>
192
202
  <source>
193
- <address domain='0x0000'
203
+ <address domain='<%= pci[:domain] %>'
194
204
  bus='<%= pci[:bus] %>'
195
205
  slot='<%= pci[:slot] %>'
196
206
  function='<%= pci[:function] %>'/>
@@ -256,11 +266,14 @@
256
266
  <% end %>
257
267
  </devices>
258
268
 
259
- <% unless @qargs.empty? %>
269
+ <% if not @qemu_args.empty? or not @qemu_env.empty? %>
260
270
  <qemu:commandline>
261
- <% @qargs.each do |arg| %>
271
+ <% @qemu_args.each do |arg| %>
262
272
  <qemu:arg value='<%= arg[:value] %>'/>
263
273
  <% end %>
274
+ <% @qemu_env.each do |env_var, env_value| %>
275
+ <qemu:env name='<%= env_var.to_s %>' value='<%= env_value %>'/>
276
+ <% end %>
264
277
  </qemu:commandline>
265
278
  <% end %>
266
279
  </domain>
@@ -18,6 +18,7 @@ module VagrantPlugins
18
18
  management_network_autostart = env[:machine].provider_config.management_network_autostart
19
19
  management_network_pci_bus = env[:machine].provider_config.management_network_pci_bus
20
20
  management_network_pci_slot = env[:machine].provider_config.management_network_pci_slot
21
+ management_network_domain = env[:machine].provider_config.management_network_domain
21
22
  logger.info "Using #{management_network_name} at #{management_network_address} as the management network #{management_network_mode} is the mode"
22
23
 
23
24
  begin
@@ -65,6 +66,10 @@ module VagrantPlugins
65
66
  management_network_options[:mac] = management_network_mac
66
67
  end
67
68
 
69
+ unless management_network_domain.nil?
70
+ management_network_options[:domain_name] = management_network_domain
71
+ end
72
+
68
73
  unless management_network_pci_bus.nil? and management_network_pci_slot.nil?
69
74
  management_network_options[:bus] = management_network_pci_bus
70
75
  management_network_options[:slot] = management_network_pci_slot
@@ -109,7 +114,7 @@ module VagrantPlugins
109
114
  networks
110
115
  end
111
116
 
112
- # Return a list of all (active and inactive) libvirt networks as a list
117
+ # Return a list of all (active and inactive) Libvirt networks as a list
113
118
  # of hashes with their name, network address and status (active or not)
114
119
  def libvirt_networks(libvirt_client)
115
120
  libvirt_networks = []
@@ -0,0 +1,17 @@
1
+ module VagrantPlugins
2
+ module ProviderLibvirt
3
+ module Util
4
+ module Nfs
5
+ include Vagrant::Action::Builtin::MixinSyncedFolders
6
+
7
+ # We're using NFS if we have any synced folder with NFS configured. If
8
+ # we are not using NFS we don't need to do the extra work to
9
+ # populate these fields in the environment.
10
+ def using_nfs?
11
+ !!synced_folders(@machine)[:nfs]
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module ProviderLibvirt
3
- VERSION = '0.0.45'.freeze
3
+ VERSION = '0.1.0'.freeze
4
4
  end
5
5
  end
@@ -16,7 +16,7 @@ en:
16
16
  Created volume larger than box defaults, will require manual resizing of
17
17
  filesystems to utilize.
18
18
  uploading_volume: |-
19
- Uploading base box image as volume into libvirt storage...
19
+ Uploading base box image as volume into Libvirt storage...
20
20
  creating_domain_volume: |-
21
21
  Creating image (snapshot of base box volume).
22
22
  removing_domain_volume: |-
@@ -60,7 +60,7 @@ en:
60
60
  Forwarding UDP ports is not supported. Ignoring.
61
61
 
62
62
  errors:
63
- package_not_supported: No support for package with libvirt. Create box manually.
63
+ package_not_supported: No support for package with Libvirt. Create box manually.
64
64
  fog_error: |-
65
65
  There was an error talking to Libvirt. The error message is shown
66
66
  below:
@@ -97,7 +97,7 @@ en:
97
97
  wrong_box_format: |-
98
98
  Wrong image format specified for box.
99
99
  fog_libvirt_connection_error: |-
100
- Error while connecting to libvirt: %{error_message}
100
+ Error while connecting to Libvirt: %{error_message}
101
101
  fog_create_volume_error: |-
102
102
  Error while creating a storage pool volume: %{error_message}
103
103
  fog_create_domain_volume_error: |-
@@ -108,11 +108,11 @@ en:
108
108
  Name `%{domain_name}` of domain about to create is already taken. Please try to run
109
109
  `vagrant up` command again.
110
110
  creating_storage_pool_error: |-
111
- There was error while creating libvirt storage pool: %{error_message}
112
- creating_volume_error: |-
113
- There was error while creating libvirt volume: %{error_message}
111
+ There was error while creating Libvirt storage pool: %{error_message}
114
112
  image_upload_error: |-
115
113
  Error while uploading image to storage pool: %{error_message}
114
+ image_download_error: |-
115
+ Error while downloading volume '%{volume_name}' from storage pool '%{pool_name}': %{error_message}
116
116
  no_domain_error: |-
117
117
  No domain found. %{error_message}
118
118
  attach_device_error: |-
@@ -14,7 +14,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain do
14
14
  end
15
15
 
16
16
  it 'builds simple domain name' do
17
- @env.default_prefix = 'pre'
17
+ @env.default_prefix = 'pre_'
18
18
  dmn = VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain.new(Object.new, @env)
19
19
  dmn.build_domain_name(@env).should eq('pre_')
20
20
  end
@@ -2,7 +2,7 @@
2
2
  <name></name>
3
3
  <uuid></uuid>
4
4
  <memory></memory>
5
- <vcpu>1</vcpu>
5
+ <vcpu cpuset='1-4,^3,6'>1</vcpu>
6
6
 
7
7
 
8
8
  <cpu mode='custom'>
@@ -11,6 +11,12 @@
11
11
  <topology sockets='1' cores='3' threads='2'/>
12
12
  </cpu>
13
13
 
14
+ <numatune>
15
+ <memory nodeset='1-4,^3,6'/>
16
+ </numatune>
17
+ <cputune>
18
+ <shares>1024</shares>
19
+ </cputune>
14
20
 
15
21
  <os>
16
22
  <type arch='x86_64' machine='pc-compatible'>hvm</type>
@@ -104,7 +110,7 @@
104
110
  </hostdev>
105
111
  <hostdev mode='subsystem' type='pci' managed='yes'>
106
112
  <source>
107
- <address domain='0x0000'
113
+ <address domain='0x0001'
108
114
  bus='0x03'
109
115
  slot='0x00'
110
116
  function='0x0'/>
@@ -137,5 +143,9 @@
137
143
  <qemu:commandline>
138
144
  <qemu:arg value='-device'/>
139
145
  <qemu:arg value='dummy-device'/>
146
+ <qemu:env name='QEMU_AUDIO_DRV' value='pa'/>
147
+ <qemu:env name='QEMU_AUDIO_TIMER_PERIOD' value='150'/>
148
+ <qemu:env name='QEMU_PA_SAMPLES' value='1024'/>
149
+ <qemu:env name='QEMU_PA_SERVER' value='/run/user/1000/pulse/native'/>
140
150
  </qemu:commandline>
141
151
  </domain>
@@ -11,7 +11,6 @@ describe 'templates/domain' do
11
11
 
12
12
  def finalize!
13
13
  super
14
- @qargs = @qemu_args
15
14
  end
16
15
  end
17
16
 
@@ -64,7 +63,7 @@ describe 'templates/domain' do
64
63
  source_path: '/tmp/foo')
65
64
  domain.random(model: 'random')
66
65
  domain.pci(bus: '0x06', slot: '0x12', function: '0x5')
67
- domain.pci(bus: '0x03', slot: '0x00', function: '0x0')
66
+ domain.pci(domain: '0x0001', bus: '0x03', slot: '0x00', function: '0x0')
68
67
  domain.usb_controller(model: 'nec-xhci', ports: '4')
69
68
  domain.usb(bus: '1', device: '2', vendor: '0x1234', product: '0xabcd')
70
69
  domain.redirdev(type: 'tcp', host: 'localhost', port: '4000')
@@ -76,6 +75,15 @@ describe 'templates/domain' do
76
75
 
77
76
  domain.qemuargs(value: '-device')
78
77
  domain.qemuargs(value: 'dummy-device')
78
+
79
+ domain.qemuenv(QEMU_AUDIO_DRV: 'pa')
80
+ domain.qemuenv(QEMU_AUDIO_TIMER_PERIOD: '150')
81
+ domain.qemuenv(QEMU_PA_SAMPLES: '1024')
82
+ domain.qemuenv(QEMU_PA_SERVER: '/run/user/1000/pulse/native')
83
+
84
+ domain.shares = '1024'
85
+ domain.cpuset = '1-4,^3,6'
86
+ domain.nodeset = '1-4,^3,6'
79
87
  end
80
88
  let(:test_file) { 'domain_all_settings.xml' }
81
89
  it 'renders template' 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.0.45
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Stanek
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-10-23 00:00:00.000000000 Z
13
+ date: 2020-05-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec-core
@@ -60,42 +60,42 @@ dependencies:
60
60
  requirements:
61
61
  - - ">="
62
62
  - !ruby/object:Gem::Version
63
- version: 0.3.0
63
+ version: 0.6.0
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
- version: 0.3.0
70
+ version: 0.6.0
71
71
  - !ruby/object:Gem::Dependency
72
- name: nokogiri
72
+ name: fog-core
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - ">="
75
+ - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: 1.6.0
77
+ version: '2.1'
78
78
  type: :runtime
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - ">="
82
+ - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: 1.6.0
84
+ version: '2.1'
85
85
  - !ruby/object:Gem::Dependency
86
- name: fog-core
86
+ name: nokogiri
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - "~>"
90
90
  - !ruby/object:Gem::Version
91
- version: 1.43.0
91
+ version: '1.6'
92
92
  type: :runtime
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - "~>"
97
97
  - !ruby/object:Gem::Version
98
- version: 1.43.0
98
+ version: '1.6'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: rake
101
101
  requirement: !ruby/object:Gem::Requirement
@@ -119,17 +119,8 @@ executables: []
119
119
  extensions: []
120
120
  extra_rdoc_files: []
121
121
  files:
122
- - ".coveralls.yml"
123
- - ".github/issue_template.md"
124
- - ".gitignore"
125
- - ".travis.yml"
126
- - Gemfile
127
122
  - LICENSE
128
123
  - README.md
129
- - Rakefile
130
- - example_box/README.md
131
- - example_box/Vagrantfile
132
- - example_box/metadata.json
133
124
  - lib/vagrant-libvirt.rb
134
125
  - lib/vagrant-libvirt/action.rb
135
126
  - lib/vagrant-libvirt/action/create_domain.rb
@@ -173,7 +164,6 @@ files:
173
164
  - lib/vagrant-libvirt/plugin.rb
174
165
  - lib/vagrant-libvirt/provider.rb
175
166
  - lib/vagrant-libvirt/templates/default_storage_pool.xml.erb
176
- - lib/vagrant-libvirt/templates/default_storage_volume.xml.erb
177
167
  - lib/vagrant-libvirt/templates/domain.xml.erb
178
168
  - lib/vagrant-libvirt/templates/private_network.xml.erb
179
169
  - lib/vagrant-libvirt/templates/public_interface.xml.erb
@@ -182,6 +172,7 @@ files:
182
172
  - lib/vagrant-libvirt/util/erb_template.rb
183
173
  - lib/vagrant-libvirt/util/error_codes.rb
184
174
  - lib/vagrant-libvirt/util/network_util.rb
175
+ - lib/vagrant-libvirt/util/nfs.rb
185
176
  - lib/vagrant-libvirt/util/storage_util.rb
186
177
  - lib/vagrant-libvirt/util/timer.rb
187
178
  - lib/vagrant-libvirt/version.rb
@@ -198,9 +189,6 @@ files:
198
189
  - spec/unit/templates/domain_custom_cpu_model.xml
199
190
  - spec/unit/templates/domain_defaults.xml
200
191
  - spec/unit/templates/domain_spec.rb
201
- - tools/create_box.sh
202
- - tools/prepare_redhat_for_box.sh
203
- - vagrant-libvirt.gemspec
204
192
  homepage: https://github.com/vagrant-libvirt/vagrant-libvirt
205
193
  licenses:
206
194
  - MIT
@@ -220,21 +208,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
208
  - !ruby/object:Gem::Version
221
209
  version: '0'
222
210
  requirements: []
223
- rubyforge_project:
224
- rubygems_version: 2.7.6
211
+ rubygems_version: 3.0.3
225
212
  signing_key:
226
213
  specification_version: 4
227
214
  summary: libvirt provider for Vagrant.
228
215
  test_files:
229
- - spec/spec_helper.rb
230
- - spec/support/environment_helper.rb
231
- - spec/support/libvirt_context.rb
232
- - spec/support/sharedcontext.rb
216
+ - spec/unit/action/wait_till_up_spec.rb
233
217
  - spec/unit/action/destroy_domain_spec.rb
234
218
  - spec/unit/action/set_name_of_domain_spec.rb
235
- - spec/unit/action/wait_till_up_spec.rb
236
219
  - spec/unit/config_spec.rb
237
- - spec/unit/templates/domain_all_settings.xml
238
- - spec/unit/templates/domain_custom_cpu_model.xml
239
220
  - spec/unit/templates/domain_defaults.xml
221
+ - spec/unit/templates/domain_all_settings.xml
240
222
  - spec/unit/templates/domain_spec.rb
223
+ - spec/unit/templates/domain_custom_cpu_model.xml
224
+ - spec/support/libvirt_context.rb
225
+ - spec/support/environment_helper.rb
226
+ - spec/support/sharedcontext.rb
227
+ - spec/spec_helper.rb