Hello community,
here is the log from the commit of package vagrant-libvirt for openSUSE:Factory
checked in at 2020-11-03 15:15:53
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/vagrant-libvirt (Old)
and /work/SRC/openSUSE:Factory/.vagrant-libvirt.new.3463 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "vagrant-libvirt"
Tue Nov 3 15:15:53 2020 rev:10 rq:845382 version:0.2.1
Changes:
--------
--- /work/SRC/openSUSE:Factory/vagrant-libvirt/vagrant-libvirt.changes
2020-09-15 16:27:52.418572861 +0200
+++
/work/SRC/openSUSE:Factory/.vagrant-libvirt.new.3463/vagrant-libvirt.changes
2020-11-03 15:16:19.276025931 +0100
@@ -1,0 +2,48 @@
+Thu Oct 22 15:45:01 UTC 2020 - Dan Čermák <[email protected]>
+
+New upstream release 0.2.1
+
+## [0.2.1](https://github.com/vagrant-libvirt/vagrant-libvirt/tree/0.2.1)
(2020-10-03)
+
+[Full
Changelog](https://github.com/vagrant-libvirt/vagrant-libvirt/compare/0.2.0...0.2.1)
+
+**Closed issues:**
+
+- Erubis dependency #1142
+
+
+## [0.2.0](https://github.com/vagrant-libvirt/vagrant-libvirt/tree/0.2.0)
(2020-10-03)
+
+[Full
Changelog](https://github.com/vagrant-libvirt/vagrant-libvirt/compare/0.1.2...0.2.0)
+
+**Closed issues:**
+
+- First time using - vagrant up fails with network related errors
[\#1146](https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1146)
+- Waiting for domain to get an IP address
[\#1145](https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1145)
+- CentOS 8 fail to install libvirt Failed to build gem native extension
[\#1135](https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1135)
+- `\<module:Util\>': uninitialized constant
VagrantPlugins::ProviderLibvirt::Util::ErbTemplate \(NameError\)
[\#1131](https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1131)
+- vagrant asking for VBoxManage binary
[\#1125](https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1125)
+- after upgrading vagrant to 2.2.9 \(from 2.2.7\) a vagrant up destroys the
domain on error
[\#1122](https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1122)
+- Failure to detect second machine instance using Vagrant CLI
[\#1121](https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1121)
+- Help/Feature-Request: Host-only management network
[\#1117](https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1117)
+- libvirt plugin install FAILs to find existing "package configuration for
libvirt is not found"
[\#1104](https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1104)
+- Fedora box download is not available
[\#1070](https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1070)
+
+**Merged pull requests:**
+
+- Support release notes generation
[\#1150](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/1150)
([electrofelix](https://github.com/electrofelix))
+- Add docker image for vagrant-libvirt
[\#1149](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/1149)
([electrofelix](https://github.com/electrofelix))
+- Use Vagrant::Util::TemplateRenderer instead of Erubis.
[\#1144](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/1144)
([voxik](https://github.com/voxik))
+- config: allow for setting URI from environment
[\#1141](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/1141)
([electrofelix](https://github.com/electrofelix))
+- Limit CI jobs to a subset of combinations
[\#1140](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/1140)
([electrofelix](https://github.com/electrofelix))
+- Add @uri config tests and minor refactor
[\#1139](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/1139)
([electrofelix](https://github.com/electrofelix))
+- Update test syntax to remove stubs
[\#1138](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/1138)
([electrofelix](https://github.com/electrofelix))
+- let the user set the domain title and description
[\#1137](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/1137)
([rgl](https://github.com/rgl))
+- remove redundant setting of default volume/backingStore mode
[\#1134](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/1134)
([eighthave](https://github.com/eighthave))
+- Add WWN support
[\#1123](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/1123)
([cvoltz](https://github.com/cvoltz))
+- update examples to use fedora/32-cloud-base
[\#1119](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/1119)
([timhughes](https://github.com/timhughes))
+- add snapshot\_pool\_name to README
[\#1114](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/1114)
([abbbi](https://github.com/abbbi))
+- action/forward\_ports.rb: Fix SSH tunnel spawning and PID tracking
[\#1037](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/1037)
([zakame](https://github.com/zakame))
+- Add public\_address provider capability
[\#1036](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/1036)
([zakame](https://github.com/zakame))
+
+-------------------------------------------------------------------
Old:
----
vagrant-libvirt-0.1.2.gem
New:
----
vagrant-libvirt-0.2.1.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ vagrant-libvirt.spec ++++++
--- /var/tmp/diff_new_pack.vyYFVf/_old 2020-11-03 15:16:20.136026759 +0100
+++ /var/tmp/diff_new_pack.vyYFVf/_new 2020-11-03 15:16:20.136026759 +0100
@@ -21,7 +21,7 @@
%global rb_ruby_suffix %rb_default_ruby_suffix
Name: vagrant-libvirt
-Version: 0.1.2
+Version: 0.2.1
Release: 0
%define mod_name vagrant-libvirt
%define mod_full_name %{mod_name}-%{version}
++++++ vagrant-libvirt-0.1.2.gem -> vagrant-libvirt-0.2.1.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md 2020-05-12 11:05:44.000000000 +0200
+++ new/README.md 2020-10-03 22:20:38.000000000 +0200
@@ -16,54 +16,55 @@
<!-- note in vim set "let g:vmt_list_item_char='-'" to generate the correct
output -->
<!-- vim-markdown-toc GFM -->
-- [Features](#features)
-- [Future work](#future-work)
-- [Installation](#installation)
- - [Possible problems with plugin installation on
Linux](#possible-problems-with-plugin-installation-on-linux)
-- [Vagrant Project Preparation](#vagrant-project-preparation)
- - [Add Box](#add-box)
- - [Create Vagrantfile](#create-vagrantfile)
- - [Start VM](#start-vm)
- - [How Project Is Created](#how-project-is-created)
- - [Libvirt Configuration](#libvirt-configuration)
- - [Provider Options](#provider-options)
- - [Domain Specific Options](#domain-specific-options)
- - [Reload behavior](#reload-behavior)
-- [Networks](#networks)
- - [Private Network Options](#private-network-options)
- - [Public Network Options](#public-network-options)
- - [Management Network](#management-network)
-- [Additional Disks](#additional-disks)
- - [Reload behavior](#reload-behavior-1)
-- [CDROMs](#cdroms)
-- [Input](#input)
-- [PCI device passthrough](#pci-device-passthrough)
-- [Using USB Devices](#using-usb-devices)
- - [USB Controller Configuration](#usb-controller-configuration)
- - [USB Device Passthrough](#usb-device-passthrough)
- - [USB Redirector Devices](#usb-redirector-devices)
- - [Filter for USB Redirector Devices](#filter-for-usb-redirector-devices)
-- [Random number generator passthrough](#random-number-generator-passthrough)
-- [Watchdog device](#watchdog-device)
-- [Smartcard device](#smartcard-device)
-- [Hypervisor Features](#hypervisor-features)
-- [CPU features](#cpu-features)
-- [Memory Backing](#memory-backing)
-- [No box and PXE boot](#no-box-and-pxe-boot)
-- [SSH Access To VM](#ssh-access-to-vm)
-- [Forwarded Ports](#forwarded-ports)
-- [Synced Folders](#synced-folders)
-- [QEMU Session Support](#qemu-session-support)
-- [Customized Graphics](#customized-graphics)
-- [TPM Devices](#tpm-devices)
-- [Libvirt communication channels](#libvirt-communication-channels)
-- [Custom command line arguments and environment
variables](#custom-command-line-arguments-and-environment-variables)
-- [Box Format](#box-format)
-- [Create Box](#create-box)
-- [Package Box from VM](#package-box-from-vm)
-- [Troubleshooting VMs](#troubleshooting-vms)
-- [Development](#development)
-- [Contributing](#contributing)
+* [Features](#features)
+* [Future work](#future-work)
+* [Using Docker based Installation](#using-docker-based-installation)
+* [Installation](#installation)
+ * [Possible problems with plugin installation on
Linux](#possible-problems-with-plugin-installation-on-linux)
+* [Vagrant Project Preparation](#vagrant-project-preparation)
+ * [Add Box](#add-box)
+ * [Create Vagrantfile](#create-vagrantfile)
+ * [Start VM](#start-vm)
+ * [How Project Is Created](#how-project-is-created)
+ * [Libvirt Configuration](#libvirt-configuration)
+ * [Provider Options](#provider-options)
+ * [Domain Specific Options](#domain-specific-options)
+ * [Reload behavior](#reload-behavior)
+* [Networks](#networks)
+ * [Private Network Options](#private-network-options)
+ * [Public Network Options](#public-network-options)
+ * [Management Network](#management-network)
+* [Additional Disks](#additional-disks)
+ * [Reload behavior](#reload-behavior-1)
+* [CDROMs](#cdroms)
+* [Input](#input)
+* [PCI device passthrough](#pci-device-passthrough)
+* [Using USB Devices](#using-usb-devices)
+ * [USB Controller Configuration](#usb-controller-configuration)
+ * [USB Device Passthrough](#usb-device-passthrough)
+ * [USB Redirector Devices](#usb-redirector-devices)
+ * [Filter for USB Redirector Devices](#filter-for-usb-redirector-devices)
+* [Random number generator passthrough](#random-number-generator-passthrough)
+* [Watchdog device](#watchdog-device)
+* [Smartcard device](#smartcard-device)
+* [Hypervisor Features](#hypervisor-features)
+* [CPU features](#cpu-features)
+* [Memory Backing](#memory-backing)
+* [No box and PXE boot](#no-box-and-pxe-boot)
+* [SSH Access To VM](#ssh-access-to-vm)
+* [Forwarded Ports](#forwarded-ports)
+* [Synced Folders](#synced-folders)
+* [QEMU Session Support](#qemu-session-support)
+* [Customized Graphics](#customized-graphics)
+* [TPM Devices](#tpm-devices)
+* [Libvirt communication channels](#libvirt-communication-channels)
+* [Custom command line arguments and environment
variables](#custom-command-line-arguments-and-environment-variables)
+* [Box Format](#box-format)
+* [Create Box](#create-box)
+* [Package Box from VM](#package-box-from-vm)
+* [Troubleshooting VMs](#troubleshooting-vms)
+* [Development](#development)
+* [Contributing](#contributing)
<!-- vim-markdown-toc -->
@@ -92,6 +93,39 @@
* Take a look at [open
issues](https://github.com/vagrant-libvirt/vagrant-libvirt/issues?state=open).
+## Using Docker based Installation
+
+Due to the number of issues encountered around compatibility between the ruby
runtime environment
+that is part of the upstream vagrant installation and the library dependencies
of libvirt that
+this project requires to communicate with libvirt, there is a docker image
build and published.
+
+This should allow users to execute vagrant with vagrant-libvirt without
needing to deal with
+the compatibility issues, though you may need to extend the image for your own
needs should
+you make use of additional plugins.
+
+To get the image:
+```bash
+docker pull vagrantlibvirt/vagrant-libvirt:latest
+```
+
+Running the image:
+```bash
+docker run -it -rm \
+ -e LIBVIRT_DEFAULT_URI \
+ -v /var/run/libvirt/:/var/run/libvirt/ \
+ -v ~/.vagrant.d:/.vagrant.d \
+ -v $(pwd):$(pwd) \
+ -w $(pwd) \
+ vagrantlibvirt/vagrant-libvirt:latest \
+ vagrant status
+```
+
+Note that if you are connecting to a remote system libvirt, you may omit the
+`-v /var/run/libvirt/:/var/run/libvirt/` mount bind. Some distributions patch
the local
+vagrant environment to ensure vagrant-libvirt uses `qemu:///session`, which
means you
+may need to set the environment variable `LIBVIRT_DEFAULT_URI` to the same
value if
+looking to use this in place of your distribution provided installation.
+
## Installation
First, you should have both QEMU and Libvirt installed if you plan to run VMs
@@ -210,7 +244,7 @@
example:
```shell
-vagrant init fedora/24-cloud-base
+vagrant init fedora/32-cloud-base
```
### Create Vagrantfile
@@ -221,7 +255,7 @@
```ruby
Vagrant.configure("2") do |config|
config.vm.define :test_vm do |test_vm|
- test_vm.vm.box = "fedora/24-cloud-base"
+ test_vm.vm.box = "fedora/32-cloud-base"
end
end
```
@@ -285,7 +319,10 @@
Connection-independent options:
* `storage_pool_name` - Libvirt storage pool name, where box image and instance
- snapshots will be stored.
+ snapshots (if `snapshot_pool_name` is not set) will be stored.
+* `snapshot_pool_name` - Libvirt storage pool name. If set, the created
+ snapshot of the instance will be stored at this location instead of
+ `storage_pool_name`.
For example:
@@ -299,6 +336,8 @@
### Domain Specific Options
+* `title` - A short description of the domain.
+* `description` - A human readable description of the virtual machine.
* `disk_bus` - The type of disk device to emulate. Defaults to virtio if not
set. Possible values are documented in Libvirt's [description for
_target_](http://libvirt.org/formatdomain.html#elementsDisks). NOTE: this
@@ -774,6 +813,7 @@
Disks with this option set to true need to be removed manually.
* `shareable` - Set to true if you want to simulate shared SAN storage.
* `serial` - Serial number of the disk device.
+* `wwn` - WWN number of the disk device.
The following example creates two additional disks.
@@ -1395,7 +1435,7 @@
```ruby
Vagrant.configure(2) do |config|
- config.vm.box = "fedora/24-cloud-base"
+ config.vm.box = "fedora/32-cloud-base"
config.vm.provider :libvirt do |libvirt|
libvirt.channel :type => 'unix', :target_name => 'org.qemu.guest_agent.0',
:target_type => 'virtio'
end
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/vagrant-libvirt/action/create_domain.rb
new/lib/vagrant-libvirt/action/create_domain.rb
--- old/lib/vagrant-libvirt/action/create_domain.rb 2020-05-12
11:05:44.000000000 +0200
+++ new/lib/vagrant-libvirt/action/create_domain.rb 2020-10-03
22:20:38.000000000 +0200
@@ -31,6 +31,8 @@
# Gather some info about domain
@name = env[:domain_name]
+ @title = config.title
+ @description = config.description
@uuid = config.uuid
@cpus = config.cpus.to_i
@cpuset = config.cpuset
@@ -195,6 +197,8 @@
# Output the settings we're going to use to the user
env[:ui].info(I18n.t('vagrant_libvirt.creating_domain'))
env[:ui].info(" -- Name: #{@name}")
+ env[:ui].info(" -- Title: #{@title}") if @title != ''
+ env[:ui].info(" -- Description: #{@description}") if
@description != ''
env[:ui].info(" -- Forced UUID: #{@uuid}") if @uuid != ''
env[:ui].info(" -- Domain type: #{@domain_type}")
env[:ui].info(" -- Cpus: #{@cpus}")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/vagrant-libvirt/action/create_domain_volume.rb
new/lib/vagrant-libvirt/action/create_domain_volume.rb
--- old/lib/vagrant-libvirt/action/create_domain_volume.rb 2020-05-12
11:05:44.000000000 +0200
+++ new/lib/vagrant-libvirt/action/create_domain_volume.rb 2020-10-03
22:20:38.000000000 +0200
@@ -51,7 +51,6 @@
xml.permissions do
xml.owner storage_uid(env)
xml.group storage_gid(env)
- xml.mode '0600'
xml.label 'virt_image_t'
end
end
@@ -61,7 +60,6 @@
xml.permissions do
xml.owner storage_uid(env)
xml.group storage_gid(env)
- xml.mode '0600'
xml.label 'virt_image_t'
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/vagrant-libvirt/action/forward_ports.rb
new/lib/vagrant-libvirt/action/forward_ports.rb
--- old/lib/vagrant-libvirt/action/forward_ports.rb 2020-05-12
11:05:44.000000000 +0200
+++ new/lib/vagrant-libvirt/action/forward_ports.rb 2020-10-03
22:20:38.000000000 +0200
@@ -98,6 +98,7 @@
Port=#{ssh_info[:port]}
UserKnownHostsFile=/dev/null
ExitOnForwardFailure=yes
+ ControlMaster=no
StrictHostKeyChecking=no
PasswordAuthentication=no
ForwardX11=#{ssh_info[:forward_x11] ? 'yes' : 'no'}
@@ -109,7 +110,7 @@
options += " -o ProxyCommand=\"#{ssh_info[:proxy_command]}\"" if
machine.provider_config.connect_via_ssh
# TODO: instead of this, try and lock and get the stdin from spawn...
- ssh_cmd = 'exec '
+ ssh_cmd = ''
if host_port <= 1024
@@lock.synchronize do
# TODO: add i18n
@@ -127,7 +128,7 @@
log_file = ssh_forward_log_file(host_ip, host_port,
guest_ip, guest_port)
@logger.info "Logging to #{log_file}"
- spawn(ssh_cmd, [:out, :err] => [log_file, 'w'])
+ spawn(ssh_cmd, [:out, :err] => [log_file, 'w'], :pgroup => true)
end
def ssh_forward_log_file(host_ip, host_port, guest_ip, guest_port)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/vagrant-libvirt/action/halt_confirm.rb
new/lib/vagrant-libvirt/action/halt_confirm.rb
--- old/lib/vagrant-libvirt/action/halt_confirm.rb 2020-05-12
11:05:44.000000000 +0200
+++ new/lib/vagrant-libvirt/action/halt_confirm.rb 1970-01-01
01:00:00.000000000 +0100
@@ -1,20 +0,0 @@
-module VagrantPlugins
- module ProviderLibvirt
- module Action
- # This class asks the user to confirm the destruction of a machine
- # that Vagrant manages. This is provided as a built-in on top of
- # {Confirm} because it sets up the proper keys and such so that
- # `vagrant destroy -f` works properly.
- class HaltConfirm < Vagrant::Action::Builtin::Confirm
- def initialize(app, env)
- force_key = :force_confirm_halt
- message = I18n.t("vagrant_libvirt.package_confirm_halt",
- name: env[:machine].name)
-
- super(app, env, message, force_key, allowed: ["y", "n", "Y", "N"])
- end
- end
- end
- end
-end
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/vagrant-libvirt/cap/public_address.rb
new/lib/vagrant-libvirt/cap/public_address.rb
--- old/lib/vagrant-libvirt/cap/public_address.rb 1970-01-01
01:00:00.000000000 +0100
+++ new/lib/vagrant-libvirt/cap/public_address.rb 2020-10-03
22:20:38.000000000 +0200
@@ -0,0 +1,16 @@
+module VagrantPlugins
+ module ProviderLibvirt
+ module Cap
+ class PublicAddress
+ def self.public_address(machine)
+ # This does not need to be a globally routable address, it
+ # only needs to be accessible from the machine running
+ # Vagrant.
+ ssh_info = machine.ssh_info
+ return nil if !ssh_info
+ ssh_info[:host]
+ end
+ end
+ end
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/vagrant-libvirt/config.rb
new/lib/vagrant-libvirt/config.rb
--- old/lib/vagrant-libvirt/config.rb 2020-05-12 11:05:44.000000000 +0200
+++ new/lib/vagrant-libvirt/config.rb 2020-10-03 22:20:38.000000000 +0200
@@ -67,6 +67,8 @@
attr_accessor :default_prefix
# Domain specific settings used while creating new domain.
+ attr_accessor :title
+ attr_accessor :description
attr_accessor :uuid
attr_accessor :memory
attr_accessor :nodeset
@@ -197,6 +199,8 @@
@system_uri = UNSET_VALUE
# Domain specific settings.
+ @title = UNSET_VALUE
+ @description = UNSET_VALUE
@uuid = UNSET_VALUE
@memory = UNSET_VALUE
@nodeset = UNSET_VALUE
@@ -600,7 +604,8 @@
cache: options[:cache] || 'default',
allow_existing: options[:allow_existing],
shareable: options[:shareable],
- serial: options[:serial]
+ serial: options[:serial],
+ wwn: options[:wwn]
}
@disks << disk # append
@@ -618,14 +623,21 @@
@qemu_env.merge!(options)
end
- # code to generate URI from a config moved out of the connect action
- def _generate_uri
+ # code to generate URI from from either the LIBVIRT_URI environment
+ # variable or a config moved out of the connect action
+ def _generate_uri(qemu_use_session)
+
+ # If the LIBVIRT_DEFAULT_URI var is set, we'll use that
+ if ENV.fetch('LIBVIRT_DEFAULT_URI', '') != ""
+ return ENV['LIBVIRT_DEFAULT_URI']
+ end
+
# builds the Libvirt connection URI from the given driver config
# Setup connection uri.
uri = @driver.dup
virt_path = case uri
when 'qemu', 'kvm'
- @qemu_use_session ? '/session' : '/system'
+ qemu_use_session ? '/session' : '/system'
when 'openvz', 'uml', 'phyp', 'parallels'
'/system'
when '@en', 'esx'
@@ -643,31 +655,37 @@
uri << '+ssh://'
uri << @username + '@' if @username
- uri << if @host
- @host
- else
- 'localhost'
- end
+ uri << ( @host ? @host : 'localhost' )
else
uri << '://'
uri << @host if @host
end
uri << virt_path
- uri << '?no_verify=1'
+
+ params = {'no_verify' => '1'}
if @id_ssh_key_file
# set ssh key for access to Libvirt host
- uri << "\&keyfile="
# if no slash, prepend $HOME/.ssh/
- @id_ssh_key_file.prepend("#{`echo ${HOME}`.chomp}/.ssh/") if
@id_ssh_key_file !~ /\A\//
- uri << @id_ssh_key_file
+ @id_ssh_key_file.prepend("#{ENV['HOME']}/.ssh/") if @id_ssh_key_file
!~ /\A\//
+ params['keyfile'] = @id_ssh_key_file
end
# set path to Libvirt socket
- uri << "\&socket=" + @socket if @socket
+ params['socket'] = @socket if @socket
+
+ uri << "?" + params.map{|pair| pair.join('=')}.join('&')
uri
end
+ def _parse_uri(uri)
+ begin
+ URI.parse(uri)
+ rescue
+ raise "@uri set to invalid uri '#{uri}'"
+ end
+ end
+
def finalize!
@driver = 'kvm' if @driver == UNSET_VALUE
@host = nil if @host == UNSET_VALUE
@@ -691,12 +709,25 @@
@management_network_domain = nil if @management_network_domain ==
UNSET_VALUE
@system_uri = 'qemu:///system' if @system_uri == UNSET_VALUE
- @qemu_use_session = false if @qemu_use_session == UNSET_VALUE
+ # If uri isn't set then let's build one from various sources.
+ # Default to passing false for qemu_use_session if it's not set.
+ if @uri == UNSET_VALUE
+ @uri = _generate_uri(@qemu_use_session == UNSET_VALUE ? false :
@qemu_use_session)
+ end
- # generate a URI if none is supplied
- @uri = _generate_uri if @uri == UNSET_VALUE
+ # Set qemu_use_session based on the URI if it wasn't set by the user
+ if @qemu_use_session == UNSET_VALUE
+ uri = _parse_uri(@uri)
+ if (uri.scheme.start_with? "qemu") && (uri.path.include? "session")
+ @qemu_use_session = true
+ else
+ @qemu_use_session = false
+ end
+ end
# Domain specific settings.
+ @title = '' if @title == UNSET_VALUE
+ @description = '' if @description == UNSET_VALUE
@uuid = '' if @uuid == UNSET_VALUE
@memory = 512 if @memory == UNSET_VALUE
@nodeset = nil if @nodeset == UNSET_VALUE
@@ -814,6 +845,14 @@
def validate(machine)
errors = _detected_errors
+ # The @uri and @qemu_use_session should not conflict
+ uri = _parse_uri(@uri)
+ if (uri.scheme.start_with? "qemu") && (uri.path.include? "session")
+ if @qemu_use_session != true
+ errors << "the URI and qemu_use_session configuration conflict:
uri:'#{@uri}' qemu_use_session:'#{@qemu_use_session}'"
+ end
+ end
+
machine.provider_config.disks.each do |disk|
if disk[:path] && (disk[:path][0] == '/')
errors << "absolute volume paths like '#{disk[:path]}' not yet
supported"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/vagrant-libvirt/plugin.rb
new/lib/vagrant-libvirt/plugin.rb
--- old/lib/vagrant-libvirt/plugin.rb 2020-05-12 11:05:44.000000000 +0200
+++ new/lib/vagrant-libvirt/plugin.rb 2020-10-03 22:20:38.000000000 +0200
@@ -39,6 +39,11 @@
Cap::NicMacAddresses
end
+ provider_capability(:libvirt, :public_address) do
+ require_relative 'cap/public_address'
+ Cap::PublicAddress
+ end
+
# lower priority than nfs or rsync
# https://github.com/vagrant-libvirt/vagrant-libvirt/pull/170
synced_folder('9p', 4) do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/vagrant-libvirt/templates/domain.xml.erb
new/lib/vagrant-libvirt/templates/domain.xml.erb
--- old/lib/vagrant-libvirt/templates/domain.xml.erb 2020-05-12
11:05:44.000000000 +0200
+++ new/lib/vagrant-libvirt/templates/domain.xml.erb 2020-10-03
22:20:38.000000000 +0200
@@ -1,5 +1,7 @@
<domain type='<%= @domain_type %>'
xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name><%= @name %></name>
+ <title><%= @title %></title>
+ <description><%= @description %></description>
<uuid><%= @uuid %></uuid>
<memory><%= @memory_size %></memory>
<vcpu<% if @cpuset %> cpuset='<%= @cpuset %>'<% end %>><%= @cpus %></vcpu>
@@ -127,6 +129,9 @@
<% if d[:serial] %>
<serial><%= d[:serial] %></serial>
<% end %>
+ <% if d[:wwn] %>
+ <wwn><%= d[:wwn] %></wwn>
+ <% end %>
<%# this will get auto generated by Libvirt
<address type='pci' domain='0x0000' bus='0x00' slot='???'
function='0x0'/>
-%>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/vagrant-libvirt/util/erb_template.rb
new/lib/vagrant-libvirt/util/erb_template.rb
--- old/lib/vagrant-libvirt/util/erb_template.rb 2020-05-12
11:05:44.000000000 +0200
+++ new/lib/vagrant-libvirt/util/erb_template.rb 2020-10-03
22:20:38.000000000 +0200
@@ -1,20 +1,19 @@
-require 'erubis'
-
module VagrantPlugins
module ProviderLibvirt
module Util
module ErbTemplate
# TODO: remove and use nokogiri builder
- # TODO: might be a chance to use vagrant template system according to
https://github.com/mitchellh/vagrant/issues/3231
def to_xml(template_name = nil, data = binding)
erb = template_name || self.class.to_s.split('::').last.downcase
- path = File.join(File.dirname(__FILE__), '..', 'templates',
- "#{erb}.xml.erb")
- template = File.read(path)
+ path = File.join(File.dirname(__FILE__), '..', 'templates')
+ template = "#{erb}.xml"
# TODO: according to erubis documentation, we should rather use
evaluate and forget about
# binding since the template may then change variables values
- Erubis::Eruby.new(template, trim: true).result(data)
+ Vagrant::Util::TemplateRenderer.render_with(:render, template,
template_root: path) do |renderer|
+ iv = data.eval ("instance_variables.collect {|i| [i,
instance_variable_get(i.to_sym)]}")
+ iv.each {|k, v| renderer.instance_variable_set(k, v)}
+ end
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/vagrant-libvirt/version.rb
new/lib/vagrant-libvirt/version.rb
--- old/lib/vagrant-libvirt/version.rb 2020-05-12 11:05:44.000000000 +0200
+++ new/lib/vagrant-libvirt/version.rb 2020-10-03 22:20:38.000000000 +0200
@@ -1,5 +1,5 @@
module VagrantPlugins
module ProviderLibvirt
- VERSION = '0.1.2'.freeze
+ VERSION = '0.2.1'.freeze
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2020-05-12 11:05:44.000000000 +0200
+++ new/metadata 2020-10-03 22:20:38.000000000 +0200
@@ -1,7 +1,7 @@
--- !ruby/object:Gem::Specification
name: vagrant-libvirt
version: !ruby/object:Gem::Version
- version: 0.1.2
+ version: 0.2.1
platform: ruby
authors:
- Lukas Stanek
@@ -10,7 +10,7 @@
autorequire:
bindir: bin
cert_chain: []
-date: 2020-05-12 00:00:00.000000000 Z
+date: 2020-10-03 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: rspec-core
@@ -130,7 +130,6 @@
- lib/vagrant-libvirt/action/destroy_domain.rb
- lib/vagrant-libvirt/action/destroy_networks.rb
- lib/vagrant-libvirt/action/forward_ports.rb
-- lib/vagrant-libvirt/action/halt_confirm.rb
- lib/vagrant-libvirt/action/halt_domain.rb
- lib/vagrant-libvirt/action/handle_box_image.rb
- lib/vagrant-libvirt/action/handle_storage_pool.rb
@@ -158,6 +157,7 @@
- lib/vagrant-libvirt/action/wait_till_up.rb
- lib/vagrant-libvirt/cap/mount_p9.rb
- lib/vagrant-libvirt/cap/nic_mac_addresses.rb
+- lib/vagrant-libvirt/cap/public_address.rb
- lib/vagrant-libvirt/cap/synced_folder.rb
- lib/vagrant-libvirt/config.rb
- lib/vagrant-libvirt/driver.rb
@@ -209,20 +209,20 @@
- !ruby/object:Gem::Version
version: '0'
requirements: []
-rubygems_version: 3.0.6
+rubygems_version: 3.0.3
signing_key:
specification_version: 4
summary: libvirt provider for Vagrant.
test_files:
-- spec/support/libvirt_context.rb
-- spec/support/sharedcontext.rb
-- spec/support/environment_helper.rb
-- spec/unit/templates/domain_all_settings.xml
-- spec/unit/templates/domain_custom_cpu_model.xml
-- spec/unit/templates/domain_defaults.xml
-- spec/unit/templates/domain_spec.rb
- spec/unit/action/wait_till_up_spec.rb
- spec/unit/action/destroy_domain_spec.rb
- spec/unit/action/set_name_of_domain_spec.rb
- spec/unit/config_spec.rb
+- spec/unit/templates/domain_defaults.xml
+- spec/unit/templates/domain_all_settings.xml
+- spec/unit/templates/domain_spec.rb
+- spec/unit/templates/domain_custom_cpu_model.xml
+- spec/support/libvirt_context.rb
+- spec/support/environment_helper.rb
+- spec/support/sharedcontext.rb
- spec/spec_helper.rb
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/support/libvirt_context.rb
new/spec/support/libvirt_context.rb
--- old/spec/support/libvirt_context.rb 2020-05-12 11:05:44.000000000 +0200
+++ new/spec/support/libvirt_context.rb 2020-10-03 22:20:38.000000000 +0200
@@ -25,6 +25,6 @@
# return some information for domain when needed
allow(domain).to receive(:mac).and_return('9C:D5:53:F1:5A:E7')
- machine.stub(id: id)
+ allow(machine).to receive(:id).and_return(id)
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/support/sharedcontext.rb
new/spec/support/sharedcontext.rb
--- old/spec/support/sharedcontext.rb 2020-05-12 11:05:44.000000000 +0200
+++ new/spec/support/sharedcontext.rb 2020-10-03 22:20:38.000000000 +0200
@@ -28,7 +28,7 @@
let(:plugin) { register_plugin }
before (:each) do
- machine.stub(guest: guest)
- machine.stub(communicator: communicator)
+ allow(machine).to receive(:guest).and_return(guest)
+ allow(machine).to receive(:communicator).and_return(communicator)
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/unit/action/destroy_domain_spec.rb
new/spec/unit/action/destroy_domain_spec.rb
--- old/spec/unit/action/destroy_domain_spec.rb 2020-05-12 11:05:44.000000000
+0200
+++ new/spec/unit/action/destroy_domain_spec.rb 2020-10-03 22:20:38.000000000
+0200
@@ -33,7 +33,7 @@
before do
allow(libvirt_domain).to receive(:list_snapshots).and_return([])
allow(libvirt_domain).to receive(:has_managed_save?).and_return(nil)
- root_disk.stub(name: 'test.img')
+ allow(root_disk).to receive(:name).and_return('test.img')
end
context 'when only has root disk' do
@@ -57,7 +57,7 @@
let(:extra_disk) { double('libvirt_extra_disk') }
before do
- extra_disk.stub(name: 'test-vdb.qcow2')
+ allow(extra_disk).to receive(:name).and_return('test-vdb.qcow2')
end
it 'destroys disks individually' do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/unit/action/set_name_of_domain_spec.rb
new/spec/unit/action/set_name_of_domain_spec.rb
--- old/spec/unit/action/set_name_of_domain_spec.rb 2020-05-12
11:05:44.000000000 +0200
+++ new/spec/unit/action/set_name_of_domain_spec.rb 2020-10-03
22:20:38.000000000 +0200
@@ -10,12 +10,12 @@
dmn =
VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain.new(Object.new, @env)
first = dmn.build_domain_name(@env)
second = dmn.build_domain_name(@env)
- first.should_not eq(second)
+ expect(first).to_not eq(second)
end
it 'builds simple domain name' do
@env.default_prefix = 'pre_'
dmn =
VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain.new(Object.new, @env)
- dmn.build_domain_name(@env).should eq('pre_')
+ expect(dmn.build_domain_name(@env)).to eq('pre_')
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/unit/config_spec.rb new/spec/unit/config_spec.rb
--- old/spec/unit/config_spec.rb 2020-05-12 11:05:44.000000000 +0200
+++ new/spec/unit/config_spec.rb 2020-10-03 22:20:38.000000000 +0200
@@ -6,12 +6,185 @@
describe VagrantPlugins::ProviderLibvirt::Config do
include_context 'unit'
+ let(:fake_env) { Hash.new }
+
+ describe '#finalize!' do
+ it 'is valid with defaults' do
+ subject.finalize!
+ end
+
+ context '@uri' do
+ before(:example) do
+ stub_const("ENV", fake_env)
+ end
+
+ context 'when LIBVIRT_DEFAULT_URI is defined' do
+ it 'should always use this value' do
+ fake_env['LIBVIRT_DEFAULT_URI'] = "custom:///custom_path"
+
+ subject.finalize!
+ expect(subject.uri).to eq("custom:///custom_path")
+ expect(subject.qemu_use_session).to eq(false)
+ end
+
+ context 'when LIBVIRT_DEFAULT_URI contains "qemu"' do
+ [
+ [
+ 'set qemu_use_session if "session" present',
+ 'qemu:///session',
+ true,
+ ],
+ [
+ 'handle different protocol additions',
+ 'qemu+ssh:///session',
+ true,
+ ],
+ [
+ 'handle options before and after path',
+ 'qemu://remote/session?keyfile=my_id_rsa',
+ true,
+ ],
+ [
+ 'identify when session not set',
+ 'qemu://remote/system',
+ false,
+ ],
+ [
+ 'handle session appearing elsewhere',
+ 'qemu://remote/system?keyfile=my_session_id',
+ false,
+ ],
+ ].each do |title, uri, session|
+ it "should #{title}" do
+ fake_env['LIBVIRT_DEFAULT_URI'] = uri
+
+ subject.finalize!
+ expect(subject.uri).to eq(uri)
+ expect(subject.qemu_use_session).to eq(session)
+ end
+ end
+ end
+ end
+
+ context 'when @driver is defined' do
+ defaults = {'id_ssh_key_file' => nil}
+ [
+ [
+ {'driver' => 'kvm'},
+ 'qemu:///system?no_verify=1',
+ false,
+ ],
+ [
+ {'driver' => 'qemu'},
+ 'qemu:///system?no_verify=1',
+ false,
+ ],
+ [
+ {'driver' => 'qemu', 'qemu_use_session' => true},
+ 'qemu:///session?no_verify=1',
+ true,
+ ],
+ [
+ {'driver' => 'openvz'},
+ 'openvz:///system?no_verify=1',
+ false,
+ ],
+ [
+ {'driver' => 'vbox'},
+ 'vbox:///session?no_verify=1',
+ false,
+ ],
+ ].each do |inputs, output_uri, output_session|
+ it "should detect #{inputs}" do
+ inputs.merge(defaults).each do |k, v|
+ subject.instance_variable_set("@#{k}", v)
+ end
+
+ subject.finalize!
+ expect(subject.uri).to eq(output_uri)
+ expect(subject.qemu_use_session).to eq(output_session)
+ end
+ end
+
+ it "should raise exception for unrecognized" do
+ subject.driver = "bad-driver"
+
+ expect { subject.finalize! }.to raise_error("Require specify driver
bad-driver")
+ end
+ end
+
+ context 'when @connect_via_ssh defined' do
+ defaults = {'driver' => 'qemu', 'id_ssh_key_file' => nil}
+ [
+ [
+ {'connect_via_ssh' => true},
+ 'qemu+ssh://localhost/system?no_verify=1',
+ ],
+ [
+ {'connect_via_ssh' => true, 'username' => 'my_user'},
+ 'qemu+ssh://my_user@localhost/system?no_verify=1',
+ ],
+ [
+ {'connect_via_ssh' => true, 'host' => 'remote_server'},
+ 'qemu+ssh://remote_server/system?no_verify=1',
+ ],
+ ].each do |inputs, output_uri|
+ it "should detect #{inputs}" do
+ inputs.merge(defaults).each do |k, v|
+ subject.instance_variable_set("@#{k}", v)
+ end
+
+ subject.finalize!
+ expect(subject.uri).to eq(output_uri)
+ end
+ end
+ end
+
+ context 'when @id_ssh_key_file defined' do
+ defaults = {'driver' => 'qemu'}
+ [
+ [
+ {},
+ 'qemu:///system?no_verify=1&keyfile=/home/user/.ssh/id_rsa',
+ ],
+ [
+ {'id_ssh_key_file' => '/path/to/keyfile'},
+ 'qemu:///system?no_verify=1&keyfile=/path/to/keyfile',
+ ],
+ ].each do |inputs, output_uri|
+ it "should detect #{inputs}" do
+ inputs.merge(defaults).each do |k, v|
+ subject.instance_variable_set("@#{k}", v)
+ end
+
+ fake_env['HOME'] = '/home/user'
+
+ subject.finalize!
+ expect(subject.uri).to eq(output_uri)
+ end
+ end
+ end
+
+ context 'when @socket defined' do
+ it "should detect @socket set" do
+ subject.socket = '/var/run/libvirt/libvirt-sock'
+ subject.id_ssh_key_file = false
+
+ subject.finalize!
+ expect(subject.uri).to
eq('qemu:///system?no_verify=1&socket=/var/run/libvirt/libvirt-sock')
+ end
+ end
+ end
+ end
+
def assert_invalid
+ subject.finalize!
errors = subject.validate(machine)
raise "No errors: #{errors.inspect}" if errors.values.all?(&:empty?)
end
def assert_valid
+ subject.finalize!
errors = subject.validate(machine)
raise "Errors: #{errors.inspect}" unless errors.values.all?(&:empty?)
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/unit/templates/domain_all_settings.xml
new/spec/unit/templates/domain_all_settings.xml
--- old/spec/unit/templates/domain_all_settings.xml 2020-05-12
11:05:44.000000000 +0200
+++ new/spec/unit/templates/domain_all_settings.xml 2020-10-03
22:20:38.000000000 +0200
@@ -1,5 +1,7 @@
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name></name>
+ <title>title</title>
+ <description>description</description>
<uuid></uuid>
<memory></memory>
<vcpu cpuset='1-4,^3,6'>1</vcpu>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/unit/templates/domain_custom_cpu_model.xml
new/spec/unit/templates/domain_custom_cpu_model.xml
--- old/spec/unit/templates/domain_custom_cpu_model.xml 2020-05-12
11:05:44.000000000 +0200
+++ new/spec/unit/templates/domain_custom_cpu_model.xml 2020-10-03
22:20:38.000000000 +0200
@@ -1,5 +1,7 @@
<domain type='' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name></name>
+ <title></title>
+ <description></description>
<uuid></uuid>
<memory></memory>
<vcpu>1</vcpu>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/unit/templates/domain_defaults.xml
new/spec/unit/templates/domain_defaults.xml
--- old/spec/unit/templates/domain_defaults.xml 2020-05-12 11:05:44.000000000
+0200
+++ new/spec/unit/templates/domain_defaults.xml 2020-10-03 22:20:38.000000000
+0200
@@ -1,5 +1,7 @@
<domain type='' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name></name>
+ <title></title>
+ <description></description>
<uuid></uuid>
<memory></memory>
<vcpu>1</vcpu>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/unit/templates/domain_spec.rb
new/spec/unit/templates/domain_spec.rb
--- old/spec/unit/templates/domain_spec.rb 2020-05-12 11:05:44.000000000
+0200
+++ new/spec/unit/templates/domain_spec.rb 2020-10-03 22:20:38.000000000
+0200
@@ -27,6 +27,8 @@
context 'when all settings enabled' do
before do
+ domain.title = 'title'
+ domain.description = 'description'
domain.instance_variable_set('@domain_type', 'kvm')
domain.cpu_mode = 'custom'
domain.cpu_feature(name: 'AAA', policy: 'required')