plugins/kernel_v2/config/vm.rb
# Define a way to access the machine via a network. This exposes a
# high-level abstraction for networking that may not directly map
# 1-to-1 for every provider. For example, AWS has no equivalent to
# "port forwarding." But most providers will attempt to implement this
# in a way that behaves similarly.
#
# `type` can be one of:
#
#   * `:forwarded_port` - A port that is accessible via localhost
#     that forwards into the machine.
#   * `:private_network` - The machine gets an IP that is not directly
#     publicly accessible, but ideally accessible from this machine.
#   * `:public_network` - The machine gets an IP on a shared network.
#
# @param [Symbol] type Type of network
# @param [Hash] options Options for the network.
Define a way to access the machine via a network. This exposes a
high-level abstraction for networking that may not directly map
1-to-1 for every provider. For example, AWS has no equivalent to
"port forwarding." But most providers will attempt to implement this
in a way that behaves similarly.

`type` can be one of.

`:forwarded_port` - A port that is accessible via localhost
that forwards into the machine.
`:private_network` - The machine gets an IP that is not directly
publicly accessible, but ideally accessible from this machine.
`:public_network` - The machine gets an IP on a shared network.
Define a way to access the machine via a network . This exposes a high - level abstraction for networking that may not directly map 1 - to - 1 for every provider . For example AWS has no equivalent to " port forwarding . " But most providers will attempt to implement this in a way that behaves similarly . ` type ` can be one of . ` : forwarded_port ` - A port that is accessible via localhost that forwards into the machine . ` : private_network ` - The machine gets an IP that is not directly publicly accessible but ideally accessible from this machine . ` : public_network ` - The machine gets an IP on a shared network .
def network(type, **options)
        options = options.dup
        options[:protocol] ||= "tcp"
        if !options[:id]
          default_id = nil
          if type == :forwarded_port
            default_id = "#{options[:protocol]}#{options[:host]}"
          end
          options[:id] = default_id || SecureRandom.uuid
        end
        id      = options[:id]
        id      = "#{type}-#{id}"
        if @__networks.has_key?(id)
          options = @__networks[id][1].merge(options)
        end
        @__networks[id] = [type.to_sym, options]
      end
def network ( type , ** options ) options = options . dup options [ :protocol ] ||= "tcp" if ! options [ :id ] default_id = nil if type == :forwarded_port default_id = "#{options[:protocol]}#{options[:host]}" end options [ :id ] = default_id || SecureRandom . uuid end id = options [ :id ] id = "#{type}-#{id}" if @__networks . has_key? ( id ) options = @__networks [ id ] [ 1 ] . merge ( options ) end @__networks [ id ] = [ type . to_sym , options ] end
Define a way to access the machine via a network.
Define a way to access the machine via a network .
# For forwarded ports, set the default ID to the # host port so that host ports overwrite each other. # Scope the ID by type so that different types can share IDs # Merge in the previous settings if we have them. # Merge in the latest settings and set the internal state
type
<not_specific>
options
<not_specific>
<not_specific>
options Options for the network.
options Options for the network .