Class: VagrantPlugins::Skytap::API::Tunnel

Inherits:
Resource show all
Defined in:
lib/vagrant-skytap/api/tunnel.rb

Instance Attribute Summary collapse

Attributes inherited from Resource

#attrs, #env

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#delete, #refresh, #reload, rest_name, short_name, #update, #url

Methods included from SpecifiedAttributes

#get_api_attribute, included

Constructor Details

#initialize(attrs, env) ⇒ Tunnel

Returns a new instance of Tunnel.



54
55
56
57
58
# File 'lib/vagrant-skytap/api/tunnel.rb', line 54

def initialize(attrs, env)
  super
  @source_network = Network.new(get_api_attribute('source_network'), env[:environment], env)
  @target_network = Network.new(get_api_attribute('target_network'), env[:environment], env)
end

Instance Attribute Details

#source_networkObject (readonly)

Returns the value of attribute source_network.



34
35
36
# File 'lib/vagrant-skytap/api/tunnel.rb', line 34

def source_network
  @source_network
end

#target_networkObject (readonly)

Returns the value of attribute target_network.



34
35
36
# File 'lib/vagrant-skytap/api/tunnel.rb', line 34

def target_network
  @target_network
end

Class Method Details

.create!(env, network, other_network) ⇒ API::Tunnel

Creates a tunnel between two networks in different environments. The API response includes information about both networks, but omits their tunnel collections, so no attempt is made to update the network objects automatically.

Parameters:

  • env (Hash)

    The environment hash

  • network (API::Network)

    The network making the connection

  • other_network (API::Network)

    The tunnelable network being connected to

Returns:



47
48
49
50
51
# File 'lib/vagrant-skytap/api/tunnel.rb', line 47

def create!(env, network, other_network)
  params = {source_network_id: network.id, target_network_id: other_network.id}
  resp = env[:api_client].post("/tunnels", JSON.dump(params))
  new(JSON.load(resp.body), env)
end

Instance Method Details

#busy?Boolean

Indicates whether the tunnel is busy.

Returns:

  • (Boolean)


63
64
65
# File 'lib/vagrant-skytap/api/tunnel.rb', line 63

def busy?
  status == "busy"
end