Class: Vcloud::EdgeGateway::ConfigurationGenerator::GatewayIpsecVpnService
- Inherits:
-
Object
- Object
- Vcloud::EdgeGateway::ConfigurationGenerator::GatewayIpsecVpnService
- Defined in:
- lib/vcloud/edge_gateway/configuration_generator/gateway_ipsec_vpn_service.rb
Instance Method Summary collapse
- #generate_fog_config ⇒ Object
-
#initialize(input_config) ⇒ GatewayIpsecVpnService
constructor
A new instance of GatewayIpsecVpnService.
- #populate_tunnel(tunnel) ⇒ Object
- #populate_vpn_tunnels ⇒ Object
Constructor Details
#initialize(input_config) ⇒ GatewayIpsecVpnService
Returns a new instance of GatewayIpsecVpnService.
6 7 8 |
# File 'lib/vcloud/edge_gateway/configuration_generator/gateway_ipsec_vpn_service.rb', line 6 def initialize input_config @input_config = input_config end |
Instance Method Details
#generate_fog_config ⇒ Object
10 11 12 13 14 15 16 17 |
# 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) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# 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 ⇒ Object
19 20 21 22 23 24 25 |
# 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 |