Sha256: 23aed25131cf3a0baefa07e86fbc5660b7a4fcdb2a9b8d5585bbd27110c09610

Contents?: true

Size: 832 Bytes

Versions: 22

Compression:

Stored size: 832 Bytes

Contents

module Vagrant
  class Action
    module VM
      # Helper methods for forwarding ports. Requires that the environment
      # is set to the `@env` instance variable.
      module ForwardPortsHelpers
        # Returns an array of used ports. This method is implemented
        # differently depending on the VirtualBox version, but the
        # behavior is the same.
        #
        # @return [Array<String>]
        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_s
                end
              end
            end
          end

          result.flatten.uniq
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
vagrantup-0.6.5 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrantup-0.6.4 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrantup-0.6.3 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrantup-0.6.2 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrantup-0.6.1 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrantup-0.6.0 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrantup-0.5.4 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrantup-0.5.3 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrantup-0.5.2 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrantup-0.5.1 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrantup-0.5.0 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrant-0.6.5 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrant-0.6.4 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrant-0.6.3 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrant-0.6.2 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrant-0.6.1 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrant-0.6.0 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrant-0.5.4 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrant-0.5.3 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrant-0.5.2 lib/vagrant/action/vm/forward_ports_helpers.rb