Sha256: 1955f8ef19608250c4ff338fc422ef7e145847e36116ecaba5a171635ccd6290

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

require "vpnconfig/version"

module Vpnconfig
  class Generator
  def generate_xml(input_configs)

      xml = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
        xml.EdgeGatewayServiceConfiguration('xmlns' => 'http://www.vmware.com/vcloud/v1.5') {
          xml.GatewayIpsecVpnService {
            xml.IsEnabled true
            input_configs.each do |input_config|
              xml.Tunnel {
                xml.Name input_config['name']
                xml.Description
                xml.IpsecVpnThirdPartyPeer {
                  xml.PeerId input_config['peerIp']
                }
                xml.PeerIpAddress input_config['peerIp']
                xml.PeerId input_config['peerIp']
                xml.LocalIpAddress input_config['localIp']
                xml.LocalId input_config['localIp']
                xml.LocalSubnet {
                  xml.Name input_config['localSubnet']['name']
                  xml.Gateway input_config['localSubnet']['gateway']
                  xml.Netmask input_config['localSubnet']['netmask']
                }
                xml.PeerSubnet {
                  xml.Name input_config['peerSubnet']['name']
                  xml.Gateway input_config['peerSubnet']['gateway']
                  xml.Netmask input_config['peerSubnet']['netmask']
                }
                xml.SharedSecret input_config['sharedSecret']
                xml.SharedSecretEncrypted false
                xml.EncryptionProtocol 'AES256'
                xml.Mtu input_config.fetch('mtu', '1500')
                xml.IsEnabled 'true'
                xml.IsOperational 'false'
              }
          end
        }
      }
      end

      xml.to_xml
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vcloud_ipsec-vpn-0.1.0 lib/generator.rb