Module: Vagrant::Action::VM::ForwardPortsHelpers
- Included in:
- ClearForwardedPorts, ForwardPorts
- Defined in:
- lib/vagrant/action/vm/forward_ports_helpers.rb
Overview
Helper methods for forwarding ports. Requires that the environment
is set to the @env
instance variable.
Instance Method Summary collapse
-
#used_ports ⇒ Array<String>
Returns an array of used ports.
Instance Method Details
#used_ports ⇒ Array<String>
Returns an array of used ports. This method is implemented differently depending on the VirtualBox version, but the behavior is the same.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/vagrant/action/vm/forward_ports_helpers.rb', line 12 def used_ports result = VirtualBox::VM.all.collect do |vm| if vm.running? && vm.uuid != @env["vm"].uuid vm.network_adapters.collect do |na| na.nat_driver.forwarded_ports.collect do |fp| fp.hostport.to_i end end end end result.flatten.uniq end |