vagrant-libvirt 0.4.0 → 0.5.3
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 +251 -33
- data/lib/vagrant-libvirt/action.rb +7 -1
- data/lib/vagrant-libvirt/action/clean_machine_folder.rb +30 -0
- data/lib/vagrant-libvirt/action/create_domain.rb +28 -11
- data/lib/vagrant-libvirt/action/create_domain_volume.rb +57 -55
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +0 -3
- data/lib/vagrant-libvirt/action/create_networks.rb +11 -4
- data/lib/vagrant-libvirt/action/destroy_domain.rb +1 -1
- data/lib/vagrant-libvirt/action/forward_ports.rb +36 -37
- data/lib/vagrant-libvirt/action/halt_domain.rb +25 -9
- data/lib/vagrant-libvirt/action/handle_box_image.rb +170 -77
- data/lib/vagrant-libvirt/action/is_running.rb +1 -3
- data/lib/vagrant-libvirt/action/is_suspended.rb +4 -4
- data/lib/vagrant-libvirt/action/set_boot_order.rb +6 -2
- data/lib/vagrant-libvirt/action/wait_till_up.rb +1 -25
- data/lib/vagrant-libvirt/cap/{mount_p9.rb → mount_9p.rb} +2 -2
- data/lib/vagrant-libvirt/cap/mount_virtiofs.rb +37 -0
- data/lib/vagrant-libvirt/cap/{synced_folder.rb → synced_folder_9p.rb} +4 -5
- data/lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb +109 -0
- data/lib/vagrant-libvirt/config.rb +34 -2
- data/lib/vagrant-libvirt/driver.rb +3 -1
- data/lib/vagrant-libvirt/errors.rb +24 -1
- data/lib/vagrant-libvirt/plugin.rb +14 -5
- data/lib/vagrant-libvirt/templates/domain.xml.erb +7 -6
- data/lib/vagrant-libvirt/templates/private_network.xml.erb +1 -1
- data/lib/vagrant-libvirt/util/byte_number.rb +71 -0
- data/lib/vagrant-libvirt/util/network_util.rb +21 -3
- data/lib/vagrant-libvirt/version +1 -1
- data/locales/en.yml +12 -0
- data/spec/spec_helper.rb +9 -1
- data/spec/support/binding_proc.rb +24 -0
- data/spec/support/matchers/have_file_content.rb +63 -0
- data/spec/unit/action/clean_machine_folder_spec.rb +58 -0
- data/spec/unit/action/create_domain_spec.rb +15 -5
- data/spec/unit/action/create_domain_spec/additional_disks_domain.xml +54 -0
- data/spec/unit/action/create_domain_spec/default_domain.xml +49 -0
- data/spec/unit/action/create_domain_volume_spec.rb +104 -0
- data/spec/unit/action/create_domain_volume_spec/one_disk_in_storage.xml +21 -0
- data/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_0.xml +21 -0
- data/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_1.xml +21 -0
- data/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_2.xml +21 -0
- data/spec/unit/action/destroy_domain_spec.rb +1 -1
- data/spec/unit/action/forward_ports_spec.rb +202 -0
- data/spec/unit/action/halt_domain_spec.rb +90 -0
- data/spec/unit/action/handle_box_image_spec.rb +441 -0
- data/spec/unit/action/wait_till_up_spec.rb +11 -15
- data/spec/unit/config_spec.rb +12 -9
- data/spec/unit/templates/domain_all_settings.xml +8 -0
- data/spec/unit/templates/domain_spec.rb +20 -1
- data/spec/unit/util/byte_number_spec.rb +26 -0
- metadata +52 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45b81bd9999cef0982201e37382c06ce3657bfe4442f060864c3f659ffc2ce37
|
4
|
+
data.tar.gz: e44c22486556883da8170f757cc8c3a29a4a98b07460c4b1098cb4aaed7566b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca1762baa21c39a9e047128f87cae3decedf38fee218bd741ebe0b40779d95bf306926a53c42038e3d4556f1484edb811868b3f612d37c574382afcf14516788
|
7
|
+
data.tar.gz: daabf0d91e896deb468a79ea287c52137991a04c9befabeab53e700dbbe580a17ba019da8b817a6e3a8148b81f5a26e86c112c2d0f05ba216595ea4c56a0dac6
|
data/README.md
CHANGED
@@ -55,6 +55,7 @@ can help a lot :-)
|
|
55
55
|
* [No box and PXE boot](#no-box-and-pxe-boot)
|
56
56
|
* [SSH Access To VM](#ssh-access-to-vm)
|
57
57
|
* [Forwarded Ports](#forwarded-ports)
|
58
|
+
* [Forwarding the ssh-port](#forwarding-the-ssh-port)
|
58
59
|
* [Synced Folders](#synced-folders)
|
59
60
|
* [QEMU Session Support](#qemu-session-support)
|
60
61
|
* [Customized Graphics](#customized-graphics)
|
@@ -62,7 +63,9 @@ can help a lot :-)
|
|
62
63
|
* [Memory balloon](#memory-balloon)
|
63
64
|
* [Libvirt communication channels](#libvirt-communication-channels)
|
64
65
|
* [Custom command line arguments and environment variables](#custom-command-line-arguments-and-environment-variables)
|
65
|
-
* [Box
|
66
|
+
* [Box Formats](#box-formats)
|
67
|
+
* [Version 1](#version-1)
|
68
|
+
* [Version 2 (Experimental)](#version-2-experimental)
|
66
69
|
* [Create Box](#create-box)
|
67
70
|
* [Package Box from VM](#package-box-from-vm)
|
68
71
|
* [Troubleshooting VMs](#troubleshooting-vms)
|
@@ -83,7 +86,7 @@ can help a lot :-)
|
|
83
86
|
* SSH into domains.
|
84
87
|
* Setup hostname and network interfaces.
|
85
88
|
* Provision domains with any built-in Vagrant provisioner.
|
86
|
-
* Synced folder support via `rsync`, `nfs` or `
|
89
|
+
* Synced folder support via `rsync`, `nfs`, `9p` or `virtiofs`.
|
87
90
|
* Snapshots via [sahara](https://github.com/jedi4ever/sahara).
|
88
91
|
* Package caching via
|
89
92
|
[vagrant-cachier](http://fgrehm.viewdocs.io/vagrant-cachier/).
|
@@ -180,6 +183,7 @@ vagrant-libvirt. This depends on your distro. An overview:
|
|
180
183
|
apt-get build-dep vagrant ruby-libvirt
|
181
184
|
apt-get install qemu libvirt-daemon-system libvirt-clients ebtables dnsmasq-base
|
182
185
|
apt-get install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev
|
186
|
+
apt-get install libguestfs-tools
|
183
187
|
```
|
184
188
|
|
185
189
|
* Ubuntu 18.04, Debian 8 and older:
|
@@ -187,23 +191,24 @@ apt-get install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev
|
|
187
191
|
apt-get build-dep vagrant ruby-libvirt
|
188
192
|
apt-get install qemu libvirt-bin ebtables dnsmasq-base
|
189
193
|
apt-get install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev
|
194
|
+
apt-get install libguestfs-tools
|
190
195
|
```
|
191
196
|
|
192
197
|
(It is possible some users will already have libraries from the third line installed, but this is the way to make it work OOTB.)
|
193
198
|
|
194
199
|
* CentOS 6, 7, Fedora 21:
|
195
200
|
```shell
|
196
|
-
yum install qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm
|
201
|
+
yum install qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm libguestfs-tools
|
197
202
|
```
|
198
203
|
|
199
204
|
* Fedora 22 and up:
|
200
205
|
```shell
|
201
|
-
dnf install -y gcc libvirt libvirt-devel libxml2-devel make ruby-devel
|
206
|
+
dnf install -y gcc libvirt libvirt-devel libxml2-devel make ruby-devel libguestfs-tools
|
202
207
|
```
|
203
208
|
|
204
209
|
* OpenSUSE leap 15.1:
|
205
210
|
```shell
|
206
|
-
zypper install qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm
|
211
|
+
zypper install qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm libguestfs
|
207
212
|
```
|
208
213
|
|
209
214
|
* Arch Linux: please read the related [ArchWiki](https://wiki.archlinux.org/index.php/Vagrant#vagrant-libvirt) page.
|
@@ -238,8 +243,7 @@ On Ubuntu, Debian, make sure you are running all three of the `apt` commands abo
|
|
238
243
|
On RedHat, Centos, Fedora, ...
|
239
244
|
|
240
245
|
```shell
|
241
|
-
$ sudo dnf install libxslt-devel libxml2-devel libvirt-devel
|
242
|
-
libguestfs-tools-c ruby-devel gcc
|
246
|
+
$ sudo dnf install libxslt-devel libxml2-devel libvirt-devel ruby-devel gcc
|
243
247
|
```
|
244
248
|
|
245
249
|
On Arch Linux it is recommended to follow [steps from ArchWiki](https://wiki.archlinux.org/index.php/Vagrant#vagrant-libvirt).
|
@@ -892,6 +896,8 @@ used by this network are configurable at the provider level.
|
|
892
896
|
* `management_network_pci_slot` - The slot of the PCI device.
|
893
897
|
* `management_network_mac` - MAC address of management network interface.
|
894
898
|
* `management_network_domain` - Domain name assigned to the management network.
|
899
|
+
* `management_network_mtu` - MTU size of management network. If not specified,
|
900
|
+
the Libvirt default (1500) will be used.
|
895
901
|
|
896
902
|
You may wonder how vagrant-libvirt knows the IP address a VM received. Libvirt
|
897
903
|
doesn't provide a standard way to find out the IP address of a running domain.
|
@@ -1256,6 +1262,8 @@ Vagrant.configure("2") do |config|
|
|
1256
1262
|
libvirt.hyperv_feature :name => 'relaxed', :state => 'on'
|
1257
1263
|
# Enable virtual APIC
|
1258
1264
|
libvirt.hyperv_feature :name => 'vapic', :state => 'on'
|
1265
|
+
# Enable spinlocks (requires retries to be specified)
|
1266
|
+
libvirt.hyperv_feature :name => 'spinlocks', :state => 'on', :retries => '8191'
|
1259
1267
|
end
|
1260
1268
|
end
|
1261
1269
|
```
|
@@ -1382,6 +1390,24 @@ Name of network "foreman_managed" is key for define boot order
|
|
1382
1390
|
end
|
1383
1391
|
```
|
1384
1392
|
|
1393
|
+
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:
|
1394
|
+
|
1395
|
+
```ruby
|
1396
|
+
Vagrant.configure("2") do |config|
|
1397
|
+
config.vm.define :pxeclient do |pxeclient|
|
1398
|
+
pxeclient.vm.network :public_network,
|
1399
|
+
dev: 'br1',
|
1400
|
+
auto_config: false
|
1401
|
+
pxeclient.vm.provider :libvirt do |domain|
|
1402
|
+
boot_network = {'dev' => 'br1'}
|
1403
|
+
domain.storage :file, :size => '100G'
|
1404
|
+
domain.boot boot_network
|
1405
|
+
domain.boot 'hd'
|
1406
|
+
end
|
1407
|
+
end
|
1408
|
+
end
|
1409
|
+
```
|
1410
|
+
|
1385
1411
|
## SSH Access To VM
|
1386
1412
|
|
1387
1413
|
vagrant-libvirt supports vagrant's [standard ssh
|
@@ -1412,40 +1438,157 @@ Default is `eth0`.
|
|
1412
1438
|
|
1413
1439
|
`config.vm.network :forwarded_port, guest: 80, host: 2000, host_ip: "0.0.0.0"`
|
1414
1440
|
|
1441
|
+
### Forwarding the ssh-port
|
1442
|
+
|
1443
|
+
Vagrant-libvirt now supports forwarding the standard ssh-port on port 2222 from
|
1444
|
+
the localhost to allow for consistent provisioning steps/ports to be used when
|
1445
|
+
defining across multiple providers.
|
1446
|
+
|
1447
|
+
To enable, set the following:
|
1448
|
+
```ruby
|
1449
|
+
Vagrant.configure("2") do |config|
|
1450
|
+
config.vm.provider :libvirt do |libvirt|
|
1451
|
+
# Enable forwarding of forwarded_port with id 'ssh'.
|
1452
|
+
libvirt.forward_ssh_port = true
|
1453
|
+
end
|
1454
|
+
end
|
1455
|
+
```
|
1456
|
+
|
1457
|
+
Previously by default libvirt skipped the forwarding of the ssh-port because
|
1458
|
+
you can access the machine directly. In the future it is expected that this
|
1459
|
+
will be enabled by default once autocorrect support is added to handle port
|
1460
|
+
collisions for multi machine environments gracefully.
|
1461
|
+
|
1415
1462
|
## Synced Folders
|
1416
1463
|
|
1417
|
-
Vagrant automatically syncs the project folder on the host to `/vagrant` in
|
1418
|
-
additional synced folders.
|
1464
|
+
Vagrant automatically syncs the project folder on the host to `/vagrant` in
|
1465
|
+
the guest. You can also configure additional synced folders.
|
1419
1466
|
|
1420
|
-
|
1421
|
-
|
1467
|
+
**SECURITY NOTE:** for remote Libvirt, nfs synced folders requires a bridged
|
1468
|
+
public network interface and you must connect to Libvirt via ssh.
|
1422
1469
|
|
1423
|
-
|
1424
|
-
it an setting the type, e.g.
|
1470
|
+
**NFS**
|
1425
1471
|
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1472
|
+
`vagrant-libvirt` supports
|
1473
|
+
[NFS](https://www.vagrantup.com/docs/synced-folders/nfs) as default with
|
1474
|
+
bidirectional synced folders.
|
1429
1475
|
|
1430
|
-
|
1476
|
+
Example with NFS:
|
1431
1477
|
|
1432
|
-
```
|
1433
|
-
|
1478
|
+
``` ruby
|
1479
|
+
Vagrant.configure("2") do |config|
|
1480
|
+
config.vm.synced_folder "./", "/vagrant"
|
1481
|
+
end
|
1434
1482
|
```
|
1435
1483
|
|
1436
|
-
|
1484
|
+
**RSync**
|
1437
1485
|
|
1438
|
-
|
1439
|
-
|
1486
|
+
`vagrant-libvirt` supports
|
1487
|
+
[rsync](https://www.vagrantup.com/docs/synced-folders/rsync) with
|
1488
|
+
unidirectional synced folders.
|
1489
|
+
|
1490
|
+
Example with rsync:
|
1491
|
+
|
1492
|
+
``` ruby
|
1493
|
+
Vagrant.configure("2") do |config|
|
1494
|
+
config.vm.synced_folder "./", "/vagrant", type: "rsync"
|
1495
|
+
end
|
1440
1496
|
```
|
1441
1497
|
|
1498
|
+
**9P**
|
1499
|
+
|
1500
|
+
`vagrant-libvirt` supports [VirtFS](http://www.linux-kvm.org/page/VirtFS) ([9p
|
1501
|
+
or Plan 9](https://en.wikipedia.org/wiki/9P_\(protocol\))) with bidirectional
|
1502
|
+
synced folders.
|
1503
|
+
|
1504
|
+
Difference between NFS and 9p is explained
|
1505
|
+
[here](https://unix.stackexchange.com/questions/240281/virtfs-plan-9-vs-nfs-as-tool-for-share-folder-for-virtual-machine).
|
1506
|
+
|
1442
1507
|
For 9p shares, a `mount: false` option allows to define synced folders without
|
1443
1508
|
mounting them at boot.
|
1444
1509
|
|
1445
|
-
|
1510
|
+
Example for `accessmode: "squash"` with 9p:
|
1446
1511
|
|
1447
|
-
|
1448
|
-
|
1512
|
+
``` ruby
|
1513
|
+
Vagrant.configure("2") do |config|
|
1514
|
+
config.vm.synced_folder "./", "/vagrant", type: "9p", disabled: false, accessmode: "squash", owner: "1000"
|
1515
|
+
end
|
1516
|
+
```
|
1517
|
+
|
1518
|
+
Example for `accessmode: "mapped"` with 9p:
|
1519
|
+
|
1520
|
+
``` ruby
|
1521
|
+
Vagrant.configure("2") do |config|
|
1522
|
+
config.vm.synced_folder "./", "/vagrant", type: "9p", disabled: false, accessmode: "mapped", mount: false
|
1523
|
+
end
|
1524
|
+
```
|
1525
|
+
|
1526
|
+
Further documentation on using 9p can be found in [kernel
|
1527
|
+
docs](https://www.kernel.org/doc/Documentation/filesystems/9p.txt) and in
|
1528
|
+
[QEMU
|
1529
|
+
wiki](https://wiki.qemu.org/Documentation/9psetup#Starting_the_Guest_directly).
|
1530
|
+
|
1531
|
+
Please do note that 9p depends on support in the guest and not all distros
|
1532
|
+
come with the 9p module by default.
|
1533
|
+
|
1534
|
+
**Virtio-fs**
|
1535
|
+
|
1536
|
+
`vagrant-libvirt` supports [Virtio-fs](https://virtio-fs.gitlab.io/) with
|
1537
|
+
bidirectional synced folders.
|
1538
|
+
|
1539
|
+
For virtiofs shares, a `mount: false` option allows to define synced folders
|
1540
|
+
without mounting them at boot.
|
1541
|
+
|
1542
|
+
So far, passthrough is the only supported access mode and it requires running
|
1543
|
+
the virtiofsd daemon as root.
|
1544
|
+
|
1545
|
+
QEMU needs to allocate the backing memory for all the guest RAM as shared
|
1546
|
+
memory, e.g. [Use file-backed
|
1547
|
+
memory](https://libvirt.org/kbase/virtiofs.html#host-setup) by enable
|
1548
|
+
`memory_backing_dir` option in `/etc/libvirt/qemu.conf`:
|
1549
|
+
|
1550
|
+
``` shell
|
1551
|
+
memory_backing_dir = "/dev/shm"
|
1552
|
+
```
|
1553
|
+
|
1554
|
+
Example for Libvirt \>= 6.2.0 (e.g. Ubuntu 20.10 with Linux 5.8.0 + QEMU 5.0 +
|
1555
|
+
Libvirt 6.6.0, i.e. NUMA nodes required) with virtiofs:
|
1556
|
+
|
1557
|
+
``` ruby
|
1558
|
+
Vagrant.configure("2") do |config|
|
1559
|
+
config.vm.provider :libvirt do |libvirt|
|
1560
|
+
libvirt.cpus = 2
|
1561
|
+
libvirt.numa_nodes = [{ :cpus => "0-1", :memory => 8192, :memAccess => "shared" }]
|
1562
|
+
libvirt.memorybacking :access, :mode => "shared"
|
1563
|
+
end
|
1564
|
+
config.vm.synced_folder "./", "/vagrant", type: "virtiofs"
|
1565
|
+
end
|
1566
|
+
```
|
1567
|
+
|
1568
|
+
Example for Libvirt \>= 6.9.0 (e.g. Ubuntu 21.04 with Linux 5.11.0 + QEMU 5.2 +
|
1569
|
+
Libvirt 7.0.0, or Ubuntu 20.04 + [PPA
|
1570
|
+
enabled](https://launchpad.net/~savoury1/+archive/ubuntu/virtualisation)) with
|
1571
|
+
virtiofs:
|
1572
|
+
|
1573
|
+
``` ruby
|
1574
|
+
Vagrant.configure("2") do |config|
|
1575
|
+
config.vm.provider :libvirt do |libvirt|
|
1576
|
+
libvirt.cpus = 2
|
1577
|
+
libvirt.memory = 8192
|
1578
|
+
libvirt.memorybacking :access, :mode => "shared"
|
1579
|
+
end
|
1580
|
+
config.vm.synced_folder "./", "/vagrant", type: "virtiofs"
|
1581
|
+
end
|
1582
|
+
```
|
1583
|
+
|
1584
|
+
Further documentation on using virtiofs can be found in [official
|
1585
|
+
HowTo](https://virtio-fs.gitlab.io/index.html#howto) and in [Libvirt
|
1586
|
+
KB](https://libvirt.org/kbase/virtiofs.html).
|
1587
|
+
|
1588
|
+
Please do note that virtiofs depends on:
|
1589
|
+
|
1590
|
+
- Host: Linux \>= 5.4, QEMU \>= 4.2 and Libvirt \>= 6.2 (e.g. Ubuntu 20.10)
|
1591
|
+
- Guest: Linux \>= 5.4 (e.g. Ubuntu 20.04)
|
1449
1592
|
|
1450
1593
|
## QEMU Session Support
|
1451
1594
|
|
@@ -1652,7 +1795,11 @@ Vagrant.configure("2") do |config|
|
|
1652
1795
|
end
|
1653
1796
|
```
|
1654
1797
|
|
1655
|
-
## Box
|
1798
|
+
## Box Formats
|
1799
|
+
|
1800
|
+
### Version 1
|
1801
|
+
|
1802
|
+
This is the original format that most boxes currently use.
|
1656
1803
|
|
1657
1804
|
You can view an example box in the
|
1658
1805
|
[`example_box/directory`](https://github.com/vagrant-libvirt/vagrant-libvirt/tree/master/example_box).
|
@@ -1666,6 +1813,45 @@ The box is a tarball containing:
|
|
1666
1813
|
* `Vagrantfile` that does default settings for the provider-specific
|
1667
1814
|
configuration for this provider
|
1668
1815
|
|
1816
|
+
|
1817
|
+
### Version 2 (Experimental)
|
1818
|
+
|
1819
|
+
Due to the limitation of only being able to handle a single disk with the version 1 format, a new
|
1820
|
+
format was added to support boxes that need to specify multiple disks. This is still currently
|
1821
|
+
experimental and as such support for packaging has yet to be added. There is a script in the tools
|
1822
|
+
folder (tools/create_box_with_two_disks.sh) that should provide a guideline on how to create such
|
1823
|
+
a box for those that wish to experiment and provide early feedback.
|
1824
|
+
|
1825
|
+
At it's most basic, it expects an array of disks to allow a specific order to be presented. Disks
|
1826
|
+
will be attached in this order and as such assume device names base on this within the VM. The
|
1827
|
+
'path' attribute is required, and is expected to be relative to the base of the box. This should
|
1828
|
+
allow placing the disk images within a nested directory within the box if it useful for those
|
1829
|
+
with a larger number of disks. The name allows overriding the target volume name that will be
|
1830
|
+
used in the libvirt storage pool. Note that vagrant-libvirt will still prefix the volume name
|
1831
|
+
with `#{box_name}_vagrant_box_image_#{box_version}_` to avoid accidental clashes with other boxes.
|
1832
|
+
|
1833
|
+
Format and virtual size need no longer be specified as they are now retrieved directly from the
|
1834
|
+
provided image using `qemu-img info ...`.
|
1835
|
+
|
1836
|
+
Example format:
|
1837
|
+
```json
|
1838
|
+
{
|
1839
|
+
'disks': [
|
1840
|
+
{
|
1841
|
+
'path': 'disk1.img'
|
1842
|
+
},
|
1843
|
+
{
|
1844
|
+
'path': 'disk2.img',
|
1845
|
+
'name': 'secondary_disk'
|
1846
|
+
},
|
1847
|
+
{
|
1848
|
+
'path': 'disk3.img'
|
1849
|
+
}
|
1850
|
+
],
|
1851
|
+
'provider': 'libvirt'
|
1852
|
+
}
|
1853
|
+
```
|
1854
|
+
|
1669
1855
|
## Create Box
|
1670
1856
|
|
1671
1857
|
If creating a box from a modified vagrant-libvirt machine, ensure that
|
@@ -1782,17 +1968,49 @@ $ bundle install
|
|
1782
1968
|
Once you have the dependencies, verify the unit tests pass with `rspec`:
|
1783
1969
|
|
1784
1970
|
```shell
|
1785
|
-
$
|
1971
|
+
$ export VAGRANT_HOME=$(mktemp -d)
|
1972
|
+
$ bundle exec rspec --fail-fast --color --format documentation
|
1973
|
+
```
|
1974
|
+
|
1975
|
+
If those pass, you're ready to start developing the plugin.
|
1976
|
+
|
1977
|
+
Setting `VAGRANT_HOME` is to avoid issues with conflicting with other
|
1978
|
+
plugins/gems or data already present under `~/.vagrant.d`.
|
1979
|
+
|
1980
|
+
Additionally if you wish to test against a specific version of vagrant you
|
1981
|
+
can control the version using the following before running the tests:
|
1982
|
+
|
1983
|
+
```shell
|
1984
|
+
$ export VAGRANT_VERSION=v2.2.14
|
1786
1985
|
```
|
1787
1986
|
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1987
|
+
**Note** rvm is used by the maintainers to help provide an environment to test
|
1988
|
+
against multiple ruby versions that align with the ones used by vagrant for
|
1989
|
+
their embedded ruby depending on the release. You can see what version is used
|
1990
|
+
by looking at the current [unit tests](.github/workflows/unit-tests.yml)
|
1991
|
+
workflow.
|
1992
|
+
|
1993
|
+
You can test the plugin without installing it into your Vagrant environment by
|
1994
|
+
just creating a `Vagrantfile` in the top level of this directory (it is
|
1995
|
+
gitignored) that uses it. You can add the following line to your Vagrantfile
|
1996
|
+
while in development to ensure vagrant checks that the plugin is installed:
|
1793
1997
|
|
1794
1998
|
```ruby
|
1795
|
-
Vagrant.
|
1999
|
+
Vagrant.configure("2") do |config|
|
2000
|
+
config.vagrant.plugins = "vagrant-libvirt"
|
2001
|
+
end
|
2002
|
+
```
|
2003
|
+
Or add the following to the top of the file to ensure that any required plugins
|
2004
|
+
are installed globally:
|
2005
|
+
```ruby
|
2006
|
+
REQUIRED_PLUGINS = %w(vagrant-libvirt)
|
2007
|
+
exit unless REQUIRED_PLUGINS.all? do |plugin|
|
2008
|
+
Vagrant.has_plugin?(plugin) || (
|
2009
|
+
puts "The #{plugin} plugin is required. Please install it with:"
|
2010
|
+
puts "$ vagrant plugin install #{plugin}"
|
2011
|
+
false
|
2012
|
+
)
|
2013
|
+
end
|
1796
2014
|
```
|
1797
2015
|
|
1798
2016
|
Now you can use bundler to execute Vagrant:
|
@@ -49,6 +49,7 @@ module VagrantPlugins
|
|
49
49
|
|
50
50
|
b2.use StartDomain
|
51
51
|
b2.use WaitTillUp
|
52
|
+
b2.use WaitForCommunicator, [:running]
|
52
53
|
|
53
54
|
b2.use ForwardPorts
|
54
55
|
b2.use SetHostname
|
@@ -107,6 +108,7 @@ module VagrantPlugins
|
|
107
108
|
# Machine should gain IP address when comming up,
|
108
109
|
# so wait for dhcp lease and store IP into machines data_dir.
|
109
110
|
b3.use WaitTillUp
|
111
|
+
b3.use WaitForCommunicator, [:running]
|
110
112
|
|
111
113
|
b3.use ForwardPorts
|
112
114
|
b3.use PrepareNFSSettings
|
@@ -179,6 +181,7 @@ module VagrantPlugins
|
|
179
181
|
# Try to remove stale volumes anyway
|
180
182
|
b2.use SetNameOfDomain
|
181
183
|
b2.use RemoveStaleVolume if env[:machine].config.vm.box
|
184
|
+
b2.use CleanMachineFolder, quiet: true
|
182
185
|
b2.use MessageNotCreated unless env[:result]
|
183
186
|
|
184
187
|
next
|
@@ -186,11 +189,12 @@ module VagrantPlugins
|
|
186
189
|
|
187
190
|
b2.use Call, DestroyConfirm do |env2, b3|
|
188
191
|
if env2[:result]
|
192
|
+
b3.use ProvisionerCleanup, :before
|
189
193
|
b3.use ClearForwardedPorts
|
190
194
|
b3.use PruneNFSExports
|
191
195
|
b3.use DestroyDomain
|
192
196
|
b3.use DestroyNetworks
|
193
|
-
b3.use
|
197
|
+
b3.use CleanMachineFolder
|
194
198
|
else
|
195
199
|
b3.use MessageWillNotDestroy
|
196
200
|
end
|
@@ -324,6 +328,7 @@ module VagrantPlugins
|
|
324
328
|
autoload :CreateDomainVolume, action_root.join('create_domain_volume')
|
325
329
|
autoload :CreateNetworkInterfaces, action_root.join('create_network_interfaces')
|
326
330
|
autoload :CreateNetworks, action_root.join('create_networks')
|
331
|
+
autoload :CleanMachineFolder, action_root.join('clean_machine_folder')
|
327
332
|
autoload :DestroyDomain, action_root.join('destroy_domain')
|
328
333
|
autoload :DestroyNetworks, action_root.join('destroy_networks')
|
329
334
|
autoload :ForwardPorts, action_root.join('forward_ports')
|
@@ -366,6 +371,7 @@ module VagrantPlugins
|
|
366
371
|
autoload :SyncedFolders, 'vagrant/action/builtin/synced_folders'
|
367
372
|
autoload :SyncedFolderCleanup, 'vagrant/action/builtin/synced_folder_cleanup'
|
368
373
|
autoload :ProvisionerCleanup, 'vagrant/action/builtin/provisioner_cleanup'
|
374
|
+
autoload :WaitForCommunicator, 'vagrant/action/builtin/wait_for_communicator'
|
369
375
|
end
|
370
376
|
end
|
371
377
|
end
|