1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

72 lines
1.6 KiB
Python
Raw Normal View History

2021-09-17 15:37:19 -04:00
import django_tables2 as tables
from ipam.models import *
2022-01-27 15:48:05 -05:00
from netbox.tables import NetBoxTable, columns
from tenancy.tables import TenantColumn
2021-09-17 15:37:19 -04:00
__all__ = (
'RouteTargetTable',
'VRFTable',
)
VRF_TARGETS = """
{% for rt in value.all %}
<a href="{{ rt.get_absolute_url }}">{{ rt }}</a>{% if not forloop.last %}<br />{% endif %}
2021-09-17 15:37:19 -04:00
{% endfor %}
"""
#
# VRFs
#
2022-01-27 15:48:05 -05:00
class VRFTable(NetBoxTable):
2021-09-17 15:37:19 -04:00
name = tables.Column(
linkify=True
)
rd = tables.Column(
verbose_name='RD'
)
tenant = TenantColumn()
enforce_unique = columns.BooleanColumn(
2021-09-17 15:37:19 -04:00
verbose_name='Unique'
)
import_targets = columns.TemplateColumn(
2021-09-17 15:37:19 -04:00
template_code=VRF_TARGETS,
orderable=False
)
export_targets = columns.TemplateColumn(
2021-09-17 15:37:19 -04:00
template_code=VRF_TARGETS,
orderable=False
)
tags = columns.TagColumn(
2021-09-17 15:37:19 -04:00
url_name='ipam:vrf_list'
)
2022-01-27 15:48:05 -05:00
class Meta(NetBoxTable.Meta):
2021-09-17 15:37:19 -04:00
model = VRF
fields = (
2022-01-17 11:12:54 -05:00
'pk', 'id', 'name', 'rd', 'tenant', 'enforce_unique', 'description', 'import_targets', 'export_targets',
'tags', 'created', 'last_updated',
2021-09-17 15:37:19 -04:00
)
default_columns = ('pk', 'name', 'rd', 'tenant', 'description')
#
# Route targets
#
2022-01-27 15:48:05 -05:00
class RouteTargetTable(NetBoxTable):
2021-09-17 15:37:19 -04:00
name = tables.Column(
linkify=True
)
tenant = TenantColumn()
tags = columns.TagColumn(
2021-09-17 15:37:19 -04:00
url_name='ipam:vrf_list'
)
2022-01-27 15:48:05 -05:00
class Meta(NetBoxTable.Meta):
2021-09-17 15:37:19 -04:00
model = RouteTarget
2022-01-17 11:12:54 -05:00
fields = ('pk', 'id', 'name', 'tenant', 'description', 'tags', 'created', 'last_updated',)
2021-09-17 15:37:19 -04:00
default_columns = ('pk', 'name', 'tenant', 'description')