Remove old `forward_port` method for configuration. Use `network`
This commit is contained in:
parent
cf2c5a10c1
commit
5c950d8200
|
@ -14,9 +14,11 @@ Vagrant.configure("2") do |config|
|
|||
config.vm.auto_port_range = (2200..2250)
|
||||
config.vm.box_url = nil
|
||||
config.vm.base_mac = nil
|
||||
config.vm.forward_port 22, 2222, :name => "ssh", :auto => true
|
||||
config.vm.guest = :linux
|
||||
|
||||
# Share SSH locally by default
|
||||
config.vm.network :forwarded_port, 22, 2222, :id => "ssh", :auto => true
|
||||
|
||||
# Share the root folder. This can then be overridden by
|
||||
# other Vagrantfiles, if they wish.
|
||||
config.vm.share_folder("v-root", "/vagrant", ".")
|
||||
|
|
|
@ -107,7 +107,7 @@ module VagrantPlugins
|
|||
guestport = options.delete(:guestport)
|
||||
hostport = options.delete(:hostport)
|
||||
|
||||
new.vm.forward_port(guestport, hostport, options)
|
||||
new.vm.network(:forwarded_port, guestport, hostport, options)
|
||||
end
|
||||
|
||||
# Re-define all networks.
|
||||
|
|
|
@ -45,17 +45,6 @@ module VagrantPlugins
|
|||
result
|
||||
end
|
||||
|
||||
def forward_port(guestport, hostport, options=nil)
|
||||
@forwarded_ports << {
|
||||
:name => "#{guestport.to_s(32)}-#{hostport.to_s(32)}",
|
||||
:guestport => guestport,
|
||||
:hostport => hostport,
|
||||
:protocol => :tcp,
|
||||
:adapter => 1,
|
||||
:auto => false
|
||||
}.merge(options || {})
|
||||
end
|
||||
|
||||
def share_folder(name, guestpath, hostpath, opts=nil)
|
||||
@shared_folders[name] = {
|
||||
:guestpath => guestpath.to_s,
|
||||
|
@ -69,6 +58,21 @@ module VagrantPlugins
|
|||
}.merge(opts || {})
|
||||
end
|
||||
|
||||
# Define a way to access the machine via a network. This exposes a
|
||||
# high-level abstraction for networking that may not directly map
|
||||
# 1-to-1 for every provider. For example, AWS has no equivalent to
|
||||
# "port forwarding." But most providers will attempt to implement this
|
||||
# in a way that behaves similarly.
|
||||
#
|
||||
# `type` can be one of:
|
||||
#
|
||||
# * `:forwarded_port` - A port that is accessible via localhost
|
||||
# that forwards into the machine.
|
||||
# * `:private_network` - The machine gets an IP that is not directly
|
||||
# publicly accessible, but ideally accessible from this machine.
|
||||
# * `:public_network` - The machine gets an IP on a shared network.
|
||||
#
|
||||
# @param [Symbol] type Type of network
|
||||
def network(type, *args)
|
||||
@networks << [type, args]
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue