diff --git a/lib/vagrant/action/vm/network.rb b/lib/vagrant/action/vm/network.rb index b1792724d..afed943cc 100644 --- a/lib/vagrant/action/vm/network.rb +++ b/lib/vagrant/action/vm/network.rb @@ -25,8 +25,8 @@ module Vagrant if enable_network? @env.ui.info I18n.t("vagrant.actions.vm.network.enabling") - @env["vm"].system.prepare_host_only_network @env.env.config.vm.network_options.compact.each do |network_options| + @env["vm"].system.prepare_host_only_network(network_options) @env["vm"].system.enable_host_only_network(network_options) end end diff --git a/lib/vagrant/systems.rb b/lib/vagrant/systems.rb index bd759f737..6f97765b4 100644 --- a/lib/vagrant/systems.rb +++ b/lib/vagrant/systems.rb @@ -6,3 +6,4 @@ require 'vagrant/systems/solaris' require 'vagrant/systems/debian' require 'vagrant/systems/gentoo' +require 'vagrant/systems/redhat' diff --git a/lib/vagrant/systems/base.rb b/lib/vagrant/systems/base.rb index 19c5e8ad9..a869b1a16 100644 --- a/lib/vagrant/systems/base.rb +++ b/lib/vagrant/systems/base.rb @@ -68,7 +68,7 @@ module Vagrant # Prepares the system for host only networks. This is called # once prior to any `enable_host_only_network` calls. - def prepare_host_only_network + def prepare_host_only_network(net_options = nil) raise BaseError, :_key => :unsupported_host_only end diff --git a/lib/vagrant/systems/debian.rb b/lib/vagrant/systems/debian.rb index 660db7cdf..86f03a3eb 100644 --- a/lib/vagrant/systems/debian.rb +++ b/lib/vagrant/systems/debian.rb @@ -1,7 +1,7 @@ module Vagrant module Systems class Debian < Linux - def prepare_host_only_network + def prepare_host_only_network(net_options = nil) # Remove any previous host only network additions to the # interface file. vm.ssh.execute do |ssh| diff --git a/lib/vagrant/systems/gentoo.rb b/lib/vagrant/systems/gentoo.rb index 878bb90b3..fcef90306 100644 --- a/lib/vagrant/systems/gentoo.rb +++ b/lib/vagrant/systems/gentoo.rb @@ -1,7 +1,7 @@ module Vagrant module Systems class Gentoo < Linux - def prepare_host_only_network + def prepare_host_only_network(net_options = nil) # Remove any previous host only network additions to the # interface file. vm.ssh.execute do |ssh| diff --git a/lib/vagrant/systems/redhat.rb b/lib/vagrant/systems/redhat.rb index 069b65545..977acce79 100644 --- a/lib/vagrant/systems/redhat.rb +++ b/lib/vagrant/systems/redhat.rb @@ -1,13 +1,13 @@ module Vagrant module Systems class Redhat < Linux - def prepare_host_only_network(net_options = nil) + def prepare_host_only_network(net_options) # Remove any previous host only network additions to the # interface file. vm.ssh.execute do |ssh| # Clear out any previous entries - #ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]} > /tmp/vagrant-ifcfg-eth#{net_options[:adapter]}") - #ssh.exec!("sudo su -c 'cat /tmp/vagrant-ifcfg-eth#{net_options[:adapter]} > /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]}'") + ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]} > /tmp/vagrant-ifcfg-eth#{net_options[:adapter]}") + ssh.exec!("sudo su -c 'cat /tmp/vagrant-ifcfg-eth#{net_options[:adapter]} > /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]}'") end end @@ -17,7 +17,8 @@ module Vagrant vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry") vm.ssh.execute do |ssh| - ssh.exec!("sudo /sbin/ifdown eth#{net_options[:adapter]} 2> /dev/null") + interface_up = ssh.test?("/sbin/ifconfig eth#{net_options[:adapter]} | grep 'inet addr:'") + ssh.exec!("sudo /sbin/ifdown eth#{net_options[:adapter]} 2> /dev/null") if interface_up ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-entry >> /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]}'") ssh.exec!("sudo /sbin/ifup eth#{net_options[:adapter]}") end diff --git a/lib/vagrant/vm.rb b/lib/vagrant/vm.rb index b192c4ce6..ff29c6dcc 100644 --- a/lib/vagrant/vm.rb +++ b/lib/vagrant/vm.rb @@ -60,6 +60,7 @@ module Vagrant mapping = { :debian => Systems::Debian, :gentoo => Systems::Gentoo, + :redhat => Systems::Redhat, :linux => Systems::Linux, :solaris => Systems::Solaris }