vagrant-libvirt 0.0.35 → 0.0.36
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 +477 -269
- data/lib/vagrant-libvirt/action/create_domain.rb +11 -2
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +4 -3
- data/lib/vagrant-libvirt/action/create_networks.rb +13 -4
- data/lib/vagrant-libvirt/action/forward_ports.rb +2 -2
- data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +1 -1
- data/lib/vagrant-libvirt/config.rb +60 -8
- data/lib/vagrant-libvirt/templates/domain.xml.erb +16 -0
- data/lib/vagrant-libvirt/templates/interface.xml.erb +8 -8
- data/lib/vagrant-libvirt/templates/public_interface.xml.erb +1 -1
- data/lib/vagrant-libvirt/version.rb +1 -1
- data/tools/prepare_redhat_for_box.sh +14 -14
- data/vagrant-libvirt.gemspec +1 -1
- metadata +6 -6
@@ -12,7 +12,7 @@ module VagrantPlugins
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def _disk_name(name, disk)
|
15
|
-
"#{name}-#{disk[:device]}.#{disk[:type]}"
|
15
|
+
"#{name}-#{disk[:device]}.#{disk[:type]}" # disk name
|
16
16
|
end
|
17
17
|
|
18
18
|
def _disks_print(disks)
|
@@ -37,6 +37,7 @@ module VagrantPlugins
|
|
37
37
|
@cpu_mode = config.cpu_mode
|
38
38
|
@cpu_model = config.cpu_model
|
39
39
|
@cpu_fallback = config.cpu_fallback
|
40
|
+
@numa_nodes = config.numa_nodes
|
40
41
|
@loader = config.loader
|
41
42
|
@machine_type = config.machine_type
|
42
43
|
@machine_arch = config.machine_arch
|
@@ -88,6 +89,9 @@ module VagrantPlugins
|
|
88
89
|
# USB device passthrough
|
89
90
|
@usbs = config.usbs
|
90
91
|
|
92
|
+
# RNG device passthrough
|
93
|
+
@rng =config.rng
|
94
|
+
|
91
95
|
config = env[:machine].provider_config
|
92
96
|
@domain_type = config.driver
|
93
97
|
|
@@ -191,7 +195,8 @@ module VagrantPlugins
|
|
191
195
|
|
192
196
|
@disks.each do |disk|
|
193
197
|
msg = " -- Disk(#{disk[:device]}): #{disk[:absolute_path]}"
|
194
|
-
msg += '
|
198
|
+
msg += ' Shared' if disk[:shareable]
|
199
|
+
msg += ' (Remove only manually)' if disk[:allow_existing]
|
195
200
|
msg += ' Not created - using existed.' if disk[:preexisting]
|
196
201
|
env[:ui].info(msg)
|
197
202
|
end
|
@@ -217,6 +222,10 @@ module VagrantPlugins
|
|
217
222
|
env[:ui].info(" -- PCI passthrough: #{pci[:bus]}:#{pci[:slot]}.#{pci[:function]}")
|
218
223
|
end
|
219
224
|
|
225
|
+
if !@rng[:model].nil?
|
226
|
+
env[:ui].info(" -- RNG device model: #{@rng[:model]}")
|
227
|
+
end
|
228
|
+
|
220
229
|
@usbs.each do |usb|
|
221
230
|
usb_dev = []
|
222
231
|
usb_dev.push("bus=#{usb[:bus]}") if usb[:bus]
|
@@ -17,8 +17,8 @@ module VagrantPlugins
|
|
17
17
|
def initialize(app, env)
|
18
18
|
@logger = Log4r::Logger.new('vagrant_libvirt::action::create_network_interfaces')
|
19
19
|
@management_network_name = env[:machine].provider_config.management_network_name
|
20
|
-
|
21
|
-
|
20
|
+
config = env[:machine].provider_config
|
21
|
+
@nic_model_type = config.nic_model_type
|
22
22
|
@nic_adapter_count = config.nic_adapter_count
|
23
23
|
@app = app
|
24
24
|
end
|
@@ -69,7 +69,7 @@ module VagrantPlugins
|
|
69
69
|
@network_name = iface_configuration[:network_name]
|
70
70
|
@mac = iface_configuration.fetch(:mac, false)
|
71
71
|
@model_type = iface_configuration.fetch(:model_type, @nic_model_type)
|
72
|
-
|
72
|
+
@device_name = iface_configuration.fetch(:iface_name, false)
|
73
73
|
template_name = 'interface'
|
74
74
|
# Configuration for public interfaces which use the macvtap driver
|
75
75
|
if iface_configuration[:iface_type] == :public_network
|
@@ -82,6 +82,7 @@ module VagrantPlugins
|
|
82
82
|
template_name = 'public_interface'
|
83
83
|
@logger.info("Setting up public interface using device #{@device} in mode #{@mode}")
|
84
84
|
@ovs = iface_configuration.fetch(:ovs, false)
|
85
|
+
@trust_guest_rx_filters = iface_configuration.fetch(:trust_guest_rx_filters, false)
|
85
86
|
# configuration for udp or tcp tunnel interfaces (p2p conn btwn guest OSes)
|
86
87
|
elsif iface_configuration.fetch(:tunnel_type, nil)
|
87
88
|
@type = iface_configuration.fetch(:tunnel_type)
|
@@ -210,10 +210,19 @@ module VagrantPlugins
|
|
210
210
|
network = lookup_network_by_name(@options[:network_name])
|
211
211
|
@interface_network = network if network
|
212
212
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
213
|
+
if @options[:libvirt__forward_mode] == "veryisolated"
|
214
|
+
# if this interface has a network address, something's wrong.
|
215
|
+
if @interface_network[:network_address]
|
216
|
+
raise Errors::NetworkNotAvailableError,
|
217
|
+
network_name: @options[:network_name]
|
218
|
+
end
|
219
|
+
else
|
220
|
+
if !@interface_network
|
221
|
+
raise Errors::NetworkNotAvailableError,
|
222
|
+
network_name: @options[:network_name]
|
223
|
+
else
|
224
|
+
verify_dhcp
|
225
|
+
end
|
217
226
|
end
|
218
227
|
|
219
228
|
# Do we need to create new network?
|
@@ -111,7 +111,7 @@ module VagrantPlugins
|
|
111
111
|
@env[:ui].info 'Requesting sudo for host port(s) <= 1024'
|
112
112
|
r = system('sudo -v')
|
113
113
|
if r
|
114
|
-
ssh_cmd << 'sudo '
|
114
|
+
ssh_cmd << 'sudo ' # add sudo prefix
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
@@ -175,7 +175,7 @@ module VagrantPlugins
|
|
175
175
|
kill_cmd = ''
|
176
176
|
|
177
177
|
if tag[:port] <= 1024
|
178
|
-
kill_cmd << 'sudo '
|
178
|
+
kill_cmd << 'sudo ' # add sudo prefix
|
179
179
|
end
|
180
180
|
|
181
181
|
kill_cmd << "kill #{tag[:pid]}"
|
@@ -62,6 +62,7 @@ module VagrantPlugins
|
|
62
62
|
attr_accessor :cpu_model
|
63
63
|
attr_accessor :cpu_fallback
|
64
64
|
attr_accessor :cpu_features
|
65
|
+
attr_accessor :numa_nodes
|
65
66
|
attr_accessor :loader
|
66
67
|
attr_accessor :boot_order
|
67
68
|
attr_accessor :machine_type
|
@@ -110,6 +111,9 @@ module VagrantPlugins
|
|
110
111
|
# PCI device passthrough
|
111
112
|
attr_accessor :pcis
|
112
113
|
|
114
|
+
# Random number device passthrough
|
115
|
+
attr_accessor :rng
|
116
|
+
|
113
117
|
# USB device passthrough
|
114
118
|
attr_accessor :usbs
|
115
119
|
|
@@ -143,6 +147,7 @@ module VagrantPlugins
|
|
143
147
|
@cpu_model = UNSET_VALUE
|
144
148
|
@cpu_fallback = UNSET_VALUE
|
145
149
|
@cpu_features = UNSET_VALUE
|
150
|
+
@numa_nodes = UNSET_VALUE
|
146
151
|
@loader = UNSET_VALUE
|
147
152
|
@machine_type = UNSET_VALUE
|
148
153
|
@machine_arch = UNSET_VALUE
|
@@ -173,10 +178,10 @@ module VagrantPlugins
|
|
173
178
|
@nic_adapter_count = UNSET_VALUE
|
174
179
|
|
175
180
|
# Boot order
|
176
|
-
@boot_order
|
181
|
+
@boot_order = []
|
177
182
|
# Storage
|
178
183
|
@disks = []
|
179
|
-
@cdroms
|
184
|
+
@cdroms = []
|
180
185
|
|
181
186
|
# Inputs
|
182
187
|
@inputs = UNSET_VALUE
|
@@ -187,6 +192,9 @@ module VagrantPlugins
|
|
187
192
|
# PCI device passthrough
|
188
193
|
@pcis = UNSET_VALUE
|
189
194
|
|
195
|
+
# Random number device passthrough
|
196
|
+
@rng = UNSET_VALUE
|
197
|
+
|
190
198
|
# USB device passthrough
|
191
199
|
@usbs = UNSET_VALUE
|
192
200
|
|
@@ -198,15 +206,15 @@ module VagrantPlugins
|
|
198
206
|
end
|
199
207
|
|
200
208
|
def boot(device)
|
201
|
-
@boot_order << device
|
209
|
+
@boot_order << device # append
|
202
210
|
end
|
203
211
|
|
204
212
|
def _get_device(disks)
|
205
213
|
# skip existing devices and also the first one (vda)
|
206
214
|
exist = disks.collect {|x| x[:device]}+[1.vdev.to_s]
|
207
|
-
skip = 1
|
215
|
+
skip = 1 # we're 1 based, not 0 based...
|
208
216
|
while true do
|
209
|
-
dev = skip.vdev
|
217
|
+
dev = skip.vdev # get lettered device
|
210
218
|
if !exist.include?(dev)
|
211
219
|
return dev
|
212
220
|
end
|
@@ -232,6 +240,33 @@ module VagrantPlugins
|
|
232
240
|
raise 'Only four cdroms may be attached at a time'
|
233
241
|
end
|
234
242
|
|
243
|
+
def _generate_numa
|
244
|
+
if @cpus % @numa_nodes != 0
|
245
|
+
raise 'NUMA nodes must be a factor of CPUs'
|
246
|
+
end
|
247
|
+
|
248
|
+
if @memory % @numa_nodes != 0
|
249
|
+
raise 'NUMA nodes must be a factor of memory'
|
250
|
+
end
|
251
|
+
|
252
|
+
numa = []
|
253
|
+
|
254
|
+
(1..@numa_nodes).each do |node|
|
255
|
+
numa_cpu_start = (@cpus / @numa_nodes) * (node - 1)
|
256
|
+
numa_cpu_end = (@cpus / @numa_nodes) * node - 1
|
257
|
+
numa_cpu = Array(numa_cpu_start..numa_cpu_end).join(',')
|
258
|
+
numa_mem = @memory / @numa_nodes
|
259
|
+
|
260
|
+
numa.push({
|
261
|
+
id: node,
|
262
|
+
cpu: numa_cpu,
|
263
|
+
mem: numa_mem
|
264
|
+
})
|
265
|
+
end
|
266
|
+
|
267
|
+
@numa_nodes = numa
|
268
|
+
end
|
269
|
+
|
235
270
|
def cpu_feature(options={})
|
236
271
|
if options[:name].nil? || options[:policy].nil?
|
237
272
|
raise 'CPU Feature name AND policy must be specified'
|
@@ -288,6 +323,18 @@ module VagrantPlugins
|
|
288
323
|
})
|
289
324
|
end
|
290
325
|
|
326
|
+
def random(options={})
|
327
|
+
if !options[:model].nil? && options[:model] != "random"
|
328
|
+
raise 'The only supported rng backend is "random".'
|
329
|
+
end
|
330
|
+
|
331
|
+
if @rng == UNSET_VALUE
|
332
|
+
@rng = {}
|
333
|
+
end
|
334
|
+
|
335
|
+
@rng[:model] = options[:model]
|
336
|
+
end
|
337
|
+
|
291
338
|
def pci(options={})
|
292
339
|
if options[:bus].nil? || options[:slot].nil? || options[:function].nil?
|
293
340
|
raise 'Bus AND slot AND function must be specified. Check `lspci` for that numbers.'
|
@@ -363,7 +410,7 @@ module VagrantPlugins
|
|
363
410
|
options = {
|
364
411
|
:device => _get_device(@disks),
|
365
412
|
:type => 'qcow2',
|
366
|
-
:size => '10G',
|
413
|
+
:size => '10G', # matches the fog default
|
367
414
|
:path => nil,
|
368
415
|
:bus => 'virtio'
|
369
416
|
}.merge(options)
|
@@ -376,9 +423,10 @@ module VagrantPlugins
|
|
376
423
|
:bus => options[:bus],
|
377
424
|
:cache => options[:cache] || 'default',
|
378
425
|
:allow_existing => options[:allow_existing],
|
426
|
+
:shareable => options[:shareable],
|
379
427
|
}
|
380
428
|
|
381
|
-
@disks << disk
|
429
|
+
@disks << disk # append
|
382
430
|
end
|
383
431
|
|
384
432
|
# code to generate URI from a config moved out of the connect action
|
@@ -397,7 +445,7 @@ module VagrantPlugins
|
|
397
445
|
raise "Require specify driver #{uri}"
|
398
446
|
end
|
399
447
|
if uri == 'kvm'
|
400
|
-
uri = 'qemu'
|
448
|
+
uri = 'qemu' # use qemu uri for kvm domain type
|
401
449
|
end
|
402
450
|
|
403
451
|
if @connect_via_ssh
|
@@ -457,6 +505,7 @@ module VagrantPlugins
|
|
457
505
|
@cpu_model = 'qemu64' if @cpu_model == UNSET_VALUE
|
458
506
|
@cpu_fallback = 'allow' if @cpu_fallback == UNSET_VALUE
|
459
507
|
@cpu_features = [] if @cpu_features == UNSET_VALUE
|
508
|
+
@numa_nodes = @numa_nodes == UNSET_VALUE ? nil : _generate_numa()
|
460
509
|
@loader = nil if @loader == UNSET_VALUE
|
461
510
|
@machine_type = nil if @machine_type == UNSET_VALUE
|
462
511
|
@machine_arch = nil if @machine_arch == UNSET_VALUE
|
@@ -504,6 +553,9 @@ module VagrantPlugins
|
|
504
553
|
# PCI device passthrough
|
505
554
|
@pcis = [] if @pcis == UNSET_VALUE
|
506
555
|
|
556
|
+
# Random number generator passthrough
|
557
|
+
@rng = {} if @rng == UNSET_VALUE
|
558
|
+
|
507
559
|
# USB device passthrough
|
508
560
|
@usbs = [] if @usbs == UNSET_VALUE
|
509
561
|
|
@@ -15,6 +15,14 @@
|
|
15
15
|
<% @cpu_features.each do |cpu_feature| %>
|
16
16
|
<feature name='<%= cpu_feature[:name] %>' policy='<%= cpu_feature[:policy] %>'/>
|
17
17
|
<% end %>
|
18
|
+
<% else %>
|
19
|
+
<% if @numa_nodes %>
|
20
|
+
<numa>
|
21
|
+
<% @numa_nodes.each do |node| %>
|
22
|
+
<cell id='<%= node[:id] %>' cpus='<%= node[:cpu] %>' memory='<%= node[:mem] %>'/>
|
23
|
+
<% end %>
|
24
|
+
</numa>
|
25
|
+
<% end %>
|
18
26
|
<% end %>
|
19
27
|
</cpu>
|
20
28
|
|
@@ -75,6 +83,9 @@
|
|
75
83
|
<driver name='qemu' type='<%= d[:type] %>' cache='<%= d[:cache] %>'/>
|
76
84
|
<source file='<%= d[:absolute_path] %>'/>
|
77
85
|
<target dev='<%= d[:device] %>' bus='<%= d[:bus] %>'/>
|
86
|
+
<% if d[:shareable] %>
|
87
|
+
<shareable/>
|
88
|
+
<% end %>
|
78
89
|
<%# this will get auto generated by libvirt
|
79
90
|
<address type='pci' domain='0x0000' bus='0x00' slot='???' function='0x0'/>
|
80
91
|
-%>
|
@@ -129,6 +140,11 @@
|
|
129
140
|
</video>
|
130
141
|
<%#End Video -%>
|
131
142
|
<% end %>
|
143
|
+
<% if @rng[:model] == "random"%>
|
144
|
+
<rng model='virtio'>
|
145
|
+
<backend model='random'>/dev/random</backend>
|
146
|
+
</rng>
|
147
|
+
<% end %>
|
132
148
|
<% @pcis.each do |pci| %>
|
133
149
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
134
150
|
<source>
|
@@ -1,13 +1,13 @@
|
|
1
1
|
<interface type='network'>
|
2
2
|
<source network='<%= @network_name %>'/>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
<% if @mac %>
|
4
|
+
<mac address='<%= @mac %>'/>
|
5
|
+
<% end %>
|
6
|
+
<% if @device_name %>
|
7
|
+
<target dev='<%= @device_name %>'/>
|
8
|
+
<% else %>
|
9
|
+
<target dev='vnet<%= @iface_number %>'/>
|
10
|
+
<% end %>
|
11
11
|
<alias name='net<%= @iface_number %>'/>
|
12
12
|
<model type='<%=@model_type%>'/>
|
13
13
|
</interface>
|
@@ -12,17 +12,17 @@
|
|
12
12
|
|
13
13
|
# We need to set a hostname.
|
14
14
|
if [ $# -ne 1 ]; then
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
echo "Usage: $0 <hostname>"
|
16
|
+
echo "Hostname should be in format vagrant-[os-name], e.g. vagrant-redhat63."
|
17
|
+
exit 1
|
18
18
|
fi
|
19
19
|
|
20
20
|
|
21
21
|
# On which version of RedHet are we running?
|
22
22
|
RHEL_MAJOR_VERSION=$(sed 's/.*release \([0-9]\)\..*/\1/' /etc/redhat-release)
|
23
23
|
if [ $? -ne 0 ]; then
|
24
|
-
|
25
|
-
|
24
|
+
echo "Is this a RedHat distro?"
|
25
|
+
exit 1
|
26
26
|
fi
|
27
27
|
echo "* Found RedHat ${RHEL_MAJOR_VERSION} version."
|
28
28
|
|
@@ -30,9 +30,9 @@ echo "* Found RedHat ${RHEL_MAJOR_VERSION} version."
|
|
30
30
|
# Setup hostname vagrant-something.
|
31
31
|
FQDN="$1.vagrantup.com"
|
32
32
|
if grep '^HOSTNAME=' /etc/sysconfig/network > /dev/null; then
|
33
|
-
|
33
|
+
sed -i 's/HOSTNAME=\(.*\)/HOSTNAME='${FQDN}'/' /etc/sysconfig/network
|
34
34
|
else
|
35
|
-
|
35
|
+
echo "HOSTNAME=${FQDN}" >> /etc/sysconfig/network
|
36
36
|
fi
|
37
37
|
|
38
38
|
|
@@ -40,11 +40,11 @@ fi
|
|
40
40
|
yum -y install wget
|
41
41
|
cd ~root
|
42
42
|
if [ $RHEL_MAJOR_VERSION -eq 5 ]; then
|
43
|
-
|
44
|
-
|
43
|
+
wget http://ftp.astral.ro/mirrors/fedora/pub/epel/5/i386/epel-release-5-4.noarch.rpm
|
44
|
+
EPEL_PKG="epel-release-5-4.noarch.rpm"
|
45
45
|
else
|
46
|
-
|
47
|
-
|
46
|
+
wget http://ftp.astral.ro/mirrors/fedora/pub/epel/6/i386/epel-release-6-8.noarch.rpm
|
47
|
+
EPEL_PKG="epel-release-6-8.noarch.rpm"
|
48
48
|
fi
|
49
49
|
rpm -i ~root/${EPEL_PKG}
|
50
50
|
rm -f ~root/${EPEL_PKG}
|
@@ -60,9 +60,9 @@ chkconfig sshd on
|
|
60
60
|
echo 'vagrant' | passwd --stdin root
|
61
61
|
grep 'vagrant' /etc/passwd > /dev/null
|
62
62
|
if [ $? -ne 0 ]; then
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
echo '* Creating user vagrant.'
|
64
|
+
useradd vagrant
|
65
|
+
echo 'vagrant' | passwd --stdin vagrant
|
66
66
|
fi
|
67
67
|
grep '^admin:' /etc/group > /dev/null || groupadd admin
|
68
68
|
usermod -G admin vagrant
|
data/vagrant-libvirt.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_development_dependency "rspec-expectations", "~> 2.14.0"
|
21
21
|
gem.add_development_dependency "rspec-mocks", "~> 2.14.0"
|
22
22
|
|
23
|
-
gem.add_runtime_dependency 'fog-libvirt', '0.0
|
23
|
+
gem.add_runtime_dependency 'fog-libvirt', '>= 0.3.0'
|
24
24
|
gem.add_runtime_dependency 'nokogiri', '~> 1.6.0'
|
25
25
|
|
26
26
|
gem.add_development_dependency 'rake'
|
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.
|
4
|
+
version: 0.0.36
|
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: 2016-
|
13
|
+
date: 2016-10-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec-core
|
@@ -58,16 +58,16 @@ dependencies:
|
|
58
58
|
name: fog-libvirt
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: 0.0
|
63
|
+
version: 0.3.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.0
|
70
|
+
version: 0.3.0
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: nokogiri
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|