Fixes Fedora 20 network issues when virtual
On Fedora 20 virtual machines biosdevname command 'Returns 4 if running in a virtual machine.' This patch: - Uses the biosdevname command return value to detect if virtual - Uses /sys/net to get interface names - Might be better solution - Leaves unchanged the original 'bare metal' case - I wonder what for though? Tested with Fedora Cloud image adapted for vagrant-libvirt Fixes issue #4104
This commit is contained in:
parent
1615325e46
commit
bd4d4284c4
|
@ -14,25 +14,40 @@ module VagrantPlugins
|
||||||
def self.configure_networks(machine, networks)
|
def self.configure_networks(machine, networks)
|
||||||
network_scripts_dir = machine.guest.capability("network_scripts_dir")
|
network_scripts_dir = machine.guest.capability("network_scripts_dir")
|
||||||
|
|
||||||
|
virtual = false
|
||||||
interface_names = Array.new
|
interface_names = Array.new
|
||||||
machine.communicate.sudo("/usr/sbin/biosdevname -d | grep Kernel | cut -f2 -d: | sed -e 's/ //;'") do |_, result|
|
machine.communicate.sudo("/usr/sbin/biosdevname; echo $?") do |_, result|
|
||||||
interface_names = result.split("\n")
|
virtual = true if result.chomp == '4'
|
||||||
end
|
end
|
||||||
|
|
||||||
interface_name_pairs = Array.new
|
if virtual
|
||||||
interface_names.each do |interface_name|
|
machine.communicate.sudo("ls /sys/class/net | grep -v lo") do |_, result|
|
||||||
machine.communicate.sudo("/usr/sbin/biosdevname --policy=all_ethN -i #{interface_name}") do |_, result|
|
interface_names = result.split("\n")
|
||||||
interface_name_pairs.push([interface_name, result.gsub("\n", "")])
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
setting_interface_names = networks.map do |network|
|
interface_names = networks.map do |network|
|
||||||
"eth#{network[:interface]}"
|
"eth#{network[:interface]}"
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
machine.communicate.sudo("/usr/sbin/biosdevname -d | grep Kernel | cut -f2 -d: | sed -e 's/ //;'") do |_, result|
|
||||||
|
interface_names = result.split("\n")
|
||||||
|
end
|
||||||
|
|
||||||
interface_name_pairs.each do |interface_name, previous_interface_name|
|
interface_name_pairs = Array.new
|
||||||
if setting_interface_names.index(previous_interface_name) == nil
|
interface_names.each do |interface_name|
|
||||||
interface_names.delete(interface_name)
|
machine.communicate.sudo("/usr/sbin/biosdevname --policy=all_ethN -i #{interface_name}") do |_, result|
|
||||||
|
interface_name_pairs.push([interface_name, result.gsub("\n", "")])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
setting_interface_names = networks.map do |network|
|
||||||
|
"eth#{network[:interface]}"
|
||||||
|
end
|
||||||
|
|
||||||
|
interface_name_pairs.each do |interface_name, previous_interface_name|
|
||||||
|
if setting_interface_names.index(previous_interface_name) == nil
|
||||||
|
interface_names.delete(interface_name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue