

def _set_subnet_vpn(context, neutron, cleaner, subnet, vpn_connection, customer_gateway, cidrs):
    subnets_connections = vpn_connection['os_ipsec_site_connections']
    os_connection_id = subnets_connections.get(subnet['id'])
    if os_connection_id:
        neutron.update_ipsec_site_connection(os_connection_id, {
            'ipsec_site_connection': {
                'peer_cidrs': cidrs,
            },
        })
    else:
        os_connection = {
            'vpnservice_id': subnet['os_vpnservice_id'],
            'ikepolicy_id': vpn_connection['os_ikepolicy_id'],
            'ipsecpolicy_id': vpn_connection['os_ipsecpolicy_id'],
            'peer_address': customer_gateway['ip_address'],
            'peer_cidrs': cidrs,
            'psk': vpn_connection['pre_shared_key'],
            'name': ('%s/%s' % (vpn_connection['id'], subnet['id'])),
            'peer_id': customer_gateway['ip_address'],
            'mtu': (AWS_MSS + MTU_MSS_DELTA),
            'initiator': 'response-only',
        }
        os_connection = neutron.create_ipsec_site_connection({
            'ipsec_site_connection': os_connection,
        })['ipsec_site_connection']
        cleaner.addCleanup(neutron.delete_ipsec_site_connection, os_connection['id'])
        _add_subnet_connection_to_vpn_connection_item(context, vpn_connection, subnet['id'], os_connection['id'])
        cleaner.addCleanup(_remove_subnet_connection_from_vpn_connection_item, context, vpn_connection, subnet['id'])

dataset/ETHPy150Open openstack/ec2-api/ec2api/api/vpn_connection.py _set_subnet_vpn/original