Revert "Merge pull request #3643 from cammoraton/rhel7-plugin-fixes"
This reverts commit919d0b9f4b
, reversing changes made to924c47feb3
.
This commit is contained in:
parent
7e6ba7fa50
commit
e7a5dc4f8e
|
@ -13,27 +13,28 @@ 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")
|
||||||
interface_names = machine.guest.capability("interfaces_list")
|
|
||||||
|
|
||||||
# Accumulate the configurations to add to the interfaces file as
|
# Accumulate the configurations to add to the interfaces file as
|
||||||
# well as what interfaces we're actually configuring since we use that
|
# well as what interfaces we're actually configuring since we use that
|
||||||
# later.
|
# later.
|
||||||
interfaces = Set.new
|
interfaces = Set.new
|
||||||
networks.each do |network|
|
networks.each do |network|
|
||||||
interface = interface_names[network[:interface]]
|
interfaces.add(network[:interface])
|
||||||
interfaces.add(interface)
|
|
||||||
network[:device] = interface
|
# Down the interface before munging the config file. This might fail
|
||||||
|
# if the interface is not actually set up yet so ignore errors.
|
||||||
|
machine.communicate.sudo(
|
||||||
|
"/sbin/ifdown eth#{network[:interface]} 2> /dev/null", error_check: false)
|
||||||
|
|
||||||
# Remove any previous vagrant configuration in this network interface's
|
# Remove any previous vagrant configuration in this network interface's
|
||||||
# configuration files.
|
# configuration files.
|
||||||
machine.communicate.sudo("touch #{network_scripts_dir}/ifcfg-#{interface}")
|
machine.communicate.sudo("touch #{network_scripts_dir}/ifcfg-eth#{network[:interface]}")
|
||||||
machine.communicate.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-#{interface} > /tmp/vagrant-ifcfg-#{interface}")
|
machine.communicate.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-eth#{network[:interface]} > /tmp/vagrant-ifcfg-eth#{network[:interface]}")
|
||||||
machine.communicate.sudo("cat /tmp/vagrant-ifcfg-#{interface} > #{network_scripts_dir}/ifcfg-#{interface}")
|
machine.communicate.sudo("cat /tmp/vagrant-ifcfg-eth#{network[:interface]} > #{network_scripts_dir}/ifcfg-eth#{network[:interface]}")
|
||||||
machine.communicate.sudo("rm /tmp/vagrant-ifcfg-#{interface}")
|
machine.communicate.sudo("rm -f /tmp/vagrant-ifcfg-eth#{network[:interface]}")
|
||||||
|
|
||||||
# Render and upload the network entry file to a deterministic
|
# Render and upload the network entry file to a deterministic
|
||||||
# temporary location.
|
# temporary location.
|
||||||
# use fedora for now
|
|
||||||
entry = TemplateRenderer.render("guests/redhat/network_#{network[:type]}",
|
entry = TemplateRenderer.render("guests/redhat/network_#{network[:type]}",
|
||||||
:options => network)
|
:options => network)
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ module VagrantPlugins
|
||||||
temp.write(entry)
|
temp.write(entry)
|
||||||
temp.close
|
temp.close
|
||||||
|
|
||||||
machine.communicate.upload(temp.path, "/tmp/vagrant-network-entry_#{interface}")
|
machine.communicate.upload(temp.path, "/tmp/vagrant-network-entry_#{network[:interface]}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Bring down all the interfaces we're reconfiguring. By bringing down
|
# Bring down all the interfaces we're reconfiguring. By bringing down
|
||||||
|
@ -50,11 +51,17 @@ module VagrantPlugins
|
||||||
# SSH never dies.
|
# SSH never dies.
|
||||||
interfaces.each do |interface|
|
interfaces.each do |interface|
|
||||||
retryable(:on => Vagrant::Errors::VagrantError, :tries => 3, :sleep => 2) do
|
retryable(:on => Vagrant::Errors::VagrantError, :tries => 3, :sleep => 2) do
|
||||||
machine.communicate.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-#{interface}")
|
# The interface should already be down so this probably
|
||||||
machine.communicate.sudo("/sbin/ifdown #{interface}", :error_check => true)
|
# won't do anything, so we run it with error_check false.
|
||||||
machine.communicate.sudo("/sbin/ifup #{interface}")
|
machine.communicate.sudo(
|
||||||
|
"/sbin/ifdown eth#{interface} 2> /dev/null", error_check: false)
|
||||||
|
|
||||||
|
# Add the new interface and bring it up
|
||||||
|
machine.communicate.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-eth#{interface}")
|
||||||
|
machine.communicate.sudo("ARPCHECK=no /sbin/ifup eth#{interface} 2> /dev/null")
|
||||||
end
|
end
|
||||||
machine.communicate.sudo("rm /tmp/vagrant-network-entry_#{interface}")
|
|
||||||
|
machine.communicate.sudo("rm -f /tmp/vagrant-network-entry_#{interface}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
module VagrantPlugins
|
|
||||||
module GuestRedHat
|
|
||||||
module Cap
|
|
||||||
class InterfacesList
|
|
||||||
def self.interfaces_list(machine)
|
|
||||||
version = String.new
|
|
||||||
machine.communicate.sudo("cat /etc/redhat-release | sed -e 's/.*release\ //' | cut -f1 -d' '") do |_, result|
|
|
||||||
# Only care about the major version for now
|
|
||||||
version = result.split('.').first
|
|
||||||
end
|
|
||||||
|
|
||||||
interface_names = Array.new
|
|
||||||
|
|
||||||
# In theory this would work with even older versions as dmesg has been relatively static for a long time
|
|
||||||
if version.to_i < 6
|
|
||||||
machine.communicate.sudo("dmesg | cut -f2 -d: | sed -e 's/^\ //' | sed -e 's/\ .*$//' | grep eth") do |_, result|
|
|
||||||
# It has two results ? - Quick hack to compensate
|
|
||||||
interface_names = result.split("\n").uniq.sort if interface_names.empty?
|
|
||||||
end
|
|
||||||
else
|
|
||||||
machine.communicate.sudo("biosdevname -d | grep Kernel | cut -f2 -d: | sed -e 's/ //;'") do |_, result|
|
|
||||||
# The previous had two results. This one never has. Do the same check for now.
|
|
||||||
interface_names = result.split("\n") if interface_names.empty?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return interface_names
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -35,11 +35,6 @@ module VagrantPlugins
|
||||||
require_relative "cap/rsync"
|
require_relative "cap/rsync"
|
||||||
Cap::RSync
|
Cap::RSync
|
||||||
end
|
end
|
||||||
|
|
||||||
guest_capability("redhat", "interfaces_list") do
|
|
||||||
require_relative "cap/interfaces_list"
|
|
||||||
Cap::InterfacesList
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
# The contents below are automatically generated by Vagrant. Do not modify.
|
||||||
BOOTPROTO=dhcp
|
BOOTPROTO=dhcp
|
||||||
ONBOOT=yes
|
ONBOOT=yes
|
||||||
DEVICE=<%= options[:device] %>
|
DEVICE=eth<%= options[:interface] %>
|
||||||
#VAGRANT-END
|
#VAGRANT-END
|
||||||
|
|
|
@ -5,6 +5,6 @@ BOOTPROTO=none
|
||||||
ONBOOT=yes
|
ONBOOT=yes
|
||||||
IPADDR=<%= options[:ip] %>
|
IPADDR=<%= options[:ip] %>
|
||||||
NETMASK=<%= options[:netmask] %>
|
NETMASK=<%= options[:netmask] %>
|
||||||
DEVICE=<%= options[:device] %>
|
DEVICE=eth<%= options[:interface] %>
|
||||||
PEERDNS=no
|
PEERDNS=no
|
||||||
#VAGRANT-END
|
#VAGRANT-END
|
||||||
|
|
Loading…
Reference in New Issue