Update to 0.0.31

This commit is contained in:
Josef Stribny 2015-10-05 16:08:37 +02:00
parent d12f1ab87c
commit 8472fef622
4 changed files with 9 additions and 79 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
/vagrant-libvirt-0.0.25.gem
/vagrant-libvirt-0.0.26.gem
/vagrant-libvirt-0.0.30.gem
/vagrant-libvirt-0.0.31.gem

View File

@ -1 +1 @@
c4c953ced538dd2c4e90116b676728dd vagrant-libvirt-0.0.30.gem
222c00400ef56df952504b9910e79aeb vagrant-libvirt-0.0.31.gem

View File

@ -1,69 +0,0 @@
From ee7afab369dc7e80128ff35a2ff11f6eab23d368 Mon Sep 17 00:00:00 2001
From: Dan Williams <dcbw@redhat.com>
Date: Tue, 30 Jun 2015 16:24:30 -0500
Subject: [PATCH] Read MAC address from libvirt and pass up to Vagrant
Configuring networks based solely on slot numbers doesn't work very
well, since there's no way to guarantee that the interface Vagrant
finds is the same one that vagrant-libvirt created at that index.
For example, Vagrant's Fedora configure_networks action does this:
machine.communicate.sudo("ls /sys/class/net | grep -v lo") do |_, result|
interface_names = result.split("\n")
end
interface_names = networks.map do |network|
"#{interface_names[network[:interface]]}"
end
which means that if your image has 'docker' pre-installed, then
interface_names[0] = "docker0" and hilarity ensues, with the first
non-management network being assigned to the vagrant-libvirt
management interface.
Since interface names are very unreliable (they can be renamed by
udev at will or when hardware changes) the only way to ensure that
the interface vagrant-libvirt attaches to the domain maps to the
correct one inside the VM is by MAC address. Pull the MAC address
out of the libvirt config once the interface has been attached and
pass that up to Vagrant so we have a chance of doing the right thing.
---
lib/vagrant-libvirt/action/create_network_interfaces.rb | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/lib/vagrant-libvirt/action/create_network_interfaces.rb b/lib/vagrant-libvirt/action/create_network_interfaces.rb
index 35886ad..cbe7562 100644
--- a/lib/vagrant-libvirt/action/create_network_interfaces.rb
+++ b/lib/vagrant-libvirt/action/create_network_interfaces.rb
@@ -96,6 +96,21 @@ def call(env)
raise Errors::AttachDeviceError,
:error_message => e.message
end
+
+ # Re-read the network configuration and grab the MAC address
+ if !@mac
+ xml = Nokogiri::XML(domain.xml_desc)
+ if iface_configuration[:iface_type] == :public_network
+ if @type == 'direct'
+ @mac = xml.xpath("/domain/devices/interface[source[@dev='#{@device}']]/mac/@address")
+ else
+ @mac = xml.xpath("/domain/devices/interface[source[@bridge='#{@device}']]/mac/@address")
+ end
+ else
+ @mac = xml.xpath("/domain/devices/interface[source[@network='#{@network_name}']]/mac/@address")
+ end
+ iface_configuration[:mac] = @mac.to_s
+ end
end
# Continue the middleware chain.
@@ -116,7 +131,7 @@ def call(env)
network = {
:interface => slot_number,
:use_dhcp_assigned_default_route => options[:use_dhcp_assigned_default_route],
- #:mac => ...,
+ :mac_address => options[:mac],
}
if options[:ip]

View File

@ -1,8 +1,8 @@
%global vagrant_plugin_name vagrant-libvirt
Name: %{vagrant_plugin_name}
Version: 0.0.30
Release: 5%{?dist}
Version: 0.0.31
Release: 1%{?dist}
Summary: libvirt provider for Vagrant
Group: Development/Languages
License: MIT
@ -10,10 +10,6 @@ URL: https://github.com/pradels/vagrant-libvirt
Source0: https://rubygems.org/gems/%{vagrant_plugin_name}-%{version}.gem
Source1: 10-vagrant-libvirt.rules
# Pass MAC addresses up to vagrant to ensure interfaces are configured correctly
# https://github.com/pradels/vagrant-libvirt/pull/408
Patch0: vagrant-libvirt-match-interface-by-mac.patch
Requires(pre): shadow-utils
Requires(posttrans): vagrant
Requires(preun): vagrant
@ -50,8 +46,6 @@ gem unpack %{SOURCE0}
gem spec %{SOURCE0} -l --ruby > %{vagrant_plugin_name}.gemspec
%patch0 -p1
%build
gem build %{vagrant_plugin_name}.gemspec
%vagrant_plugin_install
@ -69,7 +63,7 @@ install -m 0644 %{SOURCE1} %{buildroot}%{vagrant_plugin_docdir}/polkit
%check
pushd .%{vagrant_plugin_instdir}
sed -i '/:git/ s|:git.*$|:path => "%{vagrant_dir}"|' Gemfile
sed -i '14s|:git.*$|:path => "%{vagrant_dir}"|' Gemfile
sed -i '/pry/d' Gemfile
sed -i '10igem "rspec", "~> 2.0"' Gemfile
sed -i '/rspec/ s|\[\".*\"]|["~> 2.0"]|' vagrant-libvirt.gemspec
@ -95,6 +89,7 @@ getent group vagrant >/dev/null || groupadd -r vagrant
%{vagrant_plugin_instdir}/tools
%exclude %{vagrant_plugin_cache}
%exclude %{vagrant_plugin_instdir}/.gitignore
%exclude %{vagrant_plugin_instdir}/.travis.yml
%{vagrant_plugin_spec}
# polkit
# TODO: Disabled for now, since this might have security implications.
@ -111,6 +106,9 @@ getent group vagrant >/dev/null || groupadd -r vagrant
%changelog
* Mon Oct 05 2015 Josef Stribny <jstribny@redhat.com> - 0.0.31-1
- Update to 0.0.31
* Mon Sep 14 2015 Josef Stribny <jstribny@redhat.com> - 0.0.30-5
- Drop the rest of libvirt deps, they should be pulled via ruby-libvirt