Class: ConfigBuilder::Model::Network::ForwardedPort

Inherits:
Base
  • Object
show all
Defined in:
lib/config_builder/model/network/forwarded_port.rb

Overview

Vagrant forwarded port model

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#attr, #attrs=, #call, #configure!, def_model_attribute, def_model_delegator, def_model_id, def_model_option, #eval_models, #instance_id, #instance_options, model_attributes, model_delegators, #model_delegators, model_options, new_from_hash, #with_attr

Constructor Details

#initializeForwardedPort

Returns a new instance of ForwardedPort.



37
38
39
# File 'lib/config_builder/model/network/forwarded_port.rb', line 37

def initialize
  @defaults = {:auto_correct => false, :id => nil}
end

Instance Attribute Details

#auto_correctBoolean

Returns Whether to automatically correct port collisions.

Returns:

  • (Boolean)

    Whether to automatically correct port collisions



35
# File 'lib/config_builder/model/network/forwarded_port.rb', line 35

def_model_attribute :auto_correct

#guestFixnum

Returns The port on the guest that you want to be exposed on the host.

Returns:

  • (Fixnum)

    The port on the guest that you want to be exposed on the host.



13
# File 'lib/config_builder/model/network/forwarded_port.rb', line 13

def_model_attribute :guest

#guest_ipString

Returns The guest IP to bind the forwarded port to.

Returns:

  • (String)

    The guest IP to bind the forwarded port to.



17
# File 'lib/config_builder/model/network/forwarded_port.rb', line 17

def_model_attribute :guest_ip

#hostFixnum

Returns The port on the host that you want to use to access the port on the guest.

Returns:

  • (Fixnum)

    The port on the host that you want to use to access the port on the guest.



22
# File 'lib/config_builder/model/network/forwarded_port.rb', line 22

def_model_attribute :host

#host_ipString

Returns The IP on the host you want to bind the forwarded port to.

Returns:

  • (String)

    The IP on the host you want to bind the forwarded port to.



26
# File 'lib/config_builder/model/network/forwarded_port.rb', line 26

def_model_attribute :host_ip

#idString?

Returns An optional name used to identify this port forward.

Returns:

  • (String, nil)

    An optional name used to identify this port forward



8
# File 'lib/config_builder/model/network/forwarded_port.rb', line 8

def_model_attribute :id

#protocolString

Returns Either udp or tcp. This specifies the protocol that will be allowed through the forwarded port. By default this is "tcp".

Returns:

  • (String)

    Either udp or tcp. This specifies the protocol that will be allowed through the forwarded port. By default this is "tcp".



31
# File 'lib/config_builder/model/network/forwarded_port.rb', line 31

def_model_attribute :protocol

Instance Method Details

#forwarded_port_optsObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/config_builder/model/network/forwarded_port.rb', line 47

def forwarded_port_opts
  h = {}
  with_attr(:id)           { |val| h[:id]           = val }
  with_attr(:guest)        { |val| h[:guest]        = val }
  with_attr(:guest_ip)     { |val| h[:guest_ip]     = val }
  with_attr(:host)         { |val| h[:host]         = val }
  with_attr(:host_ip)      { |val| h[:host_ip]      = val }
  with_attr(:protocol)     { |val| h[:protocol]     = val }
  with_attr(:auto_correct) { |val| h[:auto_correct] = val }
  h
end

#to_procObject



41
42
43
44
45
# File 'lib/config_builder/model/network/forwarded_port.rb', line 41

def to_proc
  Proc.new do |vm_config|
    vm_config.network(:forwarded_port, forwarded_port_opts)
  end
end