Sha256: 46eb26638cb9fb06b996eaf2068d9b06b33963350e227ab0d43b1be87b572424

Contents?: true

Size: 850 Bytes

Versions: 10

Compression:

Stored size: 850 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.accessible? && 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
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
vagrantup-0.8.9 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrantup-0.8.8 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrantup-0.8.7 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrantup-0.8.6 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrantup-0.8.10 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrant-0.8.10 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrant-0.8.8 lib/vagrant/action/vm/forward_ports_helpers.rb
vagrant-0.8.7 lib/vagrant/action/vm/forward_ports_helpers.rb
rvagrant-0.8.7.dev lib/vagrant/action/vm/forward_ports_helpers.rb
vagrant-0.8.6 lib/vagrant/action/vm/forward_ports_helpers.rb