Class: Mogotest::Tunnel

Inherits:
Object
  • Object
show all
Defined in:
lib/mogotest/tunnel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_host, api_key, test_host, tunnel_url) ⇒ Tunnel

Returns a new instance of Tunnel.



10
11
12
13
14
15
# File 'lib/mogotest/tunnel.rb', line 10

def initialize(api_host, api_key, test_host, tunnel_url)
  @api_host = api_host
  @api_key = api_key
  @test_host = test_host
  @tunnel_url = tunnel_url
end

Instance Attribute Details

#api_hostObject

Returns the value of attribute api_host.



8
9
10
# File 'lib/mogotest/tunnel.rb', line 8

def api_host
  @api_host
end

#api_keyObject

Returns the value of attribute api_key.



8
9
10
# File 'lib/mogotest/tunnel.rb', line 8

def api_key
  @api_key
end

#test_hostObject

Returns the value of attribute test_host.



8
9
10
# File 'lib/mogotest/tunnel.rb', line 8

def test_host
  @test_host
end

#tunnel_urlObject

Returns the value of attribute tunnel_url.



8
9
10
# File 'lib/mogotest/tunnel.rb', line 8

def tunnel_url
  @tunnel_url
end

Instance Method Details

#notify_mogotest_of_tunnelObject



17
18
19
20
21
22
# File 'lib/mogotest/tunnel.rb', line 17

def notify_mogotest_of_tunnel
  RestClient.post "https://#{api_host}/api/v1/ssh_tunnels", { :user_credentials => api_key, :hostname => test_host, :tunnel_url => tunnel_url }
rescue
  puts "   [Error] Unable to register tunnel location with Mogotest API.  Perhaps your credentials are bad."
  exit
end

#teardown_tunnel_in_mogotestObject



24
25
26
27
28
29
# File 'lib/mogotest/tunnel.rb', line 24

def teardown_tunnel_in_mogotest
  RestClient.post "https://#{api_host}/api/v1/ssh_tunnels/destroy", { :user_credentials => api_key, :hostname => test_host }
rescue
  puts "   [Error] Unable to delete tunnel location from Mogotest API.  Perhaps your credentials are bad."
  exit
end