2023-08-01 01:35:28 +07:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2022-08-25 08:46:19 -04:00
|
|
|
import django_tables2 as tables
|
|
|
|
from django_tables2.utils import Accessor
|
|
|
|
|
|
|
|
from netbox.tables import BaseTable, columns
|
|
|
|
from dcim.models import ConsolePort, Interface, PowerPort
|
|
|
|
from .devices import PathEndpointTable
|
|
|
|
|
|
|
|
__all__ = (
|
|
|
|
'ConsoleConnectionTable',
|
|
|
|
'InterfaceConnectionTable',
|
|
|
|
'PowerConnectionTable',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Device connections
|
|
|
|
#
|
|
|
|
|
|
|
|
class ConsoleConnectionTable(PathEndpointTable):
|
|
|
|
device = tables.Column(
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Device'),
|
2022-08-25 08:46:19 -04:00
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
name = tables.Column(
|
|
|
|
linkify=True,
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Console Port')
|
2022-08-25 08:46:19 -04:00
|
|
|
)
|
|
|
|
reachable = columns.BooleanColumn(
|
|
|
|
accessor=Accessor('_path__is_active'),
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Reachable')
|
2022-08-25 08:46:19 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = ConsolePort
|
|
|
|
fields = ('device', 'name', 'connection', 'reachable')
|
|
|
|
|
|
|
|
|
|
|
|
class PowerConnectionTable(PathEndpointTable):
|
|
|
|
device = tables.Column(
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Device'),
|
2022-08-25 08:46:19 -04:00
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
name = tables.Column(
|
|
|
|
linkify=True,
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Power Port')
|
2022-08-25 08:46:19 -04:00
|
|
|
)
|
|
|
|
reachable = columns.BooleanColumn(
|
|
|
|
accessor=Accessor('_path__is_active'),
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Reachable')
|
2022-08-25 08:46:19 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = PowerPort
|
|
|
|
fields = ('device', 'name', 'connection', 'reachable')
|
|
|
|
|
|
|
|
|
|
|
|
class InterfaceConnectionTable(PathEndpointTable):
|
|
|
|
device = tables.Column(
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Device'),
|
2022-08-25 08:46:19 -04:00
|
|
|
accessor=Accessor('device'),
|
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
interface = tables.Column(
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Interface'),
|
2022-08-25 08:46:19 -04:00
|
|
|
accessor=Accessor('name'),
|
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
reachable = columns.BooleanColumn(
|
|
|
|
accessor=Accessor('_path__is_active'),
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Reachable')
|
2022-08-25 08:46:19 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = Interface
|
|
|
|
fields = ('device', 'interface', 'connection', 'reachable')
|