lib/vagrant/action/vm/forward_ports.rb
# Handles any collisions. This method will either attempt to
# fix the collision automatically or will raise an error if
# auto fixing is disabled.
Handles any collisions. This method will either attempt to
fix the collision automatically or will raise an error if
auto fixing is disabled.
Handles any collisions . This method will either attempt to fix the collision automatically or will raise an error if auto fixing is disabled .
def handle_collision(name, options, existing_ports)
          if !options[:auto]
            raise Errors::ForwardPortCollision, :name => name,
                                                :host_port => options[:hostport].to_s,
                                                :guest_port => options[:guestport].to_s
          end
          range = @env.env.config.vm.auto_port_range.to_a
          range -= @env.env.config.vm.forwarded_ports.collect { |n, o| o[:hostport].to_i }
          range -= existing_ports
          if range.empty?
            raise Errors::ForwardPortAutolistEmpty, :vm_name => @env["vm"].name,
                                                    :name => name,
                                                    :host_port => options[:hostport].to_s,
                                                    :guest_port => options[:guestport].to_s
          end
          options[:hostport] = range.shift
          existing_ports << options[:hostport]
          @env.ui.info(I18n.t("vagrant.actions.vm.forward_ports.fixed_collision",
                       :name => name,
                       :new_port => options[:hostport]))
        end
def handle_collision ( name , options , existing_ports ) if ! options [ :auto ] raise Errors :: ForwardPortCollision , :name => name , :host_port => options [ :hostport ] . to_s , :guest_port => options [ :guestport ] . to_s end range = @env . env . config . vm . auto_port_range . to_a range -= @env . env . config . vm . forwarded_ports . collect { | n , o | o [ :hostport ] . to_i } range -= existing_ports if range . empty? raise Errors :: ForwardPortAutolistEmpty , :vm_name => @env [ "vm" ] . name , :name => name , :host_port => options [ :hostport ] . to_s , :guest_port => options [ :guestport ] . to_s end options [ :hostport ] = range . shift existing_ports << options [ :hostport ] @env . ui . info ( I18n . t ( "vagrant.actions.vm.forward_ports.fixed_collision" , :name => name , :new_port => options [ :hostport ] ) ) end
Handles any collisions.
Handles any collisions .
# Auto fixing is disabled for this port forward, so we # must throw an error so the user can fix it. # Get the auto port range and get rid of the used ports and # ports which are being used in other forwards so we're just # left with available ports. # Set the port up to be the first one and add that port to # the used list. # Notify the user
name
<not_specific>
options
<not_specific>
existing_ports
<not_specific>