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.auto_port_range = (2200..2250)
|
||||||
config.vm.box_url = nil
|
config.vm.box_url = nil
|
||||||
config.vm.base_mac = nil
|
config.vm.base_mac = nil
|
||||||
config.vm.forward_port 22, 2222, :name => "ssh", :auto => true
|
|
||||||
config.vm.guest = :linux
|
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
|
# Share the root folder. This can then be overridden by
|
||||||
# other Vagrantfiles, if they wish.
|
# other Vagrantfiles, if they wish.
|
||||||
config.vm.share_folder("v-root", "/vagrant", ".")
|
config.vm.share_folder("v-root", "/vagrant", ".")
|
||||||
|
|
|
@ -107,7 +107,7 @@ module VagrantPlugins
|
||||||
guestport = options.delete(:guestport)
|
guestport = options.delete(:guestport)
|
||||||
hostport = options.delete(:hostport)
|
hostport = options.delete(:hostport)
|
||||||
|
|
||||||
new.vm.forward_port(guestport, hostport, options)
|
new.vm.network(:forwarded_port, guestport, hostport, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Re-define all networks.
|
# Re-define all networks.
|
||||||
|
|
|
@ -45,17 +45,6 @@ module VagrantPlugins
|
||||||
result
|
result
|
||||||
end
|
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)
|
def share_folder(name, guestpath, hostpath, opts=nil)
|
||||||
@shared_folders[name] = {
|
@shared_folders[name] = {
|
||||||
:guestpath => guestpath.to_s,
|
:guestpath => guestpath.to_s,
|
||||||
|
@ -69,6 +58,21 @@ module VagrantPlugins
|
||||||
}.merge(opts || {})
|
}.merge(opts || {})
|
||||||
end
|
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)
|
def network(type, *args)
|
||||||
@networks << [type, args]
|
@networks << [type, args]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue