module VagrantPlugins module Skytap module Action # This is based on code from the VirtualBox provider. class PrepareForwardedPortCollisionParams def initialize(app, env) @app = app end # This logic is based on the VirtualBox provider def call(env) # Get the forwarded ports used by other virtual machines and # consider those in use as well. env[:port_collision_extra_in_use] = env[:host].capability(:read_used_ports, env[:machine]) # Build the remap for any existing collision detections remap = {} env[:port_collision_remap] = remap env[:host].capability(:read_forwarded_ports, env[:machine]).each do |fp| env[:machine].config.vm.networks.each do |type, options| next if type != :forwarded_port # If the ID matches the name of the forwarded port, then # remap. if options[:id] == fp.id remap[options[:host]] = fp.host_port break end end end @app.call(env) end end end end end