Sha256: cc9aa7c3e54a3359b2fb089943d26472ba7c8d6a228d6d4b0c603963a92f9177

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

require 'vagrant-skytap/util/compile_forwarded_ports'

module VagrantPlugins
  module Skytap
    module Action
      # This is based on code from the VirtualBox provider.
      class ForwardPorts
        include Util::CompileForwardedPorts

        def initialize(app, env)
          @app = app
        end

        def call(env)
          @env = env
          env[:forwarded_ports] ||= compile_forwarded_ports(env[:machine].config)

          if env[:forwarded_ports].any?(&:privileged_host_port?)
            env[:ui].warn I18n.t("vagrant.actions.vm.forward_ports.privileged_ports")
          end

          env[:ui].output(I18n.t("vagrant.actions.vm.forward_ports.forwarding"))
          forward_ports

          @app.call(env)
        end

        def forward_ports
          @env[:forwarded_ports].each do |fp|
            unless fp.internal_ssh_port?
              @env[:ui].detail(I18n.t("vagrant.actions.vm.forward_ports.forwarding_entry",
                                        adapter: fp.adapter,
                                        guest_port: fp.guest_port,
                                        host_port: fp.host_port))
              @env[:host].capability(:start_ssh_tunnel, fp, @env[:machine])
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vagrant-skytap-0.2.3 lib/vagrant-skytap/action/forward_ports.rb
vagrant-skytap-0.2.2 lib/vagrant-skytap/action/forward_ports.rb
vagrant-skytap-0.2.1 lib/vagrant-skytap/action/forward_ports.rb
vagrant-skytap-0.2.0 lib/vagrant-skytap/action/forward_ports.rb