Sha256: 51feee6845f74790c05c0b8b26a13c84357043cd8e279df343f370a5295047e3

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

require "vagrant/util/scoped_hash_override"
require 'vagrant-skytap/model/forwarded_port'
module VagrantPlugins
  module Skytap
    module Util
      # This is based on code from the VirtualBox provider.
      module CompileForwardedPorts
        include Vagrant::Util::ScopedHashOverride

        # This method compiles the forwarded ports into {ForwardedPort}
        # models.
        def compile_forwarded_ports(config)
          mappings = {}

          config.vm.networks.each do |type, options|
            if type == :forwarded_port
              guest_port = options[:guest]
              host_port  = options[:host]
              protocol   = options[:protocol] || "tcp"
              options    = scoped_hash_override(options, :skytap)
              id         = options[:id]

              # If the forwarded port was marked as disabled, ignore.
              next if options[:disabled]
              mappings[host_port.to_s + protocol.to_s] =
                Model::ForwardedPort.new(id, host_port, guest_port, options)
            end
          end

          mappings.values
        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/util/compile_forwarded_ports.rb
vagrant-skytap-0.2.2 lib/vagrant-skytap/util/compile_forwarded_ports.rb
vagrant-skytap-0.2.1 lib/vagrant-skytap/util/compile_forwarded_ports.rb
vagrant-skytap-0.2.0 lib/vagrant-skytap/util/compile_forwarded_ports.rb