Source code for openstack_dashboard.dashboards.project.vpn.tables

# Copyright 2013, Mirantis Inc
#
#    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 django.core.urlresolvers import reverse
from django import template
from django.utils.translation import pgettext_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy

from horizon import exceptions
from horizon import tables

from openstack_dashboard import api
from openstack_dashboard import policy


forbid_updates = set(["PENDING_CREATE", "PENDING_UPDATE", "PENDING_DELETE"])














[docs]class IPSecSiteConnectionsTable(tables.DataTable): STATUS_CHOICES = ( ("Active", True), ("Down", True), ("Error", False), ) STATUS_DISPLAY_CHOICES = ( ("Active", pgettext_lazy("Current status of an IPSec Site Connection", u"Active")), ("Down", pgettext_lazy("Current status of an IPSec Site Connection", u"Down")), ("Error", pgettext_lazy("Current status of an IPSec Site Connection", u"Error")), ) id = tables.Column('id', hidden=True) name = tables.Column('name_or_id', verbose_name=_('Name'), link="horizon:project:vpn:ipsecsiteconnectiondetails") description = tables.Column('description', verbose_name=_('Description')) vpnservice_name = tables.Column('vpnservice_name', verbose_name=_('VPN Service')) ikepolicy_name = tables.Column('ikepolicy_name', verbose_name=_('IKE Policy')) ipsecpolicy_name = tables.Column('ipsecpolicy_name', verbose_name=_('IPSec Policy')) status = tables.Column("status", verbose_name=_("Status"), status=True, status_choices=STATUS_CHOICES, display_choices=STATUS_DISPLAY_CHOICES)
[docs] class Meta(object): name = "ipsecsiteconnectionstable" verbose_name = _("IPSec Site Connections") table_actions = (AddIPSecSiteConnectionLink, DeleteIPSecSiteConnectionLink, tables.NameFilterAction) row_actions = (UpdateIPSecSiteConnectionLink, DeleteIPSecSiteConnectionLink)
[docs]def get_local_ips(vpn): template_name = 'project/vpn/_vpn_ips.html' context = {"external_v4_ip": vpn.get('external_v4_ip'), "external_v6_ip": vpn.get('external_v6_ip')} return template.loader.render_to_string(template_name, context)
[docs]class VPNServicesTable(tables.DataTable): STATUS_CHOICES = ( ("Active", True), ("Down", True), ("Error", False), ) STATUS_DISPLAY_CHOICES = ( ("Active", pgettext_lazy("Current status of a VPN Service", u"Active")), ("Down", pgettext_lazy("Current status of a VPN Service", u"Down")), ("Error", pgettext_lazy("Current status of a VPN Service", u"Error")), ("Created", pgettext_lazy("Current status of a VPN Service", u"Created")), ("Pending_Create", pgettext_lazy("Current status of a VPN Service", u"Pending Create")), ("Pending_Update", pgettext_lazy("Current status of a VPN Service", u"Pending Update")), ("Pending_Delete", pgettext_lazy("Current status of a VPN Service", u"Pending Delete")), ("Inactive", pgettext_lazy("Current status of a VPN Service", u"Inactive")), ) id = tables.Column('id', hidden=True) name = tables.Column("name_or_id", verbose_name=_('Name'), link="horizon:project:vpn:vpnservicedetails") description = tables.Column('description', verbose_name=_('Description')) local_ips = tables.Column(get_local_ips, verbose_name=_("Local Side Public IPs")) subnet_name = tables.Column('subnet_name', verbose_name=_('Subnet')) router_name = tables.Column('router_name', verbose_name=_('Router')) status = tables.Column("status", verbose_name=_("Status"), status=True, status_choices=STATUS_CHOICES, display_choices=STATUS_DISPLAY_CHOICES)
[docs] class Meta(object): name = "vpnservicestable" verbose_name = _("VPN Services") table_actions = (AddVPNServiceLink, DeleteVPNServiceLink, tables.NameFilterAction) row_actions = (UpdateVPNServiceLink, DeleteVPNServiceLink)
[docs]class IKEPoliciesTable(tables.DataTable): id = tables.Column('id', hidden=True) name = tables.Column("name_or_id", verbose_name=_('Name'), link="horizon:project:vpn:ikepolicydetails") description = tables.Column('description', verbose_name=_('Description')) auth_algorithm = tables.Column('auth_algorithm', verbose_name=_('Authorization algorithm')) encryption_algorithm = tables.Column( 'encryption_algorithm', verbose_name=_('Encryption algorithm')) pfs = tables.Column("pfs", verbose_name=_('PFS'))
[docs] class Meta(object): name = "ikepoliciestable" verbose_name = _("IKE Policies") table_actions = (AddIKEPolicyLink, DeleteIKEPolicyLink, tables.NameFilterAction) row_actions = (UpdateIKEPolicyLink, DeleteIKEPolicyLink)
[docs]class IPSecPoliciesTable(tables.DataTable): id = tables.Column('id', hidden=True) name = tables.Column("name_or_id", verbose_name=_('Name'), link="horizon:project:vpn:ipsecpolicydetails") description = tables.Column('description', verbose_name=_('Description')) auth_algorithm = tables.Column('auth_algorithm', verbose_name=_('Authorization algorithm')) encryption_algorithm = tables.Column( 'encryption_algorithm', verbose_name=_('Encryption algorithm')) pfs = tables.Column("pfs", verbose_name=_('PFS'))
[docs] class Meta(object): name = "ipsecpoliciestable" verbose_name = _("IPSec Policies") table_actions = (AddIPSecPolicyLink, DeleteIPSecPolicyLink, tables.NameFilterAction) row_actions = (UpdateIPSecPolicyLink, DeleteIPSecPolicyLink)

Project Source