re-implemented redhat distribution of host only network with additional check to see if network interface is up as on intial setup when not using dhcp the interface will be down as dhcp lookup will time out. To prevent vagrant time out on boot you need to add file /etc/dhclient.conf with value content timeout 1; to guest this is beacuse the default is 60 seconds this should be done in the base box

This commit is contained in:
Michael Bearne 2011-01-10 17:15:15 +00:00
parent 8b6d63ab58
commit eda6b81093
7 changed files with 11 additions and 8 deletions

View File

@ -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

View File

@ -6,3 +6,4 @@ require 'vagrant/systems/solaris'
require 'vagrant/systems/debian'
require 'vagrant/systems/gentoo'
require 'vagrant/systems/redhat'

View File

@ -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

View File

@ -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|

View File

@ -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|

View File

@ -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

View File

@ -60,6 +60,7 @@ module Vagrant
mapping = {
:debian => Systems::Debian,
:gentoo => Systems::Gentoo,
:redhat => Systems::Redhat,
:linux => Systems::Linux,
:solaris => Systems::Solaris
}