From 102e8f23d63bd150d3784f516dc2eca7d2cc94b2 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 11 Jan 2013 15:50:09 -0800 Subject: [PATCH] Use scoped hash overrides for high-level config --- lib/vagrant/util/scoped_hash_override.rb | 5 +++++ plugins/providers/virtualbox/action/network.rb | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/vagrant/util/scoped_hash_override.rb b/lib/vagrant/util/scoped_hash_override.rb index ebb778799..ec4eb180d 100644 --- a/lib/vagrant/util/scoped_hash_override.rb +++ b/lib/vagrant/util/scoped_hash_override.rb @@ -18,6 +18,11 @@ module Vagrant # module ScopedHashOverride def scoped_hash_override(original, scope) + # Convert the scope to a string in case a symbol was given since + # we use string comparisons for everything. + scope = scope.to_s + + # Shallow copy the hash for the result result = original.dup original.each do |key, value| diff --git a/plugins/providers/virtualbox/action/network.rb b/plugins/providers/virtualbox/action/network.rb index 3a807cf06..cb157020b 100644 --- a/plugins/providers/virtualbox/action/network.rb +++ b/plugins/providers/virtualbox/action/network.rb @@ -3,6 +3,7 @@ require "set" require "log4r" require "vagrant/util/network_ip" +require "vagrant/util/scoped_hash_override" module VagrantPlugins module ProviderVirtualBox @@ -14,6 +15,7 @@ module VagrantPlugins # This handles all the `config.vm.network` configurations. class Network include Vagrant::Util::NetworkIP + include Vagrant::Util::ScopedHashOverride def initialize(app, env) @logger = Log4r::Logger.new("vagrant::plugins::virtualbox::network") @@ -43,9 +45,10 @@ module VagrantPlugins options = nil options = args.last if args.last.is_a?(Hash) options ||= {} + options = scoped_hash_override(options, :virtualbox) # Figure out the slot that this adapter will go into - slot = options[:virtualbox__adapter] + slot = options[:adapter] if !slot if available_slots.empty? # TODO: Error that we have no room for this adapter @@ -59,13 +62,13 @@ module VagrantPlugins if type == :private_network # private_network = hostonly - config_args = [args[0]] - data = [:hostonly, config_args] + config_args = [args[0], options] + data = [:hostonly, config_args] elsif type == :public_network # public_network = bridged - config_args = [] - data = [:bridged, config_args] + config_args = [options] + data = [:bridged, config_args] end # Store it!