From 2057d513cb552e9d6f49f3007547964a1f49feb8 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 11 Apr 2014 16:39:58 -0700 Subject: [PATCH] Update CHANGELOG --- CHANGELOG.md | 3 +-- .../guests/freebsd/cap/configure_networks.rb | 18 ++++++++++++++--- plugins/guests/freebsd/config.rb | 20 ------------------- plugins/guests/freebsd/plugin.rb | 5 ----- .../guests/openbsd/cap/configure_networks.rb | 3 ++- 5 files changed, 18 insertions(+), 31 deletions(-) delete mode 100644 plugins/guests/freebsd/config.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 029be2b25..eecb4d8b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,8 +23,7 @@ FEATURES: IMPROVEMENTS: - commands/ssh-config: Works without a target in multi-machine envs [GH-2844] - - guests/freebsd: Added `config.freebsd.device` setting to set the network - device prefix, defaults to "em". [GH-2956] + - guests/freebsd: Support for virtio interfaces. [GH-3082] - guests/openbsd: Support for virtio interfaces. [GH-3082] PLUGIN AUTHOR CHANGES: diff --git a/plugins/guests/freebsd/cap/configure_networks.rb b/plugins/guests/freebsd/cap/configure_networks.rb index 02b6a21a2..aa299c4aa 100644 --- a/plugins/guests/freebsd/cap/configure_networks.rb +++ b/plugins/guests/freebsd/cap/configure_networks.rb @@ -13,7 +13,19 @@ module VagrantPlugins machine.communicate.sudo("sed -i '' -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf", {:shell => "sh"}) networks.each do |network| - device = "#{machine.config.freebsd.device}#{network[:interface]}" + # Determine the interface prefix... + command = "ifconfig -a | grep -o ^[0-9a-z]*" + result = "" + ifname = "" + machine.communicate.execute(command) do |type, data| + result << data if type == :stdout + if result.split(/\n/).any?{|i| i.match(/vio*/)} + ifname = "vio#{network[:interface]}" + else + ifname = "em#{network[:interface]}" + end + end + entry = TemplateRenderer.render("guests/freebsd/network_#{network[:type]}", :options => network) @@ -28,9 +40,9 @@ module VagrantPlugins machine.communicate.sudo("rm /tmp/vagrant-network-entry", {:shell => "sh"}) if network[:type].to_sym == :static - machine.communicate.sudo("ifconfig #{device} inet #{network[:ip]} netmask #{network[:netmask]}", {:shell => "sh"}) + machine.communicate.sudo("ifconfig #{ifname} inet #{network[:ip]} netmask #{network[:netmask]}", {:shell => "sh"}) elsif network[:type].to_sym == :dhcp - machine.communicate.sudo("dhclient #{device}", {:shell => "sh"}) + machine.communicate.sudo("dhclient #{ifname}", {:shell => "sh"}) end end end diff --git a/plugins/guests/freebsd/config.rb b/plugins/guests/freebsd/config.rb deleted file mode 100644 index 7830fa0e7..000000000 --- a/plugins/guests/freebsd/config.rb +++ /dev/null @@ -1,20 +0,0 @@ -module VagrantPlugins - module GuestFreeBSD - class Config < Vagrant.plugin("2", :config) - # The device prefix for network devices created by Vagrant. - # This defaults to "em" but can be set for example to "vtnet" - # for virtio devices and so on. - # - # @return [String] - attr_accessor :device - - def initialize - @device = UNSET_VALUE - end - - def finalize! - @device = "em" if @device == UNSET_VALUE - end - end - end -end diff --git a/plugins/guests/freebsd/plugin.rb b/plugins/guests/freebsd/plugin.rb index 0e4cf69d9..8136adfdf 100644 --- a/plugins/guests/freebsd/plugin.rb +++ b/plugins/guests/freebsd/plugin.rb @@ -6,11 +6,6 @@ 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 diff --git a/plugins/guests/openbsd/cap/configure_networks.rb b/plugins/guests/openbsd/cap/configure_networks.rb index a5778ebfd..6e64a563b 100644 --- a/plugins/guests/openbsd/cap/configure_networks.rb +++ b/plugins/guests/openbsd/cap/configure_networks.rb @@ -18,10 +18,10 @@ module VagrantPlugins temp.write(entry) temp.close + # Determine the interface prefix... command = "ifconfig -a | grep -o ^[0-9a-z]*" result = "" ifname = "" - machine.communicate.execute(command) do |type, data| result << data if type == :stdout if result.split(/\n/).any?{|i| i.match(/vio*/)} @@ -30,6 +30,7 @@ module VagrantPlugins ifname = "em#{network[:interface]}" end end + machine.communicate.upload(temp.path, "/tmp/vagrant-network-entry") machine.communicate.sudo("mv /tmp/vagrant-network-entry /etc/hostname.#{ifname}")