class Vcloud::Walker::Resource::GatewayIpsecVpnService

Attributes

IsEnabled[R]
Tunnels[R]

Public Class Methods

new(fog_vpn_service) click to toggle source
# File lib/vcloud/walker/resource/gateway_ipsec_vpn_service.rb, line 7
def initialize fog_vpn_service
  @IsEnabled = fog_vpn_service[:IsEnabled]
  if fog_vpn_service[:Tunnel]
    fog_vpn_tunnels = [fog_vpn_service[:Tunnel]].flatten
    @Tunnels = populate_tunnel_info(fog_vpn_tunnels)
  end
end

Private Instance Methods

populate_tunnel_info(fog_vpn_tunnels) click to toggle source
# File lib/vcloud/walker/resource/gateway_ipsec_vpn_service.rb, line 16
def populate_tunnel_info(fog_vpn_tunnels)
  return if fog_vpn_tunnels.empty?
  fog_vpn_tunnels.collect do |fog_vpn_tunnel|
    @tunnel = {
      :Name => fog_vpn_tunnel[:Name],
      :Description => fog_vpn_tunnel[:Description],
      :PeerId => fog_vpn_tunnel[:PeerId],
      :LocalId => fog_vpn_tunnel[:LocalId],
      :PeerIpAddress => fog_vpn_tunnel[:PeerIpAddress],
      :LocalIpAddress => fog_vpn_tunnel[:LocalIpAddress],
      :PeerSubnet => fog_vpn_tunnel[:PeerSubnet],
      :LocalSubnet => fog_vpn_tunnel[:LocalSubnet],
      :Mtu => fog_vpn_tunnel[:Mtu],
      :IsEnabled => fog_vpn_tunnel[:IsEnabled],
      :IsOperational => fog_vpn_tunnel[:IsOperational]
    }

    if (third_party_peer = fog_vpn_tunnel.fetch(:IpsecVpnThirdPartyPeer, false))
      @tunnel[:ThirdPartyPeerId] = third_party_peer[:PeerId]
    end

    if (local_peer = fog_vpn_tunnel.fetch(:IpsecVpnLocalPeer, false))
      @tunnel[:LocalPeerId] = local_peer[:Id]
      @tunnel[:LocalPeerName] = local_peer[:Name]
    end

    @tunnel[:SharedSecret] = "*" * 65 if fog_vpn_tunnel[:SharedSecret]
    @tunnel[:SharedSecretEncrypted] = "******" if fog_vpn_tunnel[:SharedSecretEncrypted]
    @tunnel[:EncryptionProtocol] = "******" if fog_vpn_tunnel[:EncryptionProtocol]
    @tunnel
  end
end