#    Copyright 2017 FUJITSU LIMITED
#    All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.
#

from osc_lib.cli import format_columns
from osc_lib.command import command
from osc_lib import exceptions
from osc_lib import utils
from osc_lib.utils import columns as column_util
from oslo_log import log as logging

from neutronclient._i18n import _
from neutronclient.common import utils as nc_utils
from neutronclient.osc import utils as osc_utils
from neutronclient.osc.v2.vpnaas import utils as vpn_utils


LOG = logging.getLogger(__name__)


_formatters = {
    'peer_cidrs': format_columns.ListColumn
}


_attr_map = (
    ('id', 'ID', column_util.LIST_BOTH),
    ('name', 'Name', column_util.LIST_BOTH),
    ('peer_address', 'Peer Address', column_util.LIST_BOTH),
    ('auth_mode', 'Authentication Algorithm', column_util.LIST_BOTH),
    ('status', 'Status', column_util.LIST_BOTH),
    ('tenant_id', 'Project', column_util.LIST_LONG_ONLY),
    ('peer_cidrs', 'Peer CIDRs', column_util.LIST_LONG_ONLY),
    ('vpnservice_id', 'VPN Service', column_util.LIST_LONG_ONLY),
    ('ipsecpolicy_id', 'IPSec Policy', column_util.LIST_LONG_ONLY),
    ('ikepolicy_id', 'IKE Policy', column_util.LIST_LONG_ONLY),
    ('mtu', 'MTU', column_util.LIST_LONG_ONLY),
    ('initiator', 'Initiator', column_util.LIST_LONG_ONLY),
    ('admin_state_up', 'State', column_util.LIST_LONG_ONLY),
    ('description', 'Description', column_util.LIST_LONG_ONLY),
    ('psk', 'Pre-shared Key', column_util.LIST_LONG_ONLY),
    ('route_mode', 'Route Mode', column_util.LIST_LONG_ONLY),
    ('local_id', 'Local ID', column_util.LIST_LONG_ONLY),
    ('peer_id', 'Peer ID', column_util.LIST_LONG_ONLY),
    ('local_ep_group_id', 'Local Endpoint Group ID',
     column_util.LIST_LONG_ONLY),
    ('peer_ep_group_id', 'Peer Endpoint Group ID', column_util.LIST_LONG_ONLY),
)


def _convert_to_lowercase(string):
    return string.lower()


def _get_common_parser(parser, is_create=True):
    parser.add_argument(
        '--description',
        metavar='<description>',
        help=_('Description for the connection'))
    parser.add_argument(
        '--dpd',
        metavar="action=ACTION,interval=INTERVAL,timeout=TIMEOUT",
        type=nc_utils.str2dict_type(
            optional_keys=['action', 'interval', 'timeout']),
        help=vpn_utils.dpd_help("IPsec connection"))
    parser.add_argument(
        '--mtu',
        help=_('MTU size for the connection'))
    parser.add_argument(
        '--initiator',
        choices=['bi-directional', 'response-only'],
        type=_convert_to_lowercase,
        help=_('Initiator state'))
    peer_group = parser.add_mutually_exclusive_group()
    peer_group.add_argument(
        '--peer-cidr',
        dest='peer_cidrs',
        help=_('Remote subnet(s) in CIDR format. '
               'Cannot be specified when using endpoint groups. Only '
               'applicable, if subnet provided for VPN service.')
    )
    peer_group.add_argument(
        '--local-endpoint-group',
        help=_('Local endpoint group (name or ID) with subnet(s) '
               'for IPsec connection')
    )
    parser.add_argument(
        '--peer-endpoint-group',
        help=_('Peer endpoint group (name or ID) with CIDR(s) for '
               'IPSec connection'))
    admin_group = parser.add_mutually_exclusive_group()
    admin_group.add_argument(
        '--enable',
        action='store_true',
        help=_("Enable IPSec site connection")
    )
    admin_group.add_argument(
        '--disable',
        action='store_true',
        help=_("Disable IPSec site connection")
    )
    parser.add_argument(
        '--local-id',
        help=_('An ID to be used instead of the external IP '
               'address for a virtual router'))
    return parser


def _get_common_attrs(client_manager, parsed_args, is_create=True):
    attrs = {}
    if is_create:
        if 'project' in parsed_args and parsed_args.project is not None:
            attrs['tenant_id'] = osc_utils.find_project(
                client_manager.identity,
                parsed_args.project,
                parsed_args.project_domain,
            ).id
    if parsed_args.description:
        attrs['description'] = str(parsed_args.description)
    if parsed_args.mtu:
        attrs['mtu'] = parsed_args.mtu
    if parsed_args.enable:
        attrs['admin_state_up'] = True
    if parsed_args.disable:
        attrs['admin_state_up'] = False
    if parsed_args.initiator:
        attrs['initiator'] = parsed_args.initiator
    if parsed_args.dpd:
        vpn_utils.validate_dpd_dict(parsed_args.dpd)
        attrs['dpd'] = parsed_args.dpd
    if parsed_args.local_endpoint_group:
        _local_epg = client_manager.neutronclient.find_resource(
            'endpoint_group',
            parsed_args.local_endpoint_group,
            cmd_resource='endpoint_group')['id']
        attrs['local_ep_group_id'] = _local_epg
    if parsed_args.peer_endpoint_group:
        _peer_epg = client_manager.neutronclient.find_resource(
            'endpoint_group',
            parsed_args.peer_endpoint_group,
            cmd_resource='endpoint_group')['id']
        attrs['peer_ep_group_id'] = _peer_epg
    if parsed_args.peer_cidrs:
        attrs['peer_cidrs'] = parsed_args.peer_cidrs
    if parsed_args.local_id:
        attrs['local_id'] = parsed_args.local_id
    return attrs


class CreateIPsecSiteConnection(command.ShowOne):
    _description = _("Create an IPsec site connection")

    def get_parser(self, prog_name):
        parser = super(CreateIPsecSiteConnection, self).get_parser(prog_name)
        _get_common_parser(parser)
        parser.add_argument(
            '--peer-id',
            required=True,
            help=_('Peer router identity for authentication. Can be '
                   'IPv4/IPv6 address, e-mail address, key id, or FQDN'))
        parser.add_argument(
            '--peer-address',
            required=True,
            help=_('Peer gateway public IPv4/IPv6 address or FQDN'))
        parser.add_argument(
            '--psk',
            required=True,
            help=_('Pre-shared key string.'))
        parser.add_argument(
            '--vpnservice',
            metavar='VPNSERVICE',
            required=True,
            help=_('VPN service instance associated with this '
                   'connection (name or ID)'))
        parser.add_argument(
            '--ikepolicy',
            metavar='IKEPOLICY',
            required=True,
            help=_('IKE policy associated with this connection (name or ID)'))
        parser.add_argument(
            '--ipsecpolicy',
            metavar='IPSECPOLICY',
            required=True,
            help=_('IPsec policy associated with this connection '
                   '(name or ID)'))
        parser.add_argument(
            'name',
            metavar='<name>',
            help=_('Set friendly name for the connection'))
        osc_utils.add_project_owner_option_to_parser(parser)
        return parser

    def take_action(self, parsed_args):
        client = self.app.client_manager.neutronclient
        attrs = _get_common_attrs(self.app.client_manager, parsed_args)
        if parsed_args.vpnservice:
            _vpnservice_id = client.find_resource(
                'vpnservice',
                parsed_args.vpnservice,
                cmd_resource='vpnservice')['id']
            attrs['vpnservice_id'] = _vpnservice_id
        if parsed_args.ikepolicy:
            _ikepolicy_id = client.find_resource(
                'ikepolicy',
                parsed_args.ikepolicy,
                cmd_resource='ikepolicy')['id']
            attrs['ikepolicy_id'] = _ikepolicy_id
        if parsed_args.ipsecpolicy:
            _ipsecpolicy_id = client.find_resource(
                'ipsecpolicy',
                parsed_args.ipsecpolicy,
                cmd_resource='ipsecpolicy')['id']
            attrs['ipsecpolicy_id'] = _ipsecpolicy_id
        if parsed_args.peer_id:
            attrs['peer_id'] = parsed_args.peer_id
        if parsed_args.peer_address:
            attrs['peer_address'] = parsed_args.peer_address
        if parsed_args.psk:
            attrs['psk'] = parsed_args.psk
        if parsed_args.name:
            attrs['name'] = parsed_args.name
        if (bool(parsed_args.local_endpoint_group) !=
                bool(parsed_args.peer_endpoint_group)):
            message = _("You must specify both local and peer endpoint "
                        "groups")
            raise exceptions.CommandError(message)
        if not parsed_args.peer_cidrs and not parsed_args.local_endpoint_group:
            message = _("You must specify endpoint groups or peer CIDR(s)")
            raise exceptions.CommandError(message)
        obj = client.create_ipsec_site_connection(
            {'ipsec_site_connection': attrs})['ipsec_site_connection']
        columns, display_columns = column_util.get_columns(obj, _attr_map)
        data = utils.get_dict_properties(obj, columns, formatters=_formatters)
        return display_columns, data


class DeleteIPsecSiteConnection(command.Command):
    _description = _("Delete IPsec site connection(s)")

    def get_parser(self, prog_name):
        parser = super(DeleteIPsecSiteConnection, self).get_parser(prog_name)
        parser.add_argument(
            'ipsec_site_connection',
            metavar='<ipsec-site-connection>',
            nargs='+',
            help=_('IPsec site connection to delete (name or ID)'))
        return parser

    def take_action(self, parsed_args):
        client = self.app.client_manager.neutronclient
        result = 0
        for ipsec_conn in parsed_args.ipsec_site_connection:
            try:
                ipsec_con_id = client.find_resource(
                    'ipsec_site_connection',
                    ipsec_conn,
                    cmd_resource='ipsec_site_connection')['id']
                client.delete_ipsec_site_connection(ipsec_con_id)
            except Exception as e:
                result += 1
                LOG.error(_("Failed to delete IPsec site connection with "
                            "name or ID '%(ipsec_site_conn)s': %(e)s"),
                          {'ipsec_site_conn': ipsec_conn, 'e': e})

        if result > 0:
            total = len(parsed_args.ipsec_site_connection)
            msg = (_("%(result)s of %(total)s IPsec site connection failed "
                     "to delete.") % {'result': result, 'total': total})
            raise exceptions.CommandError(msg)


class ListIPsecSiteConnection(command.Lister):
    _description = _("List IPsec site connections "
                     "that belong to a given project")

    def get_parser(self, prog_name):
        parser = super(ListIPsecSiteConnection, self).get_parser(prog_name)
        parser.add_argument(
            '--long',
            action='store_true',
            default=False,
            help=_("List additional fields in output")
        )
        return parser

    def take_action(self, parsed_args):
        client = self.app.client_manager.neutronclient
        obj = client.list_ipsec_site_connections()['ipsec_site_connections']
        headers, columns = column_util.get_column_definitions(
            _attr_map, long_listing=parsed_args.long)
        return (headers, (utils.get_dict_properties(
            s, columns, formatters=_formatters) for s in obj))


