2022-06-27 23:24:50 -05:00
|
|
|
import django_tables2 as tables
|
2023-11-28 13:45:00 -05:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2022-06-27 23:24:50 -05:00
|
|
|
|
|
|
|
from netbox.tables import NetBoxTable, columns
|
2022-07-11 21:51:39 -04:00
|
|
|
from tenancy.tables import TenancyColumnsMixin
|
2023-11-28 13:45:00 -05:00
|
|
|
from vpn.models import L2VPN, L2VPNTermination
|
2022-06-27 23:24:50 -05:00
|
|
|
|
|
|
|
__all__ = (
|
|
|
|
'L2VPNTable',
|
|
|
|
'L2VPNTerminationTable',
|
|
|
|
)
|
|
|
|
|
2022-07-06 08:57:15 -05:00
|
|
|
L2VPN_TARGETS = """
|
|
|
|
{% for rt in value.all %}
|
|
|
|
<a href="{{ rt.get_absolute_url }}">{{ rt }}</a>{% if not forloop.last %}<br />{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
"""
|
|
|
|
|
2022-06-27 23:24:50 -05:00
|
|
|
|
2022-07-11 21:51:39 -04:00
|
|
|
class L2VPNTable(TenancyColumnsMixin, NetBoxTable):
|
2022-06-27 23:24:50 -05:00
|
|
|
pk = columns.ToggleColumn()
|
|
|
|
name = tables.Column(
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Name'),
|
2022-06-27 23:24:50 -05:00
|
|
|
linkify=True
|
|
|
|
)
|
2022-07-06 08:57:15 -05:00
|
|
|
import_targets = columns.TemplateColumn(
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Import Targets'),
|
2022-07-06 08:57:15 -05:00
|
|
|
template_code=L2VPN_TARGETS,
|
|
|
|
orderable=False
|
|
|
|
)
|
|
|
|
export_targets = columns.TemplateColumn(
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Export Targets'),
|
2022-07-06 08:57:15 -05:00
|
|
|
template_code=L2VPN_TARGETS,
|
|
|
|
orderable=False
|
|
|
|
)
|
2023-08-01 01:35:28 +07:00
|
|
|
comments = columns.MarkdownColumn(
|
|
|
|
verbose_name=_('Comments'),
|
|
|
|
)
|
2022-11-04 08:28:09 -04:00
|
|
|
tags = columns.TagColumn(
|
2023-11-28 13:45:00 -05:00
|
|
|
url_name='vpn:l2vpn_list'
|
2022-11-04 08:28:09 -04:00
|
|
|
)
|
2022-06-27 23:24:50 -05:00
|
|
|
|
|
|
|
class Meta(NetBoxTable.Meta):
|
|
|
|
model = L2VPN
|
2022-07-11 21:51:39 -04:00
|
|
|
fields = (
|
2022-11-04 08:28:09 -04:00
|
|
|
'pk', 'name', 'slug', 'identifier', 'type', 'import_targets', 'export_targets', 'tenant', 'tenant_group',
|
2022-12-13 17:17:05 -05:00
|
|
|
'description', 'comments', 'tags', 'created', 'last_updated',
|
2022-07-11 21:51:39 -04:00
|
|
|
)
|
2022-12-13 14:04:50 -05:00
|
|
|
default_columns = ('pk', 'name', 'identifier', 'type', 'description')
|
2022-06-27 23:24:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
class L2VPNTerminationTable(NetBoxTable):
|
|
|
|
pk = columns.ToggleColumn()
|
2022-07-06 08:57:15 -05:00
|
|
|
l2vpn = tables.Column(
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('L2VPN'),
|
2022-07-06 08:57:15 -05:00
|
|
|
linkify=True
|
|
|
|
)
|
2022-06-27 23:24:50 -05:00
|
|
|
assigned_object_type = columns.ContentTypeColumn(
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Object Type')
|
2022-06-27 23:24:50 -05:00
|
|
|
)
|
|
|
|
assigned_object = tables.Column(
|
|
|
|
linkify=True,
|
2022-08-17 10:59:17 -04:00
|
|
|
orderable=False,
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Object')
|
2022-06-27 23:24:50 -05:00
|
|
|
)
|
2022-08-02 12:38:16 -05:00
|
|
|
assigned_object_parent = tables.Column(
|
|
|
|
linkify=True,
|
2022-08-17 10:59:17 -04:00
|
|
|
orderable=False,
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Object Parent')
|
2022-08-02 12:38:16 -05:00
|
|
|
)
|
|
|
|
assigned_object_site = tables.Column(
|
|
|
|
linkify=True,
|
2022-08-17 10:59:17 -04:00
|
|
|
orderable=False,
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Object Site')
|
2022-08-02 12:38:16 -05:00
|
|
|
)
|
2023-12-11 16:01:33 +05:30
|
|
|
tags = columns.TagColumn(
|
|
|
|
url_name='ipam:l2vpntermination_list'
|
|
|
|
)
|
2022-06-27 23:24:50 -05:00
|
|
|
|
|
|
|
class Meta(NetBoxTable.Meta):
|
|
|
|
model = L2VPNTermination
|
2022-08-17 10:59:17 -04:00
|
|
|
fields = (
|
|
|
|
'pk', 'l2vpn', 'assigned_object_type', 'assigned_object', 'assigned_object_parent', 'assigned_object_site',
|
2023-12-11 16:01:33 +05:30
|
|
|
'tags', 'actions',
|
2022-08-17 10:59:17 -04:00
|
|
|
)
|
|
|
|
default_columns = (
|
|
|
|
'pk', 'l2vpn', 'assigned_object_type', 'assigned_object_parent', 'assigned_object', 'actions',
|
|
|
|
)
|