vagrant-libvirt 0.2.1 → 0.3.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 +43 -5
- data/lib/vagrant-libvirt/action/create_domain.rb +21 -6
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +1 -0
- data/lib/vagrant-libvirt/action/handle_box_image.rb +6 -3
- data/lib/vagrant-libvirt/action/package_domain.rb +8 -3
- data/lib/vagrant-libvirt/action/start_domain.rb +1 -1
- data/lib/vagrant-libvirt/config.rb +2 -1
- data/lib/vagrant-libvirt/templates/public_interface.xml.erb +5 -1
- data/lib/vagrant-libvirt/util.rb +1 -0
- data/lib/vagrant-libvirt/util/ui.rb +23 -0
- data/lib/vagrant-libvirt/version +1 -0
- data/lib/vagrant-libvirt/version.rb +24 -1
- data/spec/support/sharedcontext.rb +1 -1
- data/spec/unit/action/create_domain_spec.rb +85 -0
- data/spec/unit/action/create_domain_spec/default_storage_pool.xml +17 -0
- data/spec/unit/action/start_domain_spec.rb +49 -0
- data/spec/unit/action/start_domain_spec/default.xml +48 -0
- metadata +20 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4200a82105f1c9bf2860841eb3c801b103649c76afae39e303f28542316f0bbd
|
4
|
+
data.tar.gz: fd14f23b17262da08eac29401b779cde545913cb9b6bf4240b044a93a35fed52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c068629389967340010d5d94594111fbbf661e895ede714bc45898bc7d2e21f860a8c8d6e9cdc4b7ae5ee77cdd1b6dd313193cb2d7b634971a251456695959b
|
7
|
+
data.tar.gz: 724c11548cf02a12567bbb87470087539e39ed70aa67dd2d5938a6ed5879667fc03315022dfc1c2c6ca367b2da2552cb408e264c9fd1b2ab090506723f67a688
|
data/README.md
CHANGED
@@ -110,7 +110,7 @@ docker pull vagrantlibvirt/vagrant-libvirt:latest
|
|
110
110
|
|
111
111
|
Running the image:
|
112
112
|
```bash
|
113
|
-
docker run -it
|
113
|
+
docker run -it --rm \
|
114
114
|
-e LIBVIRT_DEFAULT_URI \
|
115
115
|
-v /var/run/libvirt/:/var/run/libvirt/ \
|
116
116
|
-v ~/.vagrant.d:/.vagrant.d \
|
@@ -231,6 +231,43 @@ If you have issues building ruby-libvirt, try the following:
|
|
231
231
|
```shell
|
232
232
|
CONFIGURE_ARGS='with-ldflags=-L/opt/vagrant/embedded/lib with-libvirt-include=/usr/include/libvirt with-libvirt-lib=/usr/lib' GEM_HOME=~/.vagrant.d/gems GEM_PATH=$GEM_HOME:/opt/vagrant/embedded/gems PATH=/opt/vagrant/embedded/bin:$PATH vagrant plugin install vagrant-libvirt
|
233
233
|
```
|
234
|
+
### Additional Notes for Fedora and Similar Linux Distributions
|
235
|
+
|
236
|
+
If you encounter the following load error when using the vagrant-libvirt plugin (note the required by libssh):
|
237
|
+
|
238
|
+
```shell
|
239
|
+
/opt/vagrant/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': /opt/vagrant/embedded/lib64/libcrypto.so.1.1: version `OPENSSL_1_1_1b' not found (required by /lib64/libssh.so.4) - /home/xxx/.vagrant.d/gems/2.4.6/gems/ruby-libvirt-0.7.1/lib/_libvirt.so (LoadError)
|
240
|
+
```
|
241
|
+
then the following steps have been found to resolve the problem. Thanks to James Reynolds (see https://github.com/hashicorp/vagrant/issues/11020#issuecomment-540043472). The specific version of libssh will change over time so references to the rpm in the commands below will need to be adjusted accordingly.
|
242
|
+
|
243
|
+
```shell
|
244
|
+
dnf download --source libssh
|
245
|
+
rpm2cpio libssh-0.9.0-5.fc30.src.rpm | cpio -imdV
|
246
|
+
tar xf libssh-0.9.0.tar.xz
|
247
|
+
mkdir build
|
248
|
+
cd build
|
249
|
+
cmake ../libssh-0.9.0 -DOPENSSL_ROOT_DIR=/opt/vagrant/embedded/
|
250
|
+
make
|
251
|
+
sudo cp lib/libssh* /opt/vagrant/embedded/lib64
|
252
|
+
```
|
253
|
+
|
254
|
+
If you encounter the following load error when using the vagrant-libvirt plugin (note the required by libk5crypto):
|
255
|
+
|
256
|
+
```shell
|
257
|
+
/opt/vagrant/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': /usr/lib64/libk5crypto.so.3: undefined symbol: EVP_KDF_ctrl, version OPENSSL_1_1_1b - /home/rbelgrave/.vagrant.d/gems/2.4.9/gems/ruby-libvirt-0.7.1/lib/_libvirt.so (LoadError)
|
258
|
+
```
|
259
|
+
|
260
|
+
then the following steps have been found to resolve the problem. After the steps below are complete, then reinstall the vagrant-libvirt plugin without setting the `CONFIGURE_ARGS`. Thanks to Marco Bevc (see https://github.com/hashicorp/vagrant/issues/11020#issuecomment-625801983):
|
261
|
+
|
262
|
+
```shell
|
263
|
+
dnf download --source krb5-libs
|
264
|
+
rpm2cpio krb5-1.18-1.fc32.src.rpm | cpio -imdV
|
265
|
+
tar xf krb5-1.18.tar.gz
|
266
|
+
cd krb5-1.18/src
|
267
|
+
./configure
|
268
|
+
make
|
269
|
+
sudo cp -P lib/crypto/libk5crypto.* /opt/vagrant/embedded/lib64/
|
270
|
+
```
|
234
271
|
|
235
272
|
## Vagrant Project Preparation
|
236
273
|
|
@@ -671,8 +708,8 @@ starts with `libvirt__` string. Here is a list of those options:
|
|
671
708
|
only when dhcp is enabled.By default is the same host that runs the DHCP
|
672
709
|
server.
|
673
710
|
* `:libvirt__adapter` - Number specifiyng sequence number of interface.
|
674
|
-
* `:libvirt__forward_mode` - Specify one of `veryisolated`, `none`, `nat`
|
675
|
-
`route` options. This option is used only when creating new network. Mode
|
711
|
+
* `:libvirt__forward_mode` - Specify one of `veryisolated`, `none`, `open`, `nat`
|
712
|
+
or `route` options. This option is used only when creating new network. Mode
|
676
713
|
`none` will create isolated network without NATing or routing outside. You
|
677
714
|
will want to use NATed forwarding typically to reach networks outside of
|
678
715
|
hypervisor. Routed forwarding is typically useful to reach other networks
|
@@ -751,6 +788,7 @@ virtual network.
|
|
751
788
|
* `:portgroup` - Name of Libvirt portgroup to connect to.
|
752
789
|
* `:ovs` - Support to connect to an Open vSwitch bridge device. Default is
|
753
790
|
'false'.
|
791
|
+
* :ovs_interfaceid - Add Open vSwitch 'interfaceid' parameter.
|
754
792
|
* `:trust_guest_rx_filters` - Support trustGuestRxFilters attribute. Details
|
755
793
|
are listed [here](http://www.libvirt.org/formatdomain.html#elementsNICSDirect).
|
756
794
|
Default is 'false'.
|
@@ -769,8 +807,8 @@ used by this network are configurable at the provider level.
|
|
769
807
|
connected. Must include the address and subnet mask. If not specified the
|
770
808
|
default is '192.168.121.0/24'.
|
771
809
|
* `management_network_mode` - Network mode for the Libvirt management network.
|
772
|
-
Specify one of veryisolated, none, nat or route options. Further
|
773
|
-
under [Private Networks](#private-network-options)
|
810
|
+
Specify one of veryisolated, none, open, nat or route options. Further
|
811
|
+
documented under [Private Networks](#private-network-options)
|
774
812
|
* `management_network_guest_ipv6` - Enable or disable guest-to-guest IPv6
|
775
813
|
communication. See
|
776
814
|
[here](https://libvirt.org/formatnetwork.html#examplesPrivate6), and
|
@@ -151,10 +151,7 @@ module VagrantPlugins
|
|
151
151
|
if env[:machine].config.vm.box
|
152
152
|
storage_prefix = File.dirname(@domain_volume_path) + '/' # steal
|
153
153
|
else
|
154
|
-
|
155
|
-
raise Errors::NoStoragePool if storage_pool.nil?
|
156
|
-
xml = Nokogiri::XML(storage_pool.xml_desc)
|
157
|
-
storage_prefix = xml.xpath('/pool/target/path').inner_text.to_s + '/'
|
154
|
+
storage_prefix = get_disk_storage_prefix(env, @storage_pool_name)
|
158
155
|
end
|
159
156
|
end
|
160
157
|
|
@@ -169,6 +166,16 @@ module VagrantPlugins
|
|
169
166
|
|
170
167
|
disk[:absolute_path] = storage_prefix + disk[:path]
|
171
168
|
|
169
|
+
if not disk[:pool].nil?
|
170
|
+
disk_pool_name = disk[:pool]
|
171
|
+
@logger.debug "Overriding pool name with: #{disk_pool_name}"
|
172
|
+
disk_storage_prefix = get_disk_storage_prefix(env, disk_pool_name)
|
173
|
+
disk[:absolute_path] = disk_storage_prefix + disk[:path]
|
174
|
+
@logger.debug "Overriding disk path with: #{disk[:absolute_path]}"
|
175
|
+
else
|
176
|
+
disk_pool_name = @storage_pool_name
|
177
|
+
end
|
178
|
+
|
172
179
|
# make the disk. equivalent to:
|
173
180
|
# qemu-img create -f qcow2 <path> 5g
|
174
181
|
begin
|
@@ -178,7 +185,7 @@ module VagrantPlugins
|
|
178
185
|
path: disk[:absolute_path],
|
179
186
|
capacity: disk[:size],
|
180
187
|
#:allocation => ?,
|
181
|
-
pool_name:
|
188
|
+
pool_name: disk_pool_name
|
182
189
|
)
|
183
190
|
rescue Libvirt::Error => e
|
184
191
|
# It is hard to believe that e contains just a string
|
@@ -188,7 +195,7 @@ module VagrantPlugins
|
|
188
195
|
if e.message == msg and disk[:allow_existing]
|
189
196
|
disk[:preexisting] = true
|
190
197
|
else
|
191
|
-
raise Errors::
|
198
|
+
raise Errors::FogCreateDomainVolumeError,
|
192
199
|
error_message: e.message
|
193
200
|
end
|
194
201
|
end
|
@@ -366,6 +373,14 @@ module VagrantPlugins
|
|
366
373
|
|
367
374
|
@app.call(env)
|
368
375
|
end
|
376
|
+
|
377
|
+
private
|
378
|
+
def get_disk_storage_prefix(env, disk_pool_name)
|
379
|
+
disk_storage_pool = env[:machine].provider.driver.connection.client.lookup_storage_pool_by_name(disk_pool_name)
|
380
|
+
raise Errors::NoStoragePool if disk_storage_pool.nil?
|
381
|
+
xml = Nokogiri::XML(disk_storage_pool.xml_desc)
|
382
|
+
disk_storage_prefix = xml.xpath('/pool/target/path').inner_text.to_s + '/'
|
383
|
+
end
|
369
384
|
end
|
370
385
|
end
|
371
386
|
end
|
@@ -95,6 +95,7 @@ module VagrantPlugins
|
|
95
95
|
template_name = 'public_interface'
|
96
96
|
@logger.info("Setting up public interface using device #{@device} in mode #{@mode}")
|
97
97
|
@ovs = iface_configuration.fetch(:ovs, false)
|
98
|
+
@ovs_interfaceid = iface_configuration.fetch(:ovs_interfaceid, false)
|
98
99
|
@trust_guest_rx_filters = iface_configuration.fetch(:trust_guest_rx_filters, false)
|
99
100
|
# configuration for udp or tcp tunnel interfaces (p2p conn btwn guest OSes)
|
100
101
|
elsif iface_configuration.fetch(:tunnel_type, nil)
|
@@ -5,6 +5,7 @@ module VagrantPlugins
|
|
5
5
|
module Action
|
6
6
|
class HandleBoxImage
|
7
7
|
include VagrantPlugins::ProviderLibvirt::Util::StorageUtil
|
8
|
+
include VagrantPlugins::ProviderLibvirt::Util::Ui
|
8
9
|
|
9
10
|
|
10
11
|
@@lock = Mutex.new
|
@@ -102,13 +103,15 @@ module VagrantPlugins
|
|
102
103
|
# Upload box image to storage pool
|
103
104
|
ret = upload_image(box_image_file, config.storage_pool_name,
|
104
105
|
env[:box_volume_name], env) do |progress|
|
105
|
-
env[:ui]
|
106
|
-
|
106
|
+
rewriting(env[:ui]) do |ui|
|
107
|
+
ui.clear_line
|
108
|
+
ui.report_progress(progress, box_image_size, false)
|
109
|
+
end
|
107
110
|
end
|
108
111
|
|
109
112
|
# Clear the line one last time since the progress meter doesn't
|
110
113
|
# disappear immediately.
|
111
|
-
env[:ui].clear_line
|
114
|
+
rewriting(env[:ui]) {|ui| ui.clear_line}
|
112
115
|
|
113
116
|
# If upload failed or was interrupted, remove created volume from
|
114
117
|
# storage pool.
|
@@ -6,6 +6,9 @@ module VagrantPlugins
|
|
6
6
|
module Action
|
7
7
|
# Action for create new box for Libvirt provider
|
8
8
|
class PackageDomain
|
9
|
+
include VagrantPlugins::ProviderLibvirt::Util::Ui
|
10
|
+
|
11
|
+
|
9
12
|
def initialize(app, env)
|
10
13
|
@logger = Log4r::Logger.new('vagrant_libvirt::action::package_domain')
|
11
14
|
@app = app
|
@@ -31,12 +34,14 @@ module VagrantPlugins
|
|
31
34
|
env[:ui].info("Downloading #{root_disk.name} to #{@tmp_img}")
|
32
35
|
ret = download_image(@tmp_img, env[:machine].provider_config.storage_pool_name,
|
33
36
|
root_disk.name, env) do |progress,image_size|
|
34
|
-
env[:ui]
|
35
|
-
|
37
|
+
rewriting(env[:ui]) do |ui|
|
38
|
+
ui.clear_line
|
39
|
+
ui.report_progress(progress, image_size, false)
|
40
|
+
end
|
36
41
|
end
|
37
42
|
# Clear the line one last time since the progress meter doesn't
|
38
43
|
# disappear immediately.
|
39
|
-
env[:ui].clear_line
|
44
|
+
rewriting(env[:ui]) {|ui| ui.clear_line}
|
40
45
|
backing = `qemu-img info "#{@tmp_img}" | grep 'backing file:' | cut -d ':' -f2`.chomp
|
41
46
|
if backing
|
42
47
|
env[:ui].info('Image has backing image, copying image and rebasing ...')
|
@@ -94,7 +94,7 @@ module VagrantPlugins
|
|
94
94
|
cpu_model.attributes['fallback'] = 'allow'
|
95
95
|
cpu_model.text = config.cpu_model
|
96
96
|
else
|
97
|
-
if cpu_model.text != config.cpu_model
|
97
|
+
if cpu_model.text.strip != config.cpu_model.strip
|
98
98
|
descr_changed = true
|
99
99
|
cpu_model.text = config.cpu_model
|
100
100
|
end
|
@@ -605,7 +605,8 @@ module VagrantPlugins
|
|
605
605
|
allow_existing: options[:allow_existing],
|
606
606
|
shareable: options[:shareable],
|
607
607
|
serial: options[:serial],
|
608
|
-
|
608
|
+
pool: options[:pool], # overrides storage_pool setting for additional disks
|
609
|
+
wwn: options[:wwn],
|
609
610
|
}
|
610
611
|
|
611
612
|
@disks << disk # append
|
@@ -18,7 +18,11 @@
|
|
18
18
|
<driver name='<%=@driver_name%>'/>
|
19
19
|
<% end %>
|
20
20
|
<% if @ovs %>
|
21
|
-
<virtualport type='openvswitch'
|
21
|
+
<virtualport type='openvswitch'>
|
22
|
+
<% if @ovs_interfaceid %>
|
23
|
+
<parameters interfaceid='<%=@ovs_interfaceid%>'/>
|
24
|
+
<% end %>
|
25
|
+
</virtualport>
|
22
26
|
<% end %>
|
23
27
|
<% if @pci_bus and @pci_slot %>
|
24
28
|
<address type='pci' bus='<%=@pci_bus%>' slot='<%=@pci_slot%>' />
|
data/lib/vagrant-libvirt/util.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
module VagrantPlugins
|
3
|
+
module ProviderLibvirt
|
4
|
+
module Util
|
5
|
+
module Ui
|
6
|
+
# Since v2.2.8 Vagrant support --no-tty option, which silences
|
7
|
+
# progress bars and other interactive elements for cleaner logs
|
8
|
+
# in scripts, but requires a slight change in UI object handling.
|
9
|
+
# This helper allows the vagrant-libvirt plugin to stay compatible
|
10
|
+
# with the older Vagrant versions.
|
11
|
+
# See: https://github.com/hashicorp/vagrant/pull/11465/
|
12
|
+
def rewriting(ui)
|
13
|
+
if ui.respond_to?(:rewriting)
|
14
|
+
ui.rewriting {|rw| yield rw}
|
15
|
+
else
|
16
|
+
yield ui
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
0.3.0
|
@@ -1,5 +1,28 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module ProviderLibvirt
|
3
|
-
|
3
|
+
VERSION_FILE = File.dirname(__FILE__) + "/version"
|
4
|
+
|
5
|
+
def self.get_version
|
6
|
+
if File.exist?(VERSION_FILE)
|
7
|
+
version = File.read(VERSION_FILE)
|
8
|
+
else
|
9
|
+
git_version = `git describe --tags`
|
10
|
+
version_parts = git_version.split('-').first(2) # drop the git sha if it exists
|
11
|
+
if version_parts.length > 1
|
12
|
+
# increment the patch number so that this is marked as a pre-release of the
|
13
|
+
# next possible release
|
14
|
+
main_version_parts = Gem::Version.new(version_parts[0]).segments
|
15
|
+
main_version_parts[-1] = main_version_parts.last + 1
|
16
|
+
version_parts = main_version_parts + ["pre", version_parts[1]]
|
17
|
+
end
|
18
|
+
version = version_parts.join(".")
|
19
|
+
end
|
20
|
+
|
21
|
+
return version.freeze
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.write_version
|
25
|
+
File.write(VERSION_FILE, self.get_version)
|
26
|
+
end
|
4
27
|
end
|
5
28
|
end
|
@@ -17,7 +17,7 @@ shared_context 'unit' do
|
|
17
17
|
end
|
18
18
|
let(:env) { { env: iso_env, machine: machine, ui: ui, root_path: '/rootpath' } }
|
19
19
|
let(:conf) { Vagrant::Config::V2::DummyConfig.new }
|
20
|
-
let(:ui) { Vagrant::UI::
|
20
|
+
let(:ui) { Vagrant::UI::Silent.new }
|
21
21
|
let(:iso_env) { test_env.create_vagrant_env ui_class: Vagrant::UI::Basic }
|
22
22
|
let(:machine) { iso_env.machine(:test, :libvirt) }
|
23
23
|
# Mock the communicator to prevent SSH commands for being executed.
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'support/sharedcontext'
|
3
|
+
require 'support/libvirt_context'
|
4
|
+
|
5
|
+
require 'vagrant-libvirt/errors'
|
6
|
+
require 'vagrant-libvirt/action/create_domain'
|
7
|
+
|
8
|
+
describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
|
9
|
+
subject { described_class.new(app, env) }
|
10
|
+
|
11
|
+
include_context 'unit'
|
12
|
+
include_context 'libvirt'
|
13
|
+
|
14
|
+
let(:libvirt_client) { double('libvirt_client') }
|
15
|
+
let(:servers) { double('servers') }
|
16
|
+
let(:volumes) { double('volumes') }
|
17
|
+
|
18
|
+
let(:storage_pool_xml) { File.read(File.join(File.dirname(__FILE__), File.basename(__FILE__, '.rb'), test_file)) }
|
19
|
+
let(:libvirt_storage_pool) { double('storage_pool') }
|
20
|
+
|
21
|
+
describe '#call' do
|
22
|
+
before do
|
23
|
+
allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver)
|
24
|
+
.to receive(:connection).and_return(connection)
|
25
|
+
allow(connection).to receive(:client).and_return(libvirt_client)
|
26
|
+
|
27
|
+
allow(connection).to receive(:servers).and_return(servers)
|
28
|
+
allow(connection).to receive(:volumes).and_return(volumes)
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'default pool' do
|
32
|
+
let(:test_file) { 'default_storage_pool.xml' }
|
33
|
+
|
34
|
+
it 'should execute correctly' do
|
35
|
+
expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
|
36
|
+
expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
|
37
|
+
expect(servers).to receive(:create).and_return(machine)
|
38
|
+
|
39
|
+
expect(subject.call(env)).to be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'additional disks' do
|
43
|
+
let(:vagrantfile) do
|
44
|
+
<<-EOF
|
45
|
+
Vagrant.configure('2') do |config|
|
46
|
+
config.vm.define :test
|
47
|
+
config.vm.provider :libvirt do |libvirt|
|
48
|
+
libvirt.storage :file, :size => '20G'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
EOF
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'volume create failed' do
|
55
|
+
it 'should raise an exception' do
|
56
|
+
expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
|
57
|
+
expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
|
58
|
+
expect(volumes).to receive(:create).and_raise(Libvirt::Error)
|
59
|
+
|
60
|
+
expect{ subject.call(env) }.to raise_error(VagrantPlugins::ProviderLibvirt::Errors::FogCreateDomainVolumeError)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'volume create succeeded' do
|
65
|
+
it 'should complete' do
|
66
|
+
expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
|
67
|
+
expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
|
68
|
+
expect(volumes).to receive(:create)
|
69
|
+
expect(servers).to receive(:create).and_return(machine)
|
70
|
+
|
71
|
+
expect(subject.call(env)).to be_nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'no default pool' do
|
78
|
+
it 'should raise an exception' do
|
79
|
+
expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(nil)
|
80
|
+
|
81
|
+
expect{ subject.call(env) }.to raise_error(VagrantPlugins::ProviderLibvirt::Errors::NoStoragePool)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<pool type='dir'>
|
2
|
+
<name>default</name>
|
3
|
+
<uuid>434e1b75-4a72-45d7-8a98-ebd90c125d22</uuid>
|
4
|
+
<capacity unit='bytes'>10737418240</capacity>
|
5
|
+
<allocation unit='bytes'>10737418240</allocation>
|
6
|
+
<available unit='bytes'>10737418240</available>
|
7
|
+
<source>
|
8
|
+
</source>
|
9
|
+
<target>
|
10
|
+
<path>/var/lib/libvirt/images</path>
|
11
|
+
<permissions>
|
12
|
+
<mode>0755</mode>
|
13
|
+
<owner>0</owner>
|
14
|
+
<group>0</group>
|
15
|
+
</permissions>
|
16
|
+
</target>
|
17
|
+
</pool>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'support/sharedcontext'
|
3
|
+
require 'support/libvirt_context'
|
4
|
+
|
5
|
+
require 'vagrant-libvirt/errors'
|
6
|
+
require 'vagrant-libvirt/action/start_domain'
|
7
|
+
|
8
|
+
describe VagrantPlugins::ProviderLibvirt::Action::StartDomain do
|
9
|
+
subject { described_class.new(app, env) }
|
10
|
+
|
11
|
+
include_context 'unit'
|
12
|
+
include_context 'libvirt'
|
13
|
+
|
14
|
+
let(:libvirt_domain) { double('libvirt_domain') }
|
15
|
+
let(:libvirt_client) { double('libvirt_client') }
|
16
|
+
let(:servers) { double('servers') }
|
17
|
+
|
18
|
+
let(:domain_xml) { File.read(File.join(File.dirname(__FILE__), File.basename(__FILE__, '.rb'), test_file)) }
|
19
|
+
|
20
|
+
describe '#call' do
|
21
|
+
before do
|
22
|
+
allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver)
|
23
|
+
.to receive(:connection).and_return(connection)
|
24
|
+
allow(connection).to receive(:client).and_return(libvirt_client)
|
25
|
+
allow(libvirt_client).to receive(:lookup_domain_by_uuid).and_return(libvirt_domain)
|
26
|
+
|
27
|
+
allow(connection).to receive(:servers).and_return(servers)
|
28
|
+
allow(servers).to receive(:get).and_return(domain)
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'default config' do
|
32
|
+
let(:test_file) { 'default.xml' }
|
33
|
+
|
34
|
+
before do
|
35
|
+
allow(libvirt_domain).to receive(:xml_desc).and_return(domain_xml)
|
36
|
+
|
37
|
+
allow(libvirt_domain).to receive(:max_memory).and_return(512*1024)
|
38
|
+
allow(libvirt_domain).to receive(:num_vcpus).and_return(1)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should execute correctly' do
|
42
|
+
expect(libvirt_domain).to receive(:autostart=)
|
43
|
+
expect(domain).to receive(:start)
|
44
|
+
|
45
|
+
expect(subject.call(env)).to be_nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<domain xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0' type=''>
|
2
|
+
<name/>
|
3
|
+
<title/>
|
4
|
+
<description/>
|
5
|
+
<uuid/>
|
6
|
+
<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/>
|
18
|
+
<initrd></initrd>
|
19
|
+
<cmdline/>
|
20
|
+
</os>
|
21
|
+
<features>
|
22
|
+
<acpi/>
|
23
|
+
<apic/>
|
24
|
+
<pae/>
|
25
|
+
</features>
|
26
|
+
<clock offset='utc'/>
|
27
|
+
<devices>
|
28
|
+
|
29
|
+
|
30
|
+
<serial type='pty'>
|
31
|
+
<target port='0'/>
|
32
|
+
</serial>
|
33
|
+
<console type='pty'>
|
34
|
+
<target port='0'/>
|
35
|
+
</console>
|
36
|
+
|
37
|
+
|
38
|
+
<input bus='ps2' type='mouse'/>
|
39
|
+
|
40
|
+
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'/>
|
41
|
+
<video>
|
42
|
+
<model heads='1' type='cirrus' vram='9216'/>
|
43
|
+
</video>
|
44
|
+
|
45
|
+
|
46
|
+
</devices>
|
47
|
+
|
48
|
+
</domain>
|
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.
|
4
|
+
version: 0.3.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: 2020-
|
13
|
+
date: 2020-11-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec-core
|
@@ -176,14 +176,20 @@ files:
|
|
176
176
|
- lib/vagrant-libvirt/util/nfs.rb
|
177
177
|
- lib/vagrant-libvirt/util/storage_util.rb
|
178
178
|
- lib/vagrant-libvirt/util/timer.rb
|
179
|
+
- lib/vagrant-libvirt/util/ui.rb
|
180
|
+
- lib/vagrant-libvirt/version
|
179
181
|
- lib/vagrant-libvirt/version.rb
|
180
182
|
- locales/en.yml
|
181
183
|
- spec/spec_helper.rb
|
182
184
|
- spec/support/environment_helper.rb
|
183
185
|
- spec/support/libvirt_context.rb
|
184
186
|
- spec/support/sharedcontext.rb
|
187
|
+
- spec/unit/action/create_domain_spec.rb
|
188
|
+
- spec/unit/action/create_domain_spec/default_storage_pool.xml
|
185
189
|
- spec/unit/action/destroy_domain_spec.rb
|
186
190
|
- spec/unit/action/set_name_of_domain_spec.rb
|
191
|
+
- spec/unit/action/start_domain_spec.rb
|
192
|
+
- spec/unit/action/start_domain_spec/default.xml
|
187
193
|
- spec/unit/action/wait_till_up_spec.rb
|
188
194
|
- spec/unit/config_spec.rb
|
189
195
|
- spec/unit/templates/domain_all_settings.xml
|
@@ -209,20 +215,24 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
215
|
- !ruby/object:Gem::Version
|
210
216
|
version: '0'
|
211
217
|
requirements: []
|
212
|
-
rubygems_version: 3.0.
|
218
|
+
rubygems_version: 3.0.8
|
213
219
|
signing_key:
|
214
220
|
specification_version: 4
|
215
221
|
summary: libvirt provider for Vagrant.
|
216
222
|
test_files:
|
223
|
+
- spec/support/libvirt_context.rb
|
224
|
+
- spec/support/sharedcontext.rb
|
225
|
+
- spec/support/environment_helper.rb
|
226
|
+
- spec/unit/templates/domain_all_settings.xml
|
227
|
+
- spec/unit/templates/domain_custom_cpu_model.xml
|
228
|
+
- spec/unit/templates/domain_defaults.xml
|
229
|
+
- spec/unit/templates/domain_spec.rb
|
230
|
+
- spec/unit/action/create_domain_spec/default_storage_pool.xml
|
231
|
+
- spec/unit/action/create_domain_spec.rb
|
217
232
|
- spec/unit/action/wait_till_up_spec.rb
|
218
233
|
- spec/unit/action/destroy_domain_spec.rb
|
234
|
+
- spec/unit/action/start_domain_spec.rb
|
219
235
|
- spec/unit/action/set_name_of_domain_spec.rb
|
236
|
+
- spec/unit/action/start_domain_spec/default.xml
|
220
237
|
- spec/unit/config_spec.rb
|
221
|
-
- spec/unit/templates/domain_defaults.xml
|
222
|
-
- spec/unit/templates/domain_all_settings.xml
|
223
|
-
- spec/unit/templates/domain_spec.rb
|
224
|
-
- spec/unit/templates/domain_custom_cpu_model.xml
|
225
|
-
- spec/support/libvirt_context.rb
|
226
|
-
- spec/support/environment_helper.rb
|
227
|
-
- spec/support/sharedcontext.rb
|
228
238
|
- spec/spec_helper.rb
|