class SetIPsecSiteConnection(command.Command):
    _description = _("Set IPsec site connection properties")

    def get_parser(self, prog_name):
        parser = super(SetIPsecSiteConnection, self).get_parser(prog_name)
        _get_common_parser(parser)
        parser.add_argument(
            '--peer-id',
            help=_('Peer router identity for authentication. Can be '
                   'IPv4/IPv6 address, e-mail address, key id, or FQDN'))
        parser.add_argument(
            '--peer-address',
            help=_('Peer gateway public IPv4/IPv6 address or FQDN'))
        parser.add_argument(
            '--name',
            metavar='<name>',
            help=_('Set friendly name for the connection'))
        parser.add_argument(
            'ipsec_site_connection',
            metavar='<ipsec-site-connection>',
            help=_('IPsec site connection to set (name or ID)'))
        return parser

    def take_action(self, parsed_args):
        client = self.app.client_manager.neutronclient
        attrs = _get_common_attrs(self.app.client_manager,
                                  parsed_args, is_create=False)
        if parsed_args.peer_id:
            attrs['peer_id'] = parsed_args.peer_id
        if parsed_args.peer_address:
            attrs['peer_address'] = parsed_args.peer_address
        if parsed_args.name:
            attrs['name'] = parsed_args.name
        ipsec_conn_id = client.find_resource(
            'ipsec_site_connection', parsed_args.ipsec_site_connection,
            cmd_resource='ipsec_site_connection')['id']
        try:
            client.update_ipsec_site_connection(
                ipsec_conn_id,
                {'ipsec_site_connection': attrs})
        except Exception as e:
            msg = (_("Failed to set IPsec site "
                     "connection '%(ipsec_conn)s': %(e)s")
                   % {'ipsec_conn': parsed_args.ipsec_site_connection, 'e': e})
            raise exceptions.CommandError(msg)


class ShowIPsecSiteConnection(command.ShowOne):
    _description = _("Show information of a given IPsec site connection")

    def get_parser(self, prog_name):
        parser = super(ShowIPsecSiteConnection, self).get_parser(prog_name)
        parser.add_argument(
            'ipsec_site_connection',
            metavar='<ipsec-site-connection>',
            help=_('IPsec site connection to display (name or ID)'))
        return parser

    def take_action(self, parsed_args):
        client = self.app.client_manager.neutronclient
        ipsec_site_id = client.find_resource(
            'ipsec_site_connection', parsed_args.ipsec_site_connection,
            cmd_resource='ipsec_site_connection')['id']
        obj = client.show_ipsec_site_connection(
            ipsec_site_id)['ipsec_site_connection']
        columns, display_columns = column_util.get_columns(obj, _attr_map)
        data = utils.get_dict_properties(obj, columns, formatters=_formatters)
        return (display_columns, data)

