From c586999a0ba3421d17f9f0cbeae6c70ba2ad7a36 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 1 Mar 2013 17:02:53 -0800 Subject: [PATCH] Properly scope network configs by type --- plugins/kernel_v2/config/vm.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 834db3ab4..ed2ae37ee 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -97,8 +97,17 @@ module VagrantPlugins def network(type, options=nil) options ||= {} id = options[:id] || SecureRandom.uuid - @__networks[id] ||= {} - @__networks[id].merge!(options) + + # Scope the ID by type so that different types can share IDs + id = "#{type}-#{id}" + + # Merge in the previous settings if we have them. + if @__networks.has_key?(id) + options = @__networks[id][1].merge(options) + end + + # Merge in the latest settings and set the internal state + @__networks[id] ||= [type, options] end # Configures a provider for this VM. @@ -193,7 +202,7 @@ module VagrantPlugins # This returns the list of networks configured. def networks - @__networks.dup + @__networks.values end def validate(machine)