vagrant-libvirt 0.5.3 → 0.6.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 +110 -18
- data/lib/vagrant-libvirt/action/clean_machine_folder.rb +2 -0
- data/lib/vagrant-libvirt/action/create_domain.rb +8 -1
- data/lib/vagrant-libvirt/action/create_domain_volume.rb +5 -0
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +8 -2
- data/lib/vagrant-libvirt/action/create_networks.rb +12 -8
- data/lib/vagrant-libvirt/action/destroy_domain.rb +2 -0
- data/lib/vagrant-libvirt/action/destroy_networks.rb +2 -0
- data/lib/vagrant-libvirt/action/forward_ports.rb +7 -5
- data/lib/vagrant-libvirt/action/halt_domain.rb +4 -34
- data/lib/vagrant-libvirt/action/handle_box_image.rb +3 -3
- data/lib/vagrant-libvirt/action/handle_storage_pool.rb +7 -1
- data/lib/vagrant-libvirt/action/is_created.rb +2 -0
- data/lib/vagrant-libvirt/action/is_running.rb +2 -0
- data/lib/vagrant-libvirt/action/is_suspended.rb +2 -0
- data/lib/vagrant-libvirt/action/message_already_created.rb +2 -0
- data/lib/vagrant-libvirt/action/message_not_created.rb +2 -0
- data/lib/vagrant-libvirt/action/message_not_running.rb +2 -0
- data/lib/vagrant-libvirt/action/message_not_suspended.rb +2 -0
- data/lib/vagrant-libvirt/action/message_will_not_destroy.rb +2 -0
- data/lib/vagrant-libvirt/action/package_domain.rb +133 -68
- data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +2 -0
- data/lib/vagrant-libvirt/action/prepare_nfs_valid_ids.rb +2 -0
- data/lib/vagrant-libvirt/action/prune_nfs_exports.rb +2 -0
- data/lib/vagrant-libvirt/action/read_mac_addresses.rb +2 -0
- data/lib/vagrant-libvirt/action/remove_libvirt_image.rb +2 -0
- data/lib/vagrant-libvirt/action/remove_stale_volume.rb +2 -0
- data/lib/vagrant-libvirt/action/resume_domain.rb +2 -0
- data/lib/vagrant-libvirt/action/set_boot_order.rb +2 -0
- data/lib/vagrant-libvirt/action/set_name_of_domain.rb +3 -1
- data/lib/vagrant-libvirt/action/share_folders.rb +2 -0
- data/lib/vagrant-libvirt/action/shutdown_domain.rb +49 -0
- data/lib/vagrant-libvirt/action/start_domain.rb +26 -17
- data/lib/vagrant-libvirt/action/suspend_domain.rb +2 -0
- data/lib/vagrant-libvirt/action/wait_till_up.rb +2 -0
- data/lib/vagrant-libvirt/action.rb +34 -4
- data/lib/vagrant-libvirt/cap/mount_9p.rb +2 -0
- data/lib/vagrant-libvirt/cap/mount_virtiofs.rb +2 -0
- data/lib/vagrant-libvirt/cap/nic_mac_addresses.rb +2 -0
- data/lib/vagrant-libvirt/cap/public_address.rb +2 -0
- data/lib/vagrant-libvirt/cap/synced_folder_9p.rb +5 -2
- data/lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb +5 -2
- data/lib/vagrant-libvirt/config.rb +49 -25
- data/lib/vagrant-libvirt/driver.rb +67 -12
- data/lib/vagrant-libvirt/errors.rb +2 -0
- data/lib/vagrant-libvirt/plugin.rb +2 -0
- data/lib/vagrant-libvirt/provider.rb +2 -0
- data/lib/vagrant-libvirt/templates/domain.xml.erb +4 -2
- data/lib/vagrant-libvirt/templates/public_interface.xml.erb +1 -0
- data/lib/vagrant-libvirt/util/collection.rb +2 -0
- data/lib/vagrant-libvirt/util/erb_template.rb +2 -0
- data/lib/vagrant-libvirt/util/error_codes.rb +2 -0
- data/lib/vagrant-libvirt/util/network_util.rb +3 -0
- data/lib/vagrant-libvirt/util/nfs.rb +2 -0
- data/lib/vagrant-libvirt/util/storage_util.rb +1 -0
- data/lib/vagrant-libvirt/util/timer.rb +2 -0
- data/lib/vagrant-libvirt/util/ui.rb +1 -0
- data/lib/vagrant-libvirt/util.rb +2 -0
- data/lib/vagrant-libvirt/version +1 -1
- data/lib/vagrant-libvirt/version.rb +2 -0
- data/lib/vagrant-libvirt.rb +2 -0
- data/locales/en.yml +2 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/binding_proc.rb +2 -0
- data/spec/support/environment_helper.rb +2 -0
- data/spec/support/libvirt_context.rb +2 -0
- data/spec/support/matchers/have_file_content.rb +2 -0
- data/spec/support/sharedcontext.rb +3 -0
- data/spec/support/temporary_dir.rb +12 -0
- data/spec/unit/action/clean_machine_folder_spec.rb +2 -0
- data/spec/unit/action/create_domain_spec/additional_disks_domain.xml +7 -0
- data/spec/unit/action/create_domain_spec/default_domain.xml +6 -0
- data/spec/unit/action/create_domain_spec.rb +62 -30
- data/spec/unit/action/create_domain_volume_spec.rb +4 -0
- data/spec/unit/action/destroy_domain_spec.rb +8 -2
- data/spec/unit/action/forward_ports_spec.rb +2 -0
- data/spec/unit/action/halt_domain_spec.rb +30 -57
- data/spec/unit/action/handle_box_image_spec.rb +6 -4
- data/spec/unit/action/package_domain_spec.rb +304 -0
- data/spec/unit/action/set_name_of_domain_spec.rb +2 -0
- data/spec/unit/action/shutdown_domain_spec.rb +131 -0
- data/spec/unit/action/start_domain_spec/existing.xml +62 -0
- data/spec/unit/action/start_domain_spec.rb +18 -28
- data/spec/unit/action/wait_till_up_spec.rb +2 -0
- data/spec/unit/action_spec.rb +96 -0
- data/spec/unit/config_spec.rb +52 -2
- data/spec/unit/driver_spec.rb +155 -0
- data/spec/unit/templates/domain_all_settings.xml +4 -0
- data/spec/unit/templates/domain_spec.rb +2 -0
- data/spec/unit/util/byte_number_spec.rb +2 -0
- metadata +53 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e37a27120aef75fdd73d704321b96c7c881b07fa3cbdd655855300bf11163a3
|
4
|
+
data.tar.gz: 4639827cc360b3f06304310f02dffea445f19d2f4b8675a6e0e05a9be3cea307
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb13d39445a95f3514cc1be73bcf6e81ec7924959ec86e6cc712c50050ac8211f6b5beb26bbd42c137020e98143794d7b67aa7241e2461cdf2d1ca5ed2a15c30
|
7
|
+
data.tar.gz: b341135cabad7d59963df62e9dd921470a43e4794fb203ff78b893bd058a38af877717f48b25a72135211e72d82082ec444227b97157e365903103240dfb1311
|
data/README.md
CHANGED
@@ -18,7 +18,10 @@ can help a lot :-)
|
|
18
18
|
|
19
19
|
* [Features](#features)
|
20
20
|
* [Future work](#future-work)
|
21
|
-
* [Using
|
21
|
+
* [Using the container image](#using-the-container-image)
|
22
|
+
* [Using Docker](#using-docker)
|
23
|
+
* [Using Podman](#using-podman)
|
24
|
+
* [Extending the Docker image with additional vagrant plugins](#extending-the-docker-image-with-additional-vagrant-plugins)
|
22
25
|
* [Installation](#installation)
|
23
26
|
* [Possible problems with plugin installation on Linux](#possible-problems-with-plugin-installation-on-linux)
|
24
27
|
* [Additional Notes for Fedora and Similar Linux Distributions](#additional-notes-for-fedora-and-similar-linux-distributions)
|
@@ -99,7 +102,7 @@ can help a lot :-)
|
|
99
102
|
* Take a look at [open
|
100
103
|
issues](https://github.com/vagrant-libvirt/vagrant-libvirt/issues?state=open).
|
101
104
|
|
102
|
-
## Using
|
105
|
+
## Using the container image
|
103
106
|
|
104
107
|
Due to the number of issues encountered around compatibility between the ruby runtime environment
|
105
108
|
that is part of the upstream vagrant installation and the library dependencies of libvirt that
|
@@ -109,11 +112,31 @@ This should allow users to execute vagrant with vagrant-libvirt without needing
|
|
109
112
|
the compatibility issues, though you may need to extend the image for your own needs should
|
110
113
|
you make use of additional plugins.
|
111
114
|
|
112
|
-
|
115
|
+
Note the default image contains the full toolchain required to build and install vagrant-libvirt
|
116
|
+
and it's dependencies. There is also a smaller image published with the `-slim` suffix if you
|
117
|
+
just need vagrant-libvirt and don't need to install any additional plugins for your environment.
|
118
|
+
|
119
|
+
If you are connecting to a remote system libvirt, you may omit the
|
120
|
+
`-v /var/run/libvirt/:/var/run/libvirt/` mount bind. Some distributions patch the local
|
121
|
+
vagrant environment to ensure vagrant-libvirt uses `qemu:///session`, which means you
|
122
|
+
may need to set the environment variable `LIBVIRT_DEFAULT_URI` to the same value if
|
123
|
+
looking to use this in place of your distribution provided installation.
|
124
|
+
|
125
|
+
### Using Docker
|
126
|
+
|
127
|
+
To get the image with the most recent release:
|
113
128
|
```bash
|
114
129
|
docker pull vagrantlibvirt/vagrant-libvirt:latest
|
115
130
|
```
|
116
131
|
|
132
|
+
---
|
133
|
+
**Note** If you want the very latest code you can use the `edge` tag instead.
|
134
|
+
|
135
|
+
```bash
|
136
|
+
docker pull vagrantlibvirt/vagrant-libvirt:edge
|
137
|
+
```
|
138
|
+
---
|
139
|
+
|
117
140
|
Preparing the docker run, only once:
|
118
141
|
|
119
142
|
```bash
|
@@ -126,33 +149,73 @@ docker run -it --rm \
|
|
126
149
|
-e LIBVIRT_DEFAULT_URI \
|
127
150
|
-v /var/run/libvirt/:/var/run/libvirt/ \
|
128
151
|
-v ~/.vagrant.d:/.vagrant.d \
|
129
|
-
-v $(
|
130
|
-
-w $(
|
152
|
+
-v $(realpath "${PWD}"):${PWD} \
|
153
|
+
-w $(realpath "${PWD}") \
|
131
154
|
--network host \
|
132
155
|
vagrantlibvirt/vagrant-libvirt:latest \
|
133
156
|
vagrant status
|
134
157
|
```
|
135
158
|
|
136
|
-
It's possible to define
|
159
|
+
It's possible to define a function in `~/.bashrc`, for example:
|
137
160
|
```bash
|
138
|
-
|
139
|
-
mkdir -p ~/.vagrant.d/{boxes,data,tmp}; \
|
161
|
+
vagrant(){
|
140
162
|
docker run -it --rm \
|
141
163
|
-e LIBVIRT_DEFAULT_URI \
|
142
164
|
-v /var/run/libvirt/:/var/run/libvirt/ \
|
143
165
|
-v ~/.vagrant.d:/.vagrant.d \
|
144
|
-
-v $(
|
145
|
-
-w $(
|
166
|
+
-v $(realpath "${PWD}"):${PWD} \
|
167
|
+
-w $(realpath "${PWD}") \
|
146
168
|
--network host \
|
147
169
|
vagrantlibvirt/vagrant-libvirt:latest \
|
148
|
-
|
170
|
+
vagrant $@
|
171
|
+
}
|
172
|
+
|
149
173
|
```
|
150
174
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
175
|
+
### Using Podman
|
176
|
+
To run with Podman you need to include
|
177
|
+
|
178
|
+
```bash
|
179
|
+
--entrypoint /bin/bash \
|
180
|
+
--security-opt label=disable \
|
181
|
+
-v ~/.vagrant.d/boxes:/vagrant/boxes \
|
182
|
+
-v ~/.vagrant.d/data:/vagrant/data \
|
183
|
+
```
|
184
|
+
|
185
|
+
for example:
|
186
|
+
|
187
|
+
```bash
|
188
|
+
vagrant(){
|
189
|
+
podman run -it --rm \
|
190
|
+
-e LIBVIRT_DEFAULT_URI \
|
191
|
+
-v /var/run/libvirt/:/var/run/libvirt/ \
|
192
|
+
-v ~/.vagrant.d/boxes:/vagrant/boxes \
|
193
|
+
-v ~/.vagrant.d/data:/vagrant/data \
|
194
|
+
-v $(realpath "${PWD}"):${PWD} \
|
195
|
+
-w $(realpath "${PWD}") \
|
196
|
+
--network host \
|
197
|
+
--entrypoint /bin/bash \
|
198
|
+
--security-opt label=disable \
|
199
|
+
docker.io/vagrantlibvirt/vagrant-libvirt:latest \
|
200
|
+
vagrant $@
|
201
|
+
}
|
202
|
+
```
|
203
|
+
|
204
|
+
Running Podman in rootless mode maps the root user inside the container to your host user so we need to bypass [entrypoint.sh](https://github.com/vagrant-libvirt/vagrant-libvirt/blob/master/entrypoint.sh) and mount persistent storage directly to `/vagrant`.
|
205
|
+
|
206
|
+
### Extending the Docker image with additional vagrant plugins
|
207
|
+
|
208
|
+
By default the image published and used contains the entire tool chain required
|
209
|
+
to reinstall the vagrant-libvirt plugin and it's dependencies, as this is the
|
210
|
+
default behaviour of vagrant anytime a new plugin is installed. This means it
|
211
|
+
should be possible to use a simple `FROM` statement and ask vagrant to install
|
212
|
+
additional plugins.
|
213
|
+
|
214
|
+
```
|
215
|
+
FROM vagrantlibvirt/vagrant-libvirt:latest
|
216
|
+
|
217
|
+
RUN vagrant plugin install <plugin>
|
218
|
+
```
|
156
219
|
|
157
220
|
## Installation
|
158
221
|
|
@@ -907,6 +970,23 @@ DHCP server. dnsmasq writes lease information in the `/var/lib/libvirt/dnsmasq`
|
|
907
970
|
directory. Vagrant-libvirt looks for the MAC address in this file and extracts
|
908
971
|
the corresponding IP address.
|
909
972
|
|
973
|
+
It is also possible to use the Qemu Agent to extract the management interface
|
974
|
+
configuration from the booted virtual machine. This is helpful in libvirt
|
975
|
+
environments where no local dnsmasq is used for automatic address assigment,
|
976
|
+
but external dhcp services via bridged libvirt networks.
|
977
|
+
|
978
|
+
Prerequisite is to enable the qemu agent channel via ([Libvirt communication
|
979
|
+
channels](#libvirt-communication-channels)) and the virtual machine image must
|
980
|
+
have the agent pre-installed before deploy. The agent will start automatically
|
981
|
+
if it detects an attached channel during boot.
|
982
|
+
|
983
|
+
* `qemu_use_agent` - false by default, if set to true, attempt to extract configured
|
984
|
+
ip address via qemu agent.
|
985
|
+
|
986
|
+
To use the management network interface with an external dhcp service you need
|
987
|
+
to setup a bridged host network manually and define it via
|
988
|
+
`management_network_name` in your Vagrantfile.
|
989
|
+
|
910
990
|
## Additional Disks
|
911
991
|
|
912
992
|
You can create and attach additional disks to a VM via `libvirt.storage :file`.
|
@@ -1068,13 +1148,14 @@ The USB controller can be configured using `libvirt.usb_controller`, with the fo
|
|
1068
1148
|
Vagrant.configure("2") do |config|
|
1069
1149
|
config.vm.provider :libvirt do |libvirt|
|
1070
1150
|
# Set up a USB3 controller
|
1071
|
-
libvirt.usb_controller :model => "
|
1151
|
+
libvirt.usb_controller :model => "qemu-xhci"
|
1072
1152
|
end
|
1073
1153
|
end
|
1074
1154
|
```
|
1075
1155
|
|
1076
1156
|
See the [libvirt documentation](https://libvirt.org/formatdomain.html#elementsControllers) for a list of valid models.
|
1077
1157
|
|
1158
|
+
If any USB devices are passed through by setting `libvirt.usb` or `libvirt.redirdev`, a default controller will be added using the model `qemu-xhci` in the absence of a user specified one. This should help ensure more devices work out of the box as the default configured by libvirt is pii3-uhci, which appears to only work for USB 1 devices and does not work as expected when connected via a USB 2 controller, while the xhci stack should work for all versions of USB.
|
1078
1159
|
|
1079
1160
|
### USB Device Passthrough
|
1080
1161
|
|
@@ -1095,6 +1176,17 @@ The example values above match the device from the following output of `lsusb`:
|
|
1095
1176
|
Bus 001 Device 002: ID 1234:abcd Example device
|
1096
1177
|
```
|
1097
1178
|
|
1179
|
+
```ruby
|
1180
|
+
Vagrant.configure("2") do |config|
|
1181
|
+
config.vm.provider :libvirt do |libvirt|
|
1182
|
+
# pass through specific device based on identifying it
|
1183
|
+
libvirt.usbdev :vendor => '0x1234', :product => '0xabcd'
|
1184
|
+
# pass through a host device where multiple of the same vendor/product exist
|
1185
|
+
libvirt.usbdev :bus => '1', :device => '1'
|
1186
|
+
end
|
1187
|
+
end
|
1188
|
+
```
|
1189
|
+
|
1098
1190
|
Additionally, the following options can be used:
|
1099
1191
|
|
1100
1192
|
* `startupPolicy` - Is passed through to Libvirt and controls if the device has
|
@@ -1151,7 +1243,7 @@ In this case, the USB device with `class 0x0b`, `vendor 0x08e6`, `product 0x3437
|
|
1151
1243
|
Vagrant.configure("2") do |config|
|
1152
1244
|
config.vm.provider :libvirt do |libvirt|
|
1153
1245
|
libvirt.redirdev :type => "spicevmc"
|
1154
|
-
libvirt.redirfilter :class => "0x0b" :vendor => "0x08e6" :product => "0x3437" :version => "2.00" :allow => "yes"
|
1246
|
+
libvirt.redirfilter :class => "0x0b", :vendor => "0x08e6", :product => "0x3437", :version => "2.00", :allow => "yes"
|
1155
1247
|
libvirt.redirfilter :allow => "no"
|
1156
1248
|
end
|
1157
1249
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'log4r'
|
2
4
|
|
3
5
|
module VagrantPlugins
|
@@ -398,9 +400,14 @@ module VagrantPlugins
|
|
398
400
|
# Create Libvirt domain.
|
399
401
|
# Is there a way to tell fog to create new domain with already
|
400
402
|
# existing volume? Use domain creation from template..
|
403
|
+
xml = to_xml('domain')
|
404
|
+
@logger.debug {
|
405
|
+
"Creating Domain with XML:\n#{xml}"
|
406
|
+
}
|
407
|
+
|
401
408
|
begin
|
402
409
|
server = env[:machine].provider.driver.connection.servers.create(
|
403
|
-
xml:
|
410
|
+
xml: xml
|
404
411
|
)
|
405
412
|
rescue Fog::Errors::Error => e
|
406
413
|
raise Errors::FogCreateServerError, error_message: e.message
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'log4r'
|
2
4
|
|
3
5
|
module VagrantPlugins
|
@@ -76,6 +78,9 @@ module VagrantPlugins
|
|
76
78
|
else
|
77
79
|
pool_name = config.storage_pool_name
|
78
80
|
end
|
81
|
+
@logger.debug {
|
82
|
+
"Creating Volume with XML:\n#{xml}"
|
83
|
+
}
|
79
84
|
@logger.debug "Using pool #{pool_name} for base box snapshot"
|
80
85
|
domain_volume = env[:machine].provider.driver.connection.volumes.create(
|
81
86
|
xml: xml,
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'log4r'
|
2
4
|
require 'vagrant/util/network_ip'
|
3
5
|
require 'vagrant/util/scoped_hash_override'
|
@@ -128,10 +130,10 @@ module VagrantPlugins
|
|
128
130
|
end
|
129
131
|
|
130
132
|
message = "Creating network interface eth#{@iface_number}"
|
131
|
-
message
|
133
|
+
message += " connected to network #{@network_name}."
|
132
134
|
if @mac
|
133
135
|
@mac = @mac.scan(/(\h{2})/).join(':')
|
134
|
-
message
|
136
|
+
message += " Using MAC address: #{@mac}"
|
135
137
|
end
|
136
138
|
@logger.info(message)
|
137
139
|
|
@@ -157,6 +159,9 @@ module VagrantPlugins
|
|
157
159
|
else
|
158
160
|
to_xml(template_name)
|
159
161
|
end
|
162
|
+
@logger.debug {
|
163
|
+
"Attaching Network Device with XML:\n#{xml}"
|
164
|
+
}
|
160
165
|
domain.attach_device(xml)
|
161
166
|
rescue => e
|
162
167
|
raise Errors::AttachDeviceError,
|
@@ -246,6 +251,7 @@ module VagrantPlugins
|
|
246
251
|
udp_tunnel={}, pci_bus, pci_slot)
|
247
252
|
Nokogiri::XML::Builder.new do |xml|
|
248
253
|
xml.interface(type: type || 'network') do
|
254
|
+
xml.alias(name: "ua-net-#{iface_number}")
|
249
255
|
xml.source(source_options) do
|
250
256
|
xml.local(udp_tunnel) if type == 'udp'
|
251
257
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'log4r'
|
2
4
|
require 'vagrant/util/network_ip'
|
3
5
|
require 'vagrant/util/scoped_hash_override'
|
@@ -160,7 +162,7 @@ module VagrantPlugins
|
|
160
162
|
if @interface_network[:created]
|
161
163
|
# Just check for mismatch error here - if name and ip from
|
162
164
|
# config match together.
|
163
|
-
if @options[:network_name] != @interface_network[:name]
|
165
|
+
if @options[:network_name] != @interface_network[:name] and @qemu_use_agent == false
|
164
166
|
raise Errors::NetworkNameAndAddressMismatch,
|
165
167
|
ip_address: @options[:ip],
|
166
168
|
network_name: @options[:network_name]
|
@@ -312,8 +314,7 @@ module VagrantPlugins
|
|
312
314
|
|
313
315
|
if @options[:dhcp_enabled]
|
314
316
|
# Find out DHCP addresses pool range.
|
315
|
-
network_address = "#{@interface_network[:network_address]}
|
316
|
-
network_address << (@interface_network[:netmask]).to_s
|
317
|
+
network_address = "#{@interface_network[:network_address]}/#{(@interface_network[:netmask]).to_s}"
|
317
318
|
net = @interface_network[:network_address] ? IPAddr.new(network_address) : nil
|
318
319
|
|
319
320
|
# First is address of network, second is gateway (by default).
|
@@ -336,8 +337,12 @@ module VagrantPlugins
|
|
336
337
|
@network_domain_name = @options[:domain_name]
|
337
338
|
|
338
339
|
begin
|
340
|
+
xml = to_xml('private_network')
|
341
|
+
@logger.debug {
|
342
|
+
"Creating private network with XML:\n#{xml}"
|
343
|
+
}
|
339
344
|
@interface_network[:libvirt_network] = \
|
340
|
-
@libvirt_client.define_network_xml(
|
345
|
+
@libvirt_client.define_network_xml(xml)
|
341
346
|
@logger.debug 'created network'
|
342
347
|
rescue => e
|
343
348
|
raise Errors::CreateNetworkError, error_message: e.message
|
@@ -345,10 +350,9 @@ module VagrantPlugins
|
|
345
350
|
|
346
351
|
created_networks_file = env[:machine].data_dir + 'created_networks'
|
347
352
|
|
348
|
-
message = 'Saving information about created network '
|
349
|
-
|
350
|
-
|
351
|
-
message << "to file #{created_networks_file}."
|
353
|
+
message = 'Saving information about created network ' \
|
354
|
+
"#{@interface_network[:name]}, UUID=#{@interface_network[:libvirt_network].uuid} " \
|
355
|
+
"to file #{created_networks_file}."
|
352
356
|
@logger.info(message)
|
353
357
|
|
354
358
|
File.open(created_networks_file, 'a') do |file|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module ProviderLibvirt
|
3
5
|
module Action
|
@@ -104,7 +106,7 @@ module VagrantPlugins
|
|
104
106
|
IdentitiesOnly=#{ssh_info[:keys_only] ? 'yes' : 'no'}
|
105
107
|
) + ssh_info[:private_key_path].map do |pk|
|
106
108
|
"IdentityFile='\"#{pk}\"'"
|
107
|
-
end).map { |s|
|
109
|
+
end).map { |s| "-o #{s}" }.join(' ')
|
108
110
|
|
109
111
|
options += " -o ProxyCommand=\"#{ssh_info[:proxy_command]}\"" if machine.provider_config.proxy_command
|
110
112
|
|
@@ -116,12 +118,12 @@ module VagrantPlugins
|
|
116
118
|
env[:ui].info 'Requesting sudo for host port(s) <= 1024'
|
117
119
|
r = system('sudo -v')
|
118
120
|
if r
|
119
|
-
ssh_cmd
|
121
|
+
ssh_cmd += 'sudo ' # add sudo prefix
|
120
122
|
end
|
121
123
|
end
|
122
124
|
end
|
123
125
|
|
124
|
-
ssh_cmd
|
126
|
+
ssh_cmd += "ssh -n #{options} #{params}"
|
125
127
|
|
126
128
|
@logger.debug "Forwarding port with `#{ssh_cmd}`"
|
127
129
|
log_file = ssh_forward_log_file(
|
@@ -180,10 +182,10 @@ module VagrantPlugins
|
|
180
182
|
kill_cmd = ''
|
181
183
|
|
182
184
|
if tag[:port] <= 1024
|
183
|
-
kill_cmd
|
185
|
+
kill_cmd += 'sudo ' # add sudo prefix
|
184
186
|
end
|
185
187
|
|
186
|
-
kill_cmd
|
188
|
+
kill_cmd += "kill #{tag[:pid]}"
|
187
189
|
@@lock.synchronize do
|
188
190
|
system(kill_cmd)
|
189
191
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'log4r'
|
2
4
|
|
3
5
|
module VagrantPlugins
|
@@ -11,41 +13,9 @@ module VagrantPlugins
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def call(env)
|
14
|
-
env[:ui].info(I18n.t('vagrant_libvirt.halt_domain'))
|
15
|
-
|
16
|
-
timeout = env[:machine].config.vm.graceful_halt_timeout
|
17
16
|
domain = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s)
|
18
|
-
|
19
|
-
|
20
|
-
if env[:force_halt]
|
21
|
-
domain.poweroff
|
22
|
-
return @app.call(env)
|
23
|
-
end
|
24
|
-
|
25
|
-
begin
|
26
|
-
Timeout.timeout(timeout) do
|
27
|
-
begin
|
28
|
-
env[:machine].guest.capability(:halt)
|
29
|
-
rescue Timeout::Error
|
30
|
-
raise
|
31
|
-
rescue
|
32
|
-
@logger.info('Trying Libvirt graceful shutdown.')
|
33
|
-
# Read domain object again
|
34
|
-
dom = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s)
|
35
|
-
if dom.state.to_s == 'running'
|
36
|
-
dom.shutdown
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
domain.wait_for(timeout) do
|
41
|
-
!ready?
|
42
|
-
end
|
43
|
-
end
|
44
|
-
rescue Timeout::Error
|
45
|
-
@logger.info('VM is still running. Calling force poweroff.')
|
46
|
-
domain.poweroff
|
47
|
-
rescue
|
48
|
-
@logger.error('Failed to shutdown cleanly. Calling force poweroff.')
|
17
|
+
if env[:machine].state.id == :running
|
18
|
+
env[:ui].info(I18n.t('vagrant_libvirt.halt_domain'))
|
49
19
|
domain.poweroff
|
50
20
|
end
|
51
21
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'log4r'
|
2
4
|
require 'open3'
|
3
5
|
require 'json'
|
@@ -85,7 +87,6 @@ module VagrantPlugins
|
|
85
87
|
box_virtual_size = env[:box_volumes][0][:virtual_size]
|
86
88
|
if config.machine_virtual_size
|
87
89
|
config_machine_virtual_size = ByteNumber.from_GB(config.machine_virtual_size)
|
88
|
-
puts config_machine_virtual_size < box_virtual_size
|
89
90
|
if config_machine_virtual_size < box_virtual_size
|
90
91
|
# Warn that a virtual size less than the box metadata size
|
91
92
|
# is not supported and will be ignored
|
@@ -180,8 +181,7 @@ module VagrantPlugins
|
|
180
181
|
raise Vagrant::Errors::BoxNotFound, name: env[:machine].box.name
|
181
182
|
end
|
182
183
|
box_image_size = File.size(box_image_file) # B
|
183
|
-
message = "Creating volume #{box_volume[:name]}"
|
184
|
-
message << " in storage pool #{config.storage_pool_name}."
|
184
|
+
message = "Creating volume #{box_volume[:name]} in storage pool #{config.storage_pool_name}."
|
185
185
|
@logger.info(message)
|
186
186
|
begin
|
187
187
|
fog_volume = env[:machine].provider.driver.connection.volumes.create(
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'log4r'
|
2
4
|
|
3
5
|
module VagrantPlugins
|
@@ -42,8 +44,12 @@ module VagrantPlugins
|
|
42
44
|
@storage_pool_path = storage_pool_path(env)
|
43
45
|
@storage_pool_uid = storage_uid(env)
|
44
46
|
@storage_pool_gid = storage_gid(env)
|
47
|
+
xml = to_xml('default_storage_pool')
|
48
|
+
@logger.debug {
|
49
|
+
"Creating Storage Pool with XML:\n#{xml}"
|
50
|
+
}
|
45
51
|
libvirt_pool = env[:machine].provider.driver.connection.client.define_storage_pool_xml(
|
46
|
-
|
52
|
+
xml
|
47
53
|
)
|
48
54
|
libvirt_pool.build
|
49
55
|
libvirt_pool.create
|