Automatically override forwarded ports if host ports match

This commit is contained in:
Mitchell Hashimoto 2013-04-10 15:37:04 -07:00
parent c4422d7198
commit e64696e839
2 changed files with 15 additions and 1 deletions

View File

@ -56,6 +56,8 @@ IMPROVEMENTS:
- Shared folders with the same guest path will overwrite each other. No
more shared folder IDs.
- Shell provisioner outputs script it is running. [GH-1568]
- Automatically merge forwarded ports that share the same host
port.
BUG FIXES:

View File

@ -133,9 +133,21 @@ module VagrantPlugins
# @param [Hash] options Options for the network.
def network(type, options=nil)
options ||= {}
id = options[:id] || SecureRandom.uuid
if !options[:id]
default_id = nil
if type == :forwarded_port
# For forwarded ports, set the default ID to the
# host port so that host ports overwrite each other.
default_id = options[:host]
end
options[:id] = default_id || SecureRandom.uuid
end
# Scope the ID by type so that different types can share IDs
id = options[:id]
id = "#{type}-#{id}"
# Merge in the previous settings if we have them.