VirtualBox no longer removes network interfaces [GH-1324]

This commit is contained in:
Mitchell Hashimoto 2013-07-23 13:13:11 -07:00
parent aeb0132dcb
commit b2ee015d00
3 changed files with 26 additions and 2 deletions

View File

@ -8,6 +8,11 @@ FEATURES:
- VirtualBox VBoxManage customizations can now be specified to run
pre-boot (the default and existing functionality, pre-import,
or post-boot. [GH-1247]
- VirtualBox no longer destroys unused network interfaces by default.
This didn't work across multi-user systems and required admin privileges
on Windows, so it has been disabled by default. It can be enabled using
the VirtualBox provider-specific `destroy_unused_network_interfaces`
configuration by setting it to true. [GH-1324]
IMPROVEMENTS:

View File

@ -1,14 +1,20 @@
require "log4r"
module VagrantPlugins
module ProviderVirtualBox
module Action
class DestroyUnusedNetworkInterfaces
def initialize(app, env)
@app = app
@logger = Log4r::Logger.new("vagrant::plugins::virtualbox::destroy_unused_netifs")
end
def call(env)
env[:machine].provider.driver.delete_unused_host_only_networks
@app.call(env)
if env[:machine].provider_config.destroy_unused_network_interfaces
@logger.info("Destroying unused network interfaces...")
env[:machine].provider.driver.delete_unused_host_only_networks
@app.call(env)
end
end
end
end

View File

@ -13,6 +13,14 @@ module VagrantPlugins
# @return [Array]
attr_reader :customizations
# If true, unused network interfaces will automatically be deleted.
# This defaults to false because the detection does not work across
# multiple users, and because on Windows this operation requires
# administrative privileges.
#
# @return [Boolean]
attr_accessor :destroy_unused_network_interfaces
# If set to `true`, then VirtualBox will be launched with a GUI.
#
# @return [Boolean]
@ -32,6 +40,7 @@ module VagrantPlugins
def initialize
@auto_nat_dns_proxy = UNSET_VALUE
@customizations = []
@destroy_unused_network_interfaces = UNSET_VALUE
@name = UNSET_VALUE
@network_adapters = {}
@gui = UNSET_VALUE
@ -73,6 +82,10 @@ module VagrantPlugins
# Default is to auto the DNS proxy
@auto_nat_dns_proxy = true if @auto_nat_dns_proxy == UNSET_VALUE
if @destroy_unused_network_interfaces == UNSET_VALUE
@destroy_unused_network_interfaces = false
end
# Default is to not show a GUI
@gui = false if @gui == UNSET_VALUE