2023-08-01 01:35:28 +07:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2016-03-01 11:23:03 -05:00
|
|
|
import django_tables2 as tables
|
2023-03-29 07:27:11 -05:00
|
|
|
|
2022-03-03 15:16:23 -05:00
|
|
|
from circuits.models import *
|
2022-10-18 13:47:14 -07:00
|
|
|
from tenancy.tables import ContactsColumnMixin, TenancyColumnsMixin
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
from netbox.tables import NetBoxTable, columns
|
2022-10-18 13:47:14 -07:00
|
|
|
|
2022-03-03 15:16:23 -05:00
|
|
|
from .columns import CommitRateColumn
|
2016-05-13 12:44:03 -04:00
|
|
|
|
2021-09-17 15:37:19 -04:00
|
|
|
__all__ = (
|
|
|
|
'CircuitTable',
|
2024-05-06 13:59:28 -07:00
|
|
|
'CircuitTerminationTable',
|
2021-09-17 15:37:19 -04:00
|
|
|
'CircuitTypeTable',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-04-05 15:24:57 -04:00
|
|
|
CIRCUITTERMINATION_LINK = """
|
|
|
|
{% if value.site %}
|
|
|
|
<a href="{{ value.site.get_absolute_url }}">{{ value.site }}</a>
|
|
|
|
{% elif value.provider_network %}
|
|
|
|
<a href="{{ value.provider_network.get_absolute_url }}">{{ value.provider_network }}</a>
|
|
|
|
{% endif %}
|
|
|
|
"""
|
|
|
|
|
2022-01-27 15:00:10 -05:00
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class CircuitTypeTable(NetBoxTable):
|
2021-04-02 16:59:53 -04:00
|
|
|
name = tables.Column(
|
2023-08-01 01:35:28 +07:00
|
|
|
linkify=True,
|
|
|
|
verbose_name=_('Name'),
|
2021-04-02 16:59:53 -04:00
|
|
|
)
|
2023-10-24 05:19:04 -07:00
|
|
|
color = columns.ColorColumn()
|
2022-01-27 15:00:10 -05:00
|
|
|
tags = columns.TagColumn(
|
2021-10-21 10:51:02 -04:00
|
|
|
url_name='circuits:circuittype_list'
|
|
|
|
)
|
2023-01-25 16:20:52 -05:00
|
|
|
circuit_count = columns.LinkedCountColumn(
|
|
|
|
viewname='circuits:circuit_list',
|
|
|
|
url_params={'type_id': 'pk'},
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Circuits')
|
2020-05-06 14:42:51 -04:00
|
|
|
)
|
2016-05-13 12:44:03 -04:00
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2016-05-13 12:44:03 -04:00
|
|
|
model = CircuitType
|
2022-01-17 11:12:54 -05:00
|
|
|
fields = (
|
2023-10-24 05:19:04 -07:00
|
|
|
'pk', 'id', 'name', 'circuit_count', 'color', 'description', 'slug', 'tags', 'created', 'last_updated', 'actions',
|
2022-01-17 11:12:54 -05:00
|
|
|
)
|
2022-01-07 10:36:58 -05:00
|
|
|
default_columns = ('pk', 'name', 'circuit_count', 'description', 'slug')
|
2016-05-13 12:44:03 -04:00
|
|
|
|
|
|
|
|
2022-10-18 13:47:14 -07:00
|
|
|
class CircuitTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
|
2021-04-02 16:59:53 -04:00
|
|
|
cid = tables.Column(
|
|
|
|
linkify=True,
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Circuit ID')
|
2020-05-06 14:42:51 -04:00
|
|
|
)
|
2021-02-26 17:23:23 -05:00
|
|
|
provider = tables.Column(
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Provider'),
|
2021-02-26 17:23:23 -05:00
|
|
|
linkify=True
|
2020-05-06 14:42:51 -04:00
|
|
|
)
|
2023-03-29 07:27:11 -05:00
|
|
|
provider_account = tables.Column(
|
|
|
|
linkify=True,
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Account')
|
2023-03-29 07:27:11 -05:00
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
status = columns.ChoiceFieldColumn()
|
2021-04-05 15:24:57 -04:00
|
|
|
termination_a = tables.TemplateColumn(
|
|
|
|
template_code=CIRCUITTERMINATION_LINK,
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Side A')
|
2019-06-27 12:30:17 -04:00
|
|
|
)
|
2021-04-05 15:24:57 -04:00
|
|
|
termination_z = tables.TemplateColumn(
|
|
|
|
template_code=CIRCUITTERMINATION_LINK,
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Side Z')
|
2019-06-27 12:30:17 -04:00
|
|
|
)
|
2023-04-10 16:35:21 -04:00
|
|
|
commit_rate = CommitRateColumn(
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Commit Rate')
|
|
|
|
)
|
|
|
|
comments = columns.MarkdownColumn(
|
|
|
|
verbose_name=_('Comments'),
|
2023-04-10 16:35:21 -04:00
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
tags = columns.TagColumn(
|
2020-05-06 14:42:51 -04:00
|
|
|
url_name='circuits:circuit_list'
|
|
|
|
)
|
2016-03-01 11:23:03 -05:00
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2016-03-01 11:23:03 -05:00
|
|
|
model = Circuit
|
2020-04-27 16:56:25 -04:00
|
|
|
fields = (
|
2023-03-29 07:27:11 -05:00
|
|
|
'pk', 'id', 'cid', 'provider', 'provider_account', 'type', 'status', 'tenant', 'tenant_group',
|
|
|
|
'termination_a', 'termination_z', 'install_date', 'termination_date', 'commit_rate', 'description',
|
|
|
|
'comments', 'contacts', 'tags', 'created', 'last_updated',
|
2021-03-18 13:54:05 -04:00
|
|
|
)
|
|
|
|
default_columns = (
|
|
|
|
'pk', 'cid', 'provider', 'type', 'status', 'tenant', 'termination_a', 'termination_z', 'description',
|
2020-04-27 16:56:25 -04:00
|
|
|
)
|
2024-05-06 13:59:28 -07:00
|
|
|
|
|
|
|
|
|
|
|
class CircuitTerminationTable(NetBoxTable):
|
2024-05-06 14:31:30 -07:00
|
|
|
circuit = tables.Column(
|
|
|
|
verbose_name=_('Circuit'),
|
|
|
|
linkify=True
|
|
|
|
)
|
2024-05-09 10:38:11 -07:00
|
|
|
circuit_provider = tables.Column(
|
|
|
|
verbose_name=_('Circuit Provider'),
|
|
|
|
linkify=True,
|
|
|
|
accessor='circuit.provider'
|
|
|
|
)
|
2024-05-06 14:31:30 -07:00
|
|
|
site = tables.Column(
|
|
|
|
verbose_name=_('Site'),
|
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
provider_network = tables.Column(
|
|
|
|
verbose_name=_('Provider Network'),
|
|
|
|
linkify=True
|
|
|
|
)
|
2024-05-06 13:59:28 -07:00
|
|
|
|
|
|
|
class Meta(NetBoxTable.Meta):
|
|
|
|
model = CircuitTermination
|
|
|
|
fields = (
|
2024-05-09 10:38:11 -07:00
|
|
|
'pk', 'id', 'circuit', 'circuit_provider', 'term_side', 'site', 'provider_network', 'port_speed', 'upstream_speed',
|
2024-05-06 14:25:03 -07:00
|
|
|
'xconnect_id', 'pp_info', 'description', 'created', 'last_updated', 'actions',
|
2024-05-06 13:59:28 -07:00
|
|
|
)
|
2024-05-09 10:38:11 -07:00
|
|
|
default_columns = ('pk', 'id', 'circuit', 'circuit_provider', 'term_side', 'description')
|