Class: Armada::Connection::Remote

Inherits:
Object
  • Object
show all
Defined in:
lib/armada/connection/remote.rb

Direct Known Subclasses

Docker, HealthCheck

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port = nil, gateway_host = nil, gateway_user = nil) ⇒ Remote

Returns a new instance of Remote.



6
7
8
9
10
11
12
# File 'lib/armada/connection/remote.rb', line 6

def initialize(host, port = nil, gateway_host = nil, gateway_user = nil)
  @host, @port  = host.split(":")
  @port         = port ||= @port
  @gateway_host = gateway_host
  @gateway_user = gateway_user
  initialize_gateway!
end

Instance Attribute Details

#gatewayObject (readonly)

Returns the value of attribute gateway.



5
6
7
# File 'lib/armada/connection/remote.rb', line 5

def gateway
  @gateway
end

#hostObject (readonly)

Returns the value of attribute host.



5
6
7
# File 'lib/armada/connection/remote.rb', line 5

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



5
6
7
# File 'lib/armada/connection/remote.rb', line 5

def port
  @port
end

Instance Method Details

#initialize_gateway!Object



18
19
20
21
22
23
# File 'lib/armada/connection/remote.rb', line 18

def initialize_gateway!
  if @gateway_host
    @gateway       = Net::SSH::Gateway.new(@gateway_host, @gateway_user)
    @tunneled_port = @gateway.open(@host, @port)
  end
end

#to_sObject



14
15
16
# File 'lib/armada/connection/remote.rb', line 14

def to_s
  "#{@host}:#{@port}"
end