Add config for FreeBSD guest plugin. Allow device to be configurable

This commit is contained in:
Doug Stevenson 2014-02-10 12:43:59 -08:00 committed by Mitchell Hashimoto
parent 0dc40e1680
commit cc343d1a7d
3 changed files with 20 additions and 3 deletions

View File

@ -13,7 +13,8 @@ module VagrantPlugins
machine.communicate.sudo("sed -i '' -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf", {:shell => "sh"})
networks.each do |network|
entry = TemplateRenderer.render("guests/freebsd/network_#{network[:type]}",
device = "#{machine.config.freebsd.device}#{network[:interface]}"
entry = TemplateRenderer.render("guests/freebsd/network_#{network[:type]}",
:options => network)
# Write the entry to a temporary location
@ -27,9 +28,9 @@ module VagrantPlugins
machine.communicate.sudo("rm /tmp/vagrant-network-entry", {:shell => "sh"})
if network[:type].to_sym == :static
machine.communicate.sudo("ifconfig em#{network[:interface]} inet #{network[:ip]} netmask #{network[:netmask]}", {:shell => "sh"})
machine.communicate.sudo("ifconfig #{device} inet #{network[:ip]} netmask #{network[:netmask]}", {:shell => "sh"})
elsif network[:type].to_sym == :dhcp
machine.communicate.sudo("dhclient em#{network[:interface]}", {:shell => "sh"})
machine.communicate.sudo("dhclient #{device}", {:shell => "sh"})
end
end
end

View File

@ -0,0 +1,11 @@
module VagrantPlugins
module GuestFreeBSD
class Config < Vagrant.plugin("2", :config)
attr_accessor :device
def initialize
@device = "em"
end
end
end
end

View File

@ -6,6 +6,11 @@ module VagrantPlugins
name "FreeBSD guest"
description "FreeBSD guest support."
config("freebsd") do
require File.expand_path("../config", __FILE__)
Config
end
guest("freebsd") do
require File.expand_path("../guest", __FILE__)
Guest