[((30, 6, 30, 33), 'oslo_log.log.getLogger', 'logging.getLogger', ({(30, 24, 30, 32): '__name__'}, {}), '(__name__)', True, 'from oslo_log import log as logging\n'), ((163, 19, 163, 55), 'neutronclient._i18n._', '_', ({(163, 21, 163, 54): '"""Create an IPsec site connection"""'}, {}), "('Create an IPsec site connection')", False, 'from neutronclient._i18n import _\n'), ((250, 19, 250, 55), 'neutronclient._i18n._', '_', ({(250, 21, 250, 54): '"""Delete IPsec site connection(s)"""'}, {}), "('Delete IPsec site connection(s)')", False, 'from neutronclient._i18n import _\n'), ((285, 19, 286, 54), 'neutronclient._i18n._', '_', ({(285, 21, 286, 53): '"""List IPsec site connections that belong to a given project"""'}, {}), "('List IPsec site connections that belong to a given project')", False, 'from neutronclient._i18n import _\n'), ((308, 19, 308, 60), 'neutronclient._i18n._', '_', ({(308, 21, 308, 59): '"""Set IPsec site connection properties"""'}, {}), "('Set IPsec site connection properties')", False, 'from neutronclient._i18n import _\n'), ((355, 19, 355, 73), 'neutronclient._i18n._', '_', ({(355, 21, 355, 72): '"""Show information of a given IPsec site connection"""'}, {}), "('Show information of a given IPsec site connection')", False, 'from neutronclient._i18n import _\n'), ((141, 8, 141, 52), 'neutronclient.osc.v2.vpnaas.utils.validate_dpd_dict', 'vpn_utils.validate_dpd_dict', ({(141, 36, 141, 51): 'parsed_args.dpd'}, {}), '(parsed_args.dpd)', True, 'from neutronclient.osc.v2.vpnaas import utils as vpn_utils\n'), ((202, 8, 202, 60), 'neutronclient.osc.utils.add_project_owner_option_to_parser', 'osc_utils.add_project_owner_option_to_parser', ({(202, 53, 202, 59): 'parser'}, {}), '(parser)', True, 'from neutronclient.osc import utils as osc_utils\n'), ((244, 35, 244, 74), 'osc_lib.utils.columns.get_columns', 'column_util.get_columns', ({(244, 59, 244, 62): 'obj', (244, 64, 244, 73): '_attr_map'}, {}), '(obj, _attr_map)', True, 'from osc_lib.utils import columns as column_util\n'), ((245, 15, 245, 78), 'osc_lib.utils.get_dict_properties', 'utils.get_dict_properties', (), '', False, 'from osc_lib import utils\n'), ((301, 27, 302, 53), 'osc_lib.utils.columns.get_column_definitions', 'column_util.get_column_definitions', (), '', True, 'from osc_lib.utils import columns as column_util\n'), ((372, 35, 372, 74), 'osc_lib.utils.columns.get_columns', 'column_util.get_columns', ({(372, 59, 372, 62): 'obj', (372, 64, 372, 73): '_attr_map'}, {}), '(obj, _attr_map)', True, 'from osc_lib.utils import columns as column_util\n'), ((373, 15, 373, 78), 'osc_lib.utils.get_dict_properties', 'utils.get_dict_properties', (), '', False, 'from osc_lib import utils\n'), ((71, 13, 71, 48), 'neutronclient._i18n._', '_', ({(71, 15, 71, 47): '"""Description for the connection"""'}, {}), "('Description for the connection')", False, 'from neutronclient._i18n import _\n'), ((75, 13, 76, 60), 'neutronclient.common.utils.str2dict_type', 'nc_utils.str2dict_type', (), '', True, 'from neutronclient.common import utils as nc_utils\n'), ((77, 13, 77, 51), 'neutronclient.osc.v2.vpnaas.utils.dpd_help', 'vpn_utils.dpd_help', ({(77, 32, 77, 50): '"""IPsec connection"""'}, {}), "('IPsec connection')", True, 'from neutronclient.osc.v2.vpnaas import utils as vpn_utils\n'), ((80, 13, 80, 45), 'neutronclient._i18n._', '_', ({(80, 15, 80, 44): '"""MTU size for the connection"""'}, {}), "('MTU size for the connection')", False, 'from neutronclient._i18n import _\n'), ((85, 13, 85, 33), 'neutronclient._i18n._', '_', ({(85, 15, 85, 32): '"""Initiator state"""'}, {}), "('Initiator state')", False, 'from neutronclient._i18n import _\n'), ((90, 13, 92, 65), 'neutronclient._i18n._', '_', ({(90, 15, 92, 64): '"""Remote subnet(s) in CIDR format. Cannot be specified when using endpoint groups. Only applicable, if subnet provided for VPN service."""'}, {}), "('Remote subnet(s) in CIDR format. Cannot be specified when using endpoint groups. Only applicable, if subnet provided for VPN service.'\n    )", False, 'from neutronclient._i18n import _\n'), ((96, 13, 97, 38), 'neutronclient._i18n._', '_', ({(96, 15, 97, 37): '"""Local endpoint group (name or ID) with subnet(s) for IPsec connection"""'}, {}), "('Local endpoint group (name or ID) with subnet(s) for IPsec connection')", False, 'from neutronclient._i18n import _\n'), ((101, 13, 102, 34), 'neutronclient._i18n._', '_', ({(101, 15, 102, 33): '"""Peer endpoint group (name or ID) with CIDR(s) for IPSec connection"""'}, {}), "('Peer endpoint group (name or ID) with CIDR(s) for IPSec connection')", False, 'from neutronclient._i18n import _\n'), ((107, 13, 107, 46), 'neutronclient._i18n._', '_', ({(107, 15, 107, 45): '"""Enable IPSec site connection"""'}, {}), "('Enable IPSec site connection')", False, 'from neutronclient._i18n import _\n'), ((112, 13, 112, 47), 'neutronclient._i18n._', '_', ({(112, 15, 112, 46): '"""Disable IPSec site connection"""'}, {}), "('Disable IPSec site connection')", False, 'from neutronclient._i18n import _\n'), ((116, 13, 117, 46), 'neutronclient._i18n._', '_', ({(116, 15, 117, 45): '"""An ID to be used instead of the external IP address for a virtual router"""'}, {}), "('An ID to be used instead of the external IP address for a virtual router')", False, 'from neutronclient._i18n import _\n'), ((236, 22, 237, 33), 'neutronclient._i18n._', '_', ({(236, 24, 237, 32): '"""You must specify both local and peer endpoint groups"""'}, {}), "('You must specify both local and peer endpoint groups')", False, 'from neutronclient._i18n import _\n'), ((238, 18, 238, 50), 'osc_lib.exceptions.CommandError', 'exceptions.CommandError', ({(238, 42, 238, 49): 'message'}, {}), '(message)', False, 'from osc_lib import exceptions\n'), ((240, 22, 240, 75), 'neutronclient._i18n._', '_', ({(240, 24, 240, 74): '"""You must specify endpoint groups or peer CIDR(s)"""'}, {}), "('You must specify endpoint groups or peer CIDR(s)')", False, 'from neutronclient._i18n import _\n'), ((241, 18, 241, 50), 'osc_lib.exceptions.CommandError', 'exceptions.CommandError', ({(241, 42, 241, 49): 'message'}, {}), '(message)', False, 'from osc_lib import exceptions\n'), ((281, 18, 281, 46), 'osc_lib.exceptions.CommandError', 'exceptions.CommandError', ({(281, 42, 281, 45): 'msg'}, {}), '(msg)', False, 'from osc_lib import exceptions\n'), ((125, 33, 129, 13), 'neutronclient.osc.utils.find_project', 'osc_utils.find_project', ({(126, 16, 126, 39): 'client_manager.identity', (127, 16, 127, 35): 'parsed_args.project', (128, 16, 128, 42): 'parsed_args.project_domain'}, {}), '(client_manager.identity, parsed_args.project,\n    parsed_args.project_domain)', True, 'from neutronclient.osc import utils as osc_utils\n'), ((171, 17, 172, 72), 'neutronclient._i18n._', '_', ({(171, 19, 172, 71): '"""Peer router identity for authentication. Can be IPv4/IPv6 address, e-mail address, key id, or FQDN"""'}, {}), "('Peer router identity for authentication. Can be IPv4/IPv6 address, e-mail address, key id, or FQDN'\n    )", False, 'from neutronclient._i18n import _\n'), ((176, 17, 176, 67), 'neutronclient._i18n._', '_', ({(176, 19, 176, 66): '"""Peer gateway public IPv4/IPv6 address or FQDN"""'}, {}), "('Peer gateway public IPv4/IPv6 address or FQDN')", False, 'from neutronclient._i18n import _\n'), ((180, 17, 180, 44), 'neutronclient._i18n._', '_', ({(180, 19, 180, 43): '"""Pre-shared key string."""'}, {}), "('Pre-shared key string.')", False, 'from neutronclient._i18n import _\n'), ((185, 17, 186, 45), 'neutronclient._i18n._', '_', ({(185, 19, 186, 44): '"""VPN service instance associated with this connection (name or ID)"""'}, {}), "('VPN service instance associated with this connection (name or ID)')", False, 'from neutronclient._i18n import _\n'), ((191, 17, 191, 77), 'neutronclient._i18n._', '_', ({(191, 19, 191, 76): '"""IKE policy associated with this connection (name or ID)"""'}, {}), "('IKE policy associated with this connection (name or ID)')", False, 'from neutronclient._i18n import _\n'), ((196, 17, 197, 34), 'neutronclient._i18n._', '_', ({(196, 19, 197, 33): '"""IPsec policy associated with this connection (name or ID)"""'}, {}), "('IPsec policy associated with this connection (name or ID)')", False, 'from neutronclient._i18n import _\n'), ((201, 17, 201, 58), 'neutronclient._i18n._', '_', ({(201, 19, 201, 57): '"""Set friendly name for the connection"""'}, {}), "('Set friendly name for the connection')", False, 'from neutronclient._i18n import _\n'), ((258, 17, 258, 66), 'neutronclient._i18n._', '_', ({(258, 19, 258, 65): '"""IPsec site connection to delete (name or ID)"""'}, {}), "('IPsec site connection to delete (name or ID)')", False, 'from neutronclient._i18n import _\n'), ((279, 19, 280, 34), 'neutronclient._i18n._', '_', ({(279, 21, 280, 33): '"""%(result)s of %(total)s IPsec site connection failed to delete."""'}, {}), "('%(result)s of %(total)s IPsec site connection failed to delete.')", False, 'from neutronclient._i18n import _\n'), ((294, 17, 294, 54), 'neutronclient._i18n._', '_', ({(294, 19, 294, 53): '"""List additional fields in output"""'}, {}), "('List additional fields in output')", False, 'from neutronclient._i18n import _\n'), ((303, 26, 304, 47), 'osc_lib.utils.get_dict_properties', 'utils.get_dict_properties', (), '', False, 'from osc_lib import utils\n'), ((315, 17, 316, 72), 'neutronclient._i18n._', '_', ({(315, 19, 316, 71): '"""Peer router identity for authentication. Can be IPv4/IPv6 address, e-mail address, key id, or FQDN"""'}, {}), "('Peer router identity for authentication. Can be IPv4/IPv6 address, e-mail address, key id, or FQDN'\n    )", False, 'from neutronclient._i18n import _\n'), ((319, 17, 319, 67), 'neutronclient._i18n._', '_', ({(319, 19, 319, 66): '"""Peer gateway public IPv4/IPv6 address or FQDN"""'}, {}), "('Peer gateway public IPv4/IPv6 address or FQDN')", False, 'from neutronclient._i18n import _\n'), ((323, 17, 323, 58), 'neutronclient._i18n._', '_', ({(323, 19, 323, 57): '"""Set friendly name for the connection"""'}, {}), "('Set friendly name for the connection')", False, 'from neutronclient._i18n import _\n'), ((327, 17, 327, 63), 'neutronclient._i18n._', '_', ({(327, 19, 327, 62): '"""IPsec site connection to set (name or ID)"""'}, {}), "('IPsec site connection to set (name or ID)')", False, 'from neutronclient._i18n import _\n'), ((351, 18, 351, 46), 'osc_lib.exceptions.CommandError', 'exceptions.CommandError', ({(351, 42, 351, 45): 'msg'}, {}), '(msg)', False, 'from osc_lib import exceptions\n'), ((362, 17, 362, 67), 'neutronclient._i18n._', '_', ({(362, 19, 362, 66): '"""IPsec site connection to display (name or ID)"""'}, {}), "('IPsec site connection to display (name or ID)')", False, 'from neutronclient._i18n import _\n'), ((348, 19, 349, 58), 'neutronclient._i18n._', '_', ({(348, 21, 349, 57): '"""Failed to set IPsec site connection \'%(ipsec_conn)s\': %(e)s"""'}, {}), '("Failed to set IPsec site connection \'%(ipsec_conn)s\': %(e)s")', False, 'from neutronclient._i18n import _\n'), ((273, 26, 274, 70), 'neutronclient._i18n._', '_', ({(273, 28, 274, 69): '"""Failed to delete IPsec site connection with name or ID \'%(ipsec_site_conn)s\': %(e)s"""'}, {}), '("Failed to delete IPsec site connection with name or ID \'%(ipsec_site_conn)s\': %(e)s"\n    )', False, 'from neutronclient._i18n import _\n')]