2013-01-11 23:52:45 +00:00
|
|
|
require "vagrant/util/scoped_hash_override"
|
|
|
|
|
2013-01-11 22:44:27 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module ProviderVirtualBox
|
|
|
|
module Util
|
|
|
|
module CompileForwardedPorts
|
2013-01-11 23:52:45 +00:00
|
|
|
include Vagrant::Util::ScopedHashOverride
|
|
|
|
|
2013-01-11 22:44:27 +00:00
|
|
|
# This method compiles the forwarded ports into {ForwardedPort}
|
|
|
|
# models.
|
|
|
|
def compile_forwarded_ports(config)
|
|
|
|
mappings = {}
|
|
|
|
|
|
|
|
config.vm.networks.each do |type, args|
|
|
|
|
if type == :forwarded_port
|
|
|
|
guest_port = args[0]
|
|
|
|
host_port = args[1]
|
|
|
|
options = args[2] || {}
|
2013-01-11 23:52:45 +00:00
|
|
|
options = scoped_hash_override(options, :virtualbox)
|
2013-01-11 22:44:27 +00:00
|
|
|
id = options[:id] ||
|
|
|
|
"#{guest_port.to_s(32)}-#{host_port.to_s(32)}"
|
|
|
|
|
|
|
|
mappings[host_port] =
|
|
|
|
Model::ForwardedPort.new(id, host_port, guest_port, options)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
mappings.values
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|