Update FreeBSD guest to support networking

The latest update to 0.9.x broke FreeBSD networking. This patch fixes
things by moving the code into the right method.
This commit is contained in:
Scott Sanders 2012-01-27 20:19:15 +00:00 committed by Mitchell Hashimoto
parent ce659a7f7d
commit 28c377848f
1 changed files with 8 additions and 13 deletions

View File

@ -53,23 +53,18 @@ module Vagrant
end end
end end
def prepare_host_only_network(net_options=nil) def configure_networks(networks)
# Remove any previous host only network additions to the # Remove any previous host only network additions to the
# interface file. # interface file.
vm.ssh.execute do |ssh| vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN-HOSTONLY/,/^#VAGRANT-END-HOSTONLY/ d' /etc/rc.conf > /tmp/rc.conf")
# Clear out any previous entries vm.channel.sudo("mv /tmp/rc.conf /etc/rc.conf")
ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN-HOSTONLY/,/^#VAGRANT-END-HOSTONLY/ d' /etc/rc.conf > /tmp/rc.conf")
ssh.exec!("sudo mv /tmp/rc.conf /etc/rc.conf")
end
end
def enable_host_only_network(net_options) networks.each do |network|
entry = "#VAGRANT-BEGIN-HOSTONLY\nifconfig_em#{net_options[:adapter]}=\"inet #{net_options[:ip]} netmask #{net_options[:netmask]}\"\n#VAGRANT-END-HOSTONLY\n" entry = "#VAGRANT-BEGIN-HOSTONLY\nifconfig_em#{network[:interface]}=\"inet #{network[:ip]} netmask #{network[:netmask]}\"\n#VAGRANT-END-HOSTONLY\n"
vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry") vm.channel.upload(StringIO.new(entry), "/tmp/vagrant-network-entry")
vm.ssh.execute do |ssh| vm.channel.sudo("su -m root -c 'cat /tmp/vagrant-network-entry >> /etc/rc.conf'")
ssh.exec!("sudo su -m root -c 'cat /tmp/vagrant-network-entry >> /etc/rc.conf'") vm.channel.sudo("ifconfig em#{network[:interface]} inet #{network[:ip]} netmask #{network[:netmask]}")
ssh.exec!("sudo ifconfig em#{net_options[:adapter]} inet #{net_options[:ip]} netmask #{net_options[:netmask]}")
end end
end end
end end