class Vcloud::EdgeGateway::ConfigurationGenerator::GatewayIpsecVpnService

Public Class Methods

new(input_config) click to toggle source
# File lib/vcloud/edge_gateway/configuration_generator/gateway_ipsec_vpn_service.rb, line 6
def initialize input_config
  @input_config = input_config
end

Public Instance Methods

generate_fog_config() click to toggle source
# File lib/vcloud/edge_gateway/configuration_generator/gateway_ipsec_vpn_service.rb, line 10
def generate_fog_config
  if @input_config
    gateway_ipsec_vpn_service = {}
    gateway_ipsec_vpn_service[:IsEnabled] = @input_config.key?(:enabled) ? @input_config[:enabled].to_s : 'true'
    gateway_ipsec_vpn_service[:Tunnel] = populate_vpn_tunnels
    gateway_ipsec_vpn_service
  end
end
populate_tunnel(tunnel) click to toggle source
# File lib/vcloud/edge_gateway/configuration_generator/gateway_ipsec_vpn_service.rb, line 27
def populate_tunnel(tunnel)
  vpn_tunnel = {}
  vpn_tunnel[:Name] = tunnel[:name]
  vpn_tunnel[:Description] = tunnel[:description]
  vpn_tunnel[:IpsecVpnLocalPeer] = {
    :Id => tunnel[:ipsec_vpn_local_peer][:id],
    :Name => tunnel[:ipsec_vpn_local_peer][:name]
  }
  vpn_tunnel[:PeerIpAddress] = tunnel[:peer_ip_address]
  vpn_tunnel[:PeerId] = tunnel[:peer_id]
  vpn_tunnel[:LocalIpAddress] = tunnel[:local_ip_address]
  vpn_tunnel[:LocalId] = tunnel[:local_id]
  vpn_tunnel[:PeerSubnet] =
  tunnel[:peer_subnets].map do |subnet|
    { :Name => subnet[:name],
      :Gateway => subnet[:gateway],
      :Netmask => subnet[:netmask]
    }
  end
  vpn_tunnel[:SharedSecret] = tunnel[:shared_secret]
  vpn_tunnel[:SharedSecretEncrypted] = tunnel[:shared_secret_encrypted] if tunnel.key?(:shared_secret_encrypted)
  vpn_tunnel[:EncryptionProtocol] = tunnel[:encryption_protocol]
  vpn_tunnel[:Mtu] = tunnel[:mtu]
  vpn_tunnel[:IsEnabled] = tunnel[:enabled]
  vpn_tunnel[:LocalSubnet] =
  tunnel[:local_subnets].map do |subnet|
    { :Name => subnet[:name],
      :Gateway => subnet[:gateway],
      :Netmask => subnet[:netmask]
    }
  end
  vpn_tunnel
end
populate_vpn_tunnels() click to toggle source
# File lib/vcloud/edge_gateway/configuration_generator/gateway_ipsec_vpn_service.rb, line 19
def populate_vpn_tunnels
  tunnels = @input_config[:tunnels]
  tunnels.collect do |tunnel|
    new_tunnel = populate_tunnel(tunnel)
    new_tunnel
  end
end