Sha256: a7224e81ec652ad3366d47c5095f02c213a870633823bf34716342d07c38f0c0

Contents?: true

Size: 1.92 KB

Versions: 3

Compression:

Stored size: 1.92 KB

Contents

module Vcloud
  module Walker
    module Resource
      class GatewayIpsecVpnService < Entity
        attr_reader :IsEnabled, :Tunnels

        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
        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


      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vcloud-walker-5.1.0 lib/vcloud/walker/resource/gateway_ipsec_vpn_service.rb
vcloud-walker-5.0.0 lib/vcloud/walker/resource/gateway_ipsec_vpn_service.rb
vcloud-walker-4.0.0 lib/vcloud/walker/resource/gateway_ipsec_vpn_service.rb