def _format_customer_config(vpn_connection, customer_gateways, os_ikepolicies,
                            os_ipsecpolicies, os_ipsec_site_connections,
                            external_ips):
    customer_gateway = customer_gateways[vpn_connection['customer_gateway_id']]
    os_connections_ids = vpn_connection['os_ipsec_site_connections'].values()
    if os_connections_ids:
        os_ipsec_site_connection = next(
            (os_ipsec_site_connections[conn_id]
             for conn_id in os_connections_ids
             if os_ipsec_site_connections.get(conn_id)),
            None)
    else:
        os_ipsec_site_connection = None

    # TODO(ft): figure out and add to the output tunnel internal addresses
    config_dict = {
        'customer_gateway_id': vpn_connection['customer_gateway_id'],
        'vpn_gateway_id': vpn_connection['vpn_gateway_id'],
        'vpn_connection_type': 'ipsec.1',
        'vpn_connection_attributes': 'NoBGPVPNConnection',
        'ipsec_tunnel': {
            'customer_gateway': {
                'tunnel_outside_address': {
                    'ip_address': (
                        os_ipsec_site_connection['peer_address']
                        if os_ipsec_site_connection else
                        customer_gateway['ip_address'])}},
            'vpn_gateway': {
                'tunnel_outside_address': {
                    'ip_address': external_ips.get(
                        vpn_connection['vpn_gateway_id'])}}},
    }
    os_ikepolicy = os_ikepolicies.get(vpn_connection['os_ikepolicy_id'])
    if os_ikepolicy:
        config_dict['ipsec_tunnel']['ike'] = {
            'authentication_protocol': os_ikepolicy['auth_algorithm'],
            'encryption_protocol': os_ikepolicy['encryption_algorithm'],
            'lifetime': os_ikepolicy['lifetime']['value'],
            'perfect_forward_secrecy': os_ikepolicy['pfs'],
            'mode': os_ikepolicy['phase1_negotiation_mode'],
            'pre_shared_key': (
                os_ipsec_site_connection['psk']
                if os_ipsec_site_connection else
                vpn_connection['pre_shared_key']),
        }
    os_ipsecpolicy = os_ipsecpolicies.get(vpn_connection['os_ipsecpolicy_id'])
    if os_ipsecpolicy:
        config_dict['ipsec_tunnel']['ipsec'] = {
            'protocol': os_ipsecpolicy['transform_protocol'],
            'authentication_protocol': os_ipsecpolicy['auth_algorithm'],
            'encryption_protocol': os_ipsecpolicy['encryption_algorithm'],
            'lifetime': os_ipsecpolicy['lifetime']['value'],
            'perfect_forward_secrecy': os_ipsecpolicy['pfs'],
            'mode': os_ipsecpolicy['encapsulation_mode'],
            'tcp_mss_adjustment': (
                os_ipsec_site_connection['mtu'] - MTU_MSS_DELTA
                if os_ipsec_site_connection else
                AWS_MSS),
        }
    return config_dict
dataset/ETHPy150Open openstack/ec2-api/ec2api/api/vpn_connection.py/_format_customer_config/original