From 28c377848fd25a8ced63a5537ace384920e3363d Mon Sep 17 00:00:00 2001 From: Scott Sanders Date: Fri, 27 Jan 2012 20:19:15 +0000 Subject: [PATCH] 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. --- lib/vagrant/guest/freebsd.rb | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/vagrant/guest/freebsd.rb b/lib/vagrant/guest/freebsd.rb index 00a97db19..4073a53b5 100644 --- a/lib/vagrant/guest/freebsd.rb +++ b/lib/vagrant/guest/freebsd.rb @@ -53,23 +53,18 @@ module Vagrant end end - def prepare_host_only_network(net_options=nil) + def configure_networks(networks) # 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-HOSTONLY/,/^#VAGRANT-END-HOSTONLY/ d' /etc/rc.conf > /tmp/rc.conf") - ssh.exec!("sudo mv /tmp/rc.conf /etc/rc.conf") - end - end + vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN-HOSTONLY/,/^#VAGRANT-END-HOSTONLY/ d' /etc/rc.conf > /tmp/rc.conf") + vm.channel.sudo("mv /tmp/rc.conf /etc/rc.conf") - def enable_host_only_network(net_options) - entry = "#VAGRANT-BEGIN-HOSTONLY\nifconfig_em#{net_options[:adapter]}=\"inet #{net_options[:ip]} netmask #{net_options[:netmask]}\"\n#VAGRANT-END-HOSTONLY\n" - vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry") + networks.each do |network| + entry = "#VAGRANT-BEGIN-HOSTONLY\nifconfig_em#{network[:interface]}=\"inet #{network[:ip]} netmask #{network[:netmask]}\"\n#VAGRANT-END-HOSTONLY\n" + vm.channel.upload(StringIO.new(entry), "/tmp/vagrant-network-entry") - vm.ssh.execute do |ssh| - ssh.exec!("sudo su -m root -c 'cat /tmp/vagrant-network-entry >> /etc/rc.conf'") - ssh.exec!("sudo ifconfig em#{net_options[:adapter]} inet #{net_options[:ip]} netmask #{net_options[:netmask]}") + vm.channel.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]}") end end end