Rework v1 forward_port call to append forward port networks
This commit is contained in:
parent
7a9363e8a1
commit
8299ac38bd
|
@ -1,5 +1,3 @@
|
||||||
require "pathname"
|
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module Kernel_V1
|
module Kernel_V1
|
||||||
# This is the Version 1.0.x Vagrant VM configuration. This is
|
# This is the Version 1.0.x Vagrant VM configuration. This is
|
||||||
|
@ -17,13 +15,11 @@ module VagrantPlugins
|
||||||
attr_accessor :guest
|
attr_accessor :guest
|
||||||
attr_accessor :host_name
|
attr_accessor :host_name
|
||||||
attr_reader :customizations
|
attr_reader :customizations
|
||||||
attr_reader :forwarded_ports
|
|
||||||
attr_reader :networks
|
attr_reader :networks
|
||||||
attr_reader :provisioners
|
attr_reader :provisioners
|
||||||
attr_reader :shared_folders
|
attr_reader :shared_folders
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@forwarded_ports = []
|
|
||||||
@shared_folders = {}
|
@shared_folders = {}
|
||||||
@networks = []
|
@networks = []
|
||||||
@provisioners = []
|
@provisioners = []
|
||||||
|
@ -32,14 +28,13 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def forward_port(guestport, hostport, options=nil)
|
def forward_port(guestport, hostport, options=nil)
|
||||||
@forwarded_ports << {
|
# Build up the network options for V2
|
||||||
:name => "#{guestport.to_s(32)}-#{hostport.to_s(32)}",
|
network_options = {}
|
||||||
:guestport => guestport,
|
network_options[:virtualbox__adapter] = options[:adapter]
|
||||||
:hostport => hostport,
|
network_options[:virtualbox__protocol] = options[:protocol]
|
||||||
:protocol => :tcp,
|
|
||||||
:adapter => 1,
|
# Just append the forwarded port to the networks
|
||||||
:auto => false
|
@networks << [:forwarded_port, guestport, hostport, network_options]
|
||||||
}.merge(options || {})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def share_folder(name, guestpath, hostpath, opts=nil)
|
def share_folder(name, guestpath, hostpath, opts=nil)
|
||||||
|
@ -101,15 +96,6 @@ module VagrantPlugins
|
||||||
new.vm.providers[:virtualbox].config.customize(customization)
|
new.vm.providers[:virtualbox].config.customize(customization)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Take all the defined forwarded ports and re-define them
|
|
||||||
self.forwarded_ports.each do |fp|
|
|
||||||
options = fp.dup
|
|
||||||
guestport = options.delete(:guestport)
|
|
||||||
hostport = options.delete(:hostport)
|
|
||||||
|
|
||||||
new.vm.network(:forwarded_port, guestport, hostport, options)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Re-define all networks.
|
# Re-define all networks.
|
||||||
self.networks.each do |type, args|
|
self.networks.each do |type, args|
|
||||||
new.vm.network(type, *args)
|
new.vm.network(type, *args)
|
||||||
|
|
Loading…
Reference in New Issue