2020-10-16 10:39:13 -04:00
|
|
|
import django_tables2 as tables
|
2022-11-04 08:28:09 -04:00
|
|
|
from dcim import models
|
2022-10-18 13:47:14 -07:00
|
|
|
from django_tables2.utils import Accessor
|
|
|
|
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
|
|
|
|
2021-10-18 10:05:43 -04:00
|
|
|
from .template_code import *
|
2020-10-16 10:39:13 -04:00
|
|
|
|
|
|
|
__all__ = (
|
2021-09-17 15:37:19 -04:00
|
|
|
'BaseInterfaceTable',
|
2021-11-03 10:29:02 -04:00
|
|
|
'CableTerminationTable',
|
2020-10-16 10:39:13 -04:00
|
|
|
'ConsolePortTable',
|
|
|
|
'ConsoleServerPortTable',
|
2020-10-16 15:09:23 -04:00
|
|
|
'DeviceBayTable',
|
2020-10-16 14:39:15 -04:00
|
|
|
'DeviceConsolePortTable',
|
2020-10-16 15:01:16 -04:00
|
|
|
'DeviceConsoleServerPortTable',
|
2020-10-16 15:51:46 -04:00
|
|
|
'DeviceDeviceBayTable',
|
2020-10-16 15:28:28 -04:00
|
|
|
'DeviceFrontPortTable',
|
2020-10-16 10:39:13 -04:00
|
|
|
'DeviceImportTable',
|
2020-10-16 15:42:48 -04:00
|
|
|
'DeviceInterfaceTable',
|
2020-10-16 16:00:25 -04:00
|
|
|
'DeviceInventoryItemTable',
|
2021-12-17 09:35:57 -05:00
|
|
|
'DeviceModuleBayTable',
|
2020-10-16 15:09:23 -04:00
|
|
|
'DevicePowerPortTable',
|
2020-10-16 15:16:36 -04:00
|
|
|
'DevicePowerOutletTable',
|
2020-10-16 15:33:39 -04:00
|
|
|
'DeviceRearPortTable',
|
2020-10-16 10:39:13 -04:00
|
|
|
'DeviceRoleTable',
|
2020-10-16 15:09:23 -04:00
|
|
|
'DeviceTable',
|
2020-10-16 10:39:13 -04:00
|
|
|
'FrontPortTable',
|
|
|
|
'InterfaceTable',
|
2021-12-27 10:18:39 -05:00
|
|
|
'InventoryItemRoleTable',
|
2020-10-16 10:39:13 -04:00
|
|
|
'InventoryItemTable',
|
2021-12-17 09:35:57 -05:00
|
|
|
'ModuleBayTable',
|
2020-10-16 10:39:13 -04:00
|
|
|
'PlatformTable',
|
|
|
|
'PowerOutletTable',
|
|
|
|
'PowerPortTable',
|
|
|
|
'RearPortTable',
|
|
|
|
'VirtualChassisTable',
|
2022-11-11 06:55:49 -06:00
|
|
|
'VirtualDeviceContextTable'
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-03-29 10:53:02 -04:00
|
|
|
def get_cabletermination_row_class(record):
|
|
|
|
if record.mark_connected:
|
|
|
|
return 'success'
|
|
|
|
elif record.cable:
|
2022-02-16 08:23:57 -05:00
|
|
|
return record.cable.get_status_color()
|
2021-03-29 10:53:02 -04:00
|
|
|
return ''
|
|
|
|
|
|
|
|
|
2021-10-24 03:31:29 +01:00
|
|
|
def get_interface_row_class(record):
|
|
|
|
if not record.enabled:
|
|
|
|
return 'danger'
|
2021-11-11 16:36:13 +00:00
|
|
|
elif record.is_virtual:
|
2021-10-24 03:31:29 +01:00
|
|
|
return 'primary'
|
2021-11-11 16:36:13 +00:00
|
|
|
return get_cabletermination_row_class(record)
|
2021-10-24 03:31:29 +01:00
|
|
|
|
|
|
|
|
2021-05-26 16:32:09 -07:00
|
|
|
def get_interface_state_attribute(record):
|
|
|
|
"""
|
|
|
|
Get interface enabled state as string to attach to <tr/> DOM element.
|
|
|
|
"""
|
|
|
|
if record.enabled:
|
|
|
|
return "enabled"
|
|
|
|
else:
|
|
|
|
return "disabled"
|
|
|
|
|
2021-12-27 10:18:39 -05:00
|
|
|
|
2020-10-16 10:39:13 -04:00
|
|
|
#
|
|
|
|
# Device roles
|
|
|
|
#
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class DeviceRoleTable(NetBoxTable):
|
2021-03-26 14:44:43 -04:00
|
|
|
name = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
device_count = columns.LinkedCountColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
viewname='dcim:device_list',
|
2021-04-05 11:47:25 -04:00
|
|
|
url_params={'role_id': 'pk'},
|
2020-10-16 10:39:13 -04:00
|
|
|
verbose_name='Devices'
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
vm_count = columns.LinkedCountColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
viewname='virtualization:virtualmachine_list',
|
2021-04-05 11:47:25 -04:00
|
|
|
url_params={'role_id': 'pk'},
|
2020-10-16 10:39:13 -04:00
|
|
|
verbose_name='VMs'
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
color = columns.ColorColumn()
|
|
|
|
vm_role = columns.BooleanColumn()
|
|
|
|
tags = columns.TagColumn(
|
2021-10-21 10:51:02 -04:00
|
|
|
url_name='dcim:devicerole_list'
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.DeviceRole
|
2021-10-21 10:51:02 -04:00
|
|
|
fields = (
|
2021-11-03 10:29:02 -04:00
|
|
|
'pk', 'id', 'name', 'device_count', 'vm_count', 'color', 'vm_role', 'description', 'slug', 'tags',
|
2022-01-17 11:12:54 -05:00
|
|
|
'actions', 'created', 'last_updated',
|
2021-10-21 10:51:02 -04:00
|
|
|
)
|
2022-01-07 10:36:58 -05:00
|
|
|
default_columns = ('pk', 'name', 'device_count', 'vm_count', 'color', 'vm_role', 'description')
|
2020-10-16 10:39:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Platforms
|
|
|
|
#
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class PlatformTable(NetBoxTable):
|
2021-03-26 14:44:43 -04:00
|
|
|
name = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
device_count = columns.LinkedCountColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
viewname='dcim:device_list',
|
2021-04-05 11:47:25 -04:00
|
|
|
url_params={'platform_id': 'pk'},
|
2020-10-16 10:39:13 -04:00
|
|
|
verbose_name='Devices'
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
vm_count = columns.LinkedCountColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
viewname='virtualization:virtualmachine_list',
|
2021-04-05 11:47:25 -04:00
|
|
|
url_params={'platform_id': 'pk'},
|
2020-10-16 10:39:13 -04:00
|
|
|
verbose_name='VMs'
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
tags = columns.TagColumn(
|
2021-10-21 10:51:02 -04:00
|
|
|
url_name='dcim:platform_list'
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.Platform
|
2020-10-16 10:39:13 -04:00
|
|
|
fields = (
|
2021-11-02 16:21:34 -04:00
|
|
|
'pk', 'id', 'name', 'manufacturer', 'device_count', 'vm_count', 'slug', 'napalm_driver', 'napalm_args',
|
2022-01-17 11:12:54 -05:00
|
|
|
'description', 'tags', 'actions', 'created', 'last_updated',
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|
|
|
|
default_columns = (
|
2022-01-07 10:36:58 -05:00
|
|
|
'pk', 'name', 'manufacturer', 'device_count', 'vm_count', 'napalm_driver', 'description',
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Devices
|
|
|
|
#
|
|
|
|
|
2022-10-18 13:47:14 -07:00
|
|
|
class DeviceTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
|
2020-10-16 10:39:13 -04:00
|
|
|
name = tables.TemplateColumn(
|
|
|
|
order_by=('_name',),
|
2022-11-18 16:33:06 -05:00
|
|
|
template_code=DEVICE_LINK,
|
|
|
|
linkify=True
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
status = columns.ChoiceFieldColumn()
|
2022-09-15 12:55:21 -04:00
|
|
|
region = tables.Column(
|
|
|
|
accessor=Accessor('site__region'),
|
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
site_group = tables.Column(
|
|
|
|
accessor=Accessor('site__group'),
|
|
|
|
linkify=True,
|
|
|
|
verbose_name='Site Group'
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
site = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2021-03-03 14:28:07 -05:00
|
|
|
location = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
rack = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-09-07 14:09:17 -04:00
|
|
|
position = columns.TemplateColumn(
|
|
|
|
template_code='{{ value|floatformat }}'
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
device_role = columns.ColoredLabelColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
verbose_name='Role'
|
|
|
|
)
|
2021-04-02 17:02:12 -04:00
|
|
|
manufacturer = tables.Column(
|
|
|
|
accessor=Accessor('device_type__manufacturer'),
|
|
|
|
linkify=True
|
|
|
|
)
|
2021-04-02 16:59:53 -04:00
|
|
|
device_type = tables.Column(
|
|
|
|
linkify=True,
|
|
|
|
verbose_name='Type'
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|
2021-10-25 14:42:20 -04:00
|
|
|
primary_ip = tables.Column(
|
|
|
|
linkify=True,
|
|
|
|
order_by=('primary_ip4', 'primary_ip6'),
|
|
|
|
verbose_name='IP Address'
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
primary_ip4 = tables.Column(
|
|
|
|
linkify=True,
|
|
|
|
verbose_name='IPv4 Address'
|
|
|
|
)
|
|
|
|
primary_ip6 = tables.Column(
|
|
|
|
linkify=True,
|
|
|
|
verbose_name='IPv6 Address'
|
|
|
|
)
|
2021-04-02 16:59:53 -04:00
|
|
|
cluster = tables.Column(
|
|
|
|
linkify=True
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|
2021-04-02 16:59:53 -04:00
|
|
|
virtual_chassis = tables.Column(
|
|
|
|
linkify=True
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|
|
|
|
vc_position = tables.Column(
|
|
|
|
verbose_name='VC Position'
|
|
|
|
)
|
|
|
|
vc_priority = tables.Column(
|
|
|
|
verbose_name='VC Priority'
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
comments = columns.MarkdownColumn()
|
|
|
|
tags = columns.TagColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
url_name='dcim:device_list'
|
|
|
|
)
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.Device
|
2020-10-16 10:39:13 -04:00
|
|
|
fields = (
|
2022-09-07 14:09:17 -04:00
|
|
|
'pk', 'id', 'name', 'status', 'tenant', 'tenant_group', 'device_role', 'manufacturer', 'device_type',
|
2022-09-15 12:55:21 -04:00
|
|
|
'platform', 'serial', 'asset_tag', 'region', 'site_group', 'site', 'location', 'rack', 'position', 'face',
|
|
|
|
'airflow', 'primary_ip', 'primary_ip4', 'primary_ip6', 'cluster', 'virtual_chassis', 'vc_position',
|
2022-11-04 08:28:09 -04:00
|
|
|
'vc_priority', 'description', 'comments', 'contacts', 'tags', 'created', 'last_updated',
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|
|
|
|
default_columns = (
|
2021-04-02 17:02:12 -04:00
|
|
|
'pk', 'name', 'status', 'tenant', 'site', 'location', 'rack', 'device_role', 'manufacturer', 'device_type',
|
|
|
|
'primary_ip',
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-07-10 15:13:48 +02:00
|
|
|
class DeviceImportTable(TenancyColumnsMixin, NetBoxTable):
|
2020-10-16 10:39:13 -04:00
|
|
|
name = tables.TemplateColumn(
|
2022-11-18 16:33:06 -05:00
|
|
|
template_code=DEVICE_LINK,
|
|
|
|
linkify=True
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
status = columns.ChoiceFieldColumn()
|
2020-10-16 10:39:13 -04:00
|
|
|
site = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
rack = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
device_role = tables.Column(
|
|
|
|
verbose_name='Role'
|
|
|
|
)
|
|
|
|
device_type = tables.Column(
|
|
|
|
verbose_name='Type'
|
|
|
|
)
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.Device
|
2022-07-10 15:13:48 +02:00
|
|
|
fields = ('id', 'name', 'status', 'tenant', 'tenant_group', 'site', 'rack', 'position', 'device_role', 'device_type')
|
2020-10-16 10:39:13 -04:00
|
|
|
empty_text = False
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Device components
|
|
|
|
#
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class DeviceComponentTable(NetBoxTable):
|
2020-10-16 10:39:13 -04:00
|
|
|
device = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
name = tables.Column(
|
|
|
|
linkify=True,
|
|
|
|
order_by=('_name',)
|
|
|
|
)
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2020-10-16 10:39:13 -04:00
|
|
|
order_by = ('device', 'name')
|
|
|
|
|
|
|
|
|
2021-12-17 20:15:49 -05:00
|
|
|
class ModularDeviceComponentTable(DeviceComponentTable):
|
|
|
|
module_bay = tables.Column(
|
|
|
|
accessor=Accessor('module__module_bay'),
|
|
|
|
linkify={
|
|
|
|
'viewname': 'dcim:device_modulebays',
|
|
|
|
'args': [Accessor('device_id')],
|
|
|
|
}
|
|
|
|
)
|
|
|
|
module = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class CableTerminationTable(NetBoxTable):
|
2020-10-16 11:11:41 -04:00
|
|
|
cable = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
cable_color = columns.ColorColumn(
|
2022-02-02 09:18:50 -05:00
|
|
|
accessor='cable__color',
|
2021-03-31 15:49:29 -04:00
|
|
|
orderable=False,
|
|
|
|
verbose_name='Cable Color'
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
link_peer = columns.TemplateColumn(
|
2022-07-14 10:37:27 -04:00
|
|
|
accessor='link_peers',
|
2021-10-13 14:04:53 -04:00
|
|
|
template_code=LINKTERMINATION,
|
2020-10-30 13:57:17 -04:00
|
|
|
orderable=False,
|
2022-07-14 10:37:27 -04:00
|
|
|
verbose_name='Link Peers'
|
2020-10-16 11:11:41 -04:00
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
mark_connected = columns.BooleanColumn()
|
2020-10-16 11:11:41 -04:00
|
|
|
|
|
|
|
|
2020-10-16 11:41:24 -04:00
|
|
|
class PathEndpointTable(CableTerminationTable):
|
2022-01-27 15:00:10 -05:00
|
|
|
connection = columns.TemplateColumn(
|
2022-07-14 10:37:27 -04:00
|
|
|
accessor='_path__destinations',
|
2021-10-13 14:04:53 -04:00
|
|
|
template_code=LINKTERMINATION,
|
2020-10-16 11:41:24 -04:00
|
|
|
verbose_name='Connection',
|
|
|
|
orderable=False
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-12-17 20:15:49 -05:00
|
|
|
class ConsolePortTable(ModularDeviceComponentTable, PathEndpointTable):
|
2021-03-29 12:06:39 -04:00
|
|
|
device = tables.Column(
|
|
|
|
linkify={
|
|
|
|
'viewname': 'dcim:device_consoleports',
|
|
|
|
'args': [Accessor('device_id')],
|
|
|
|
}
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
tags = columns.TagColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
url_name='dcim:consoleport_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.ConsolePort
|
2020-10-16 11:41:24 -04:00
|
|
|
fields = (
|
2021-12-17 20:15:49 -05:00
|
|
|
'pk', 'id', 'name', 'device', 'module_bay', 'module', 'label', 'type', 'speed', 'description',
|
2022-01-17 11:12:54 -05:00
|
|
|
'mark_connected', 'cable', 'cable_color', 'link_peer', 'connection', 'tags', 'created', 'last_updated',
|
2020-10-16 11:41:24 -04:00
|
|
|
)
|
2021-08-25 15:18:00 -04:00
|
|
|
default_columns = ('pk', 'name', 'device', 'label', 'type', 'speed', 'description')
|
2020-10-16 10:39:13 -04:00
|
|
|
|
|
|
|
|
2020-10-16 14:39:15 -04:00
|
|
|
class DeviceConsolePortTable(ConsolePortTable):
|
|
|
|
name = tables.TemplateColumn(
|
2020-11-13 13:14:10 -05:00
|
|
|
template_code='<i class="mdi mdi-console"></i> <a href="{{ record.get_absolute_url }}">{{ value }}</a>',
|
2021-04-20 20:21:52 -04:00
|
|
|
order_by=Accessor('_name'),
|
2020-11-13 13:14:10 -05:00
|
|
|
attrs={'td': {'class': 'text-nowrap'}}
|
2020-10-16 14:39:15 -04:00
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
actions = columns.ActionsColumn(
|
2022-01-10 11:17:40 -05:00
|
|
|
extra_buttons=CONSOLEPORT_BUTTONS
|
2020-10-16 14:39:15 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.ConsolePort
|
2020-10-16 14:39:15 -04:00
|
|
|
fields = (
|
2021-12-17 20:15:49 -05:00
|
|
|
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'speed', 'description', 'mark_connected',
|
|
|
|
'cable', 'cable_color', 'link_peer', 'connection', 'tags', 'actions'
|
2020-10-16 14:39:15 -04:00
|
|
|
)
|
2022-01-07 10:36:58 -05:00
|
|
|
default_columns = ('pk', 'name', 'label', 'type', 'speed', 'description', 'cable', 'connection')
|
2020-10-16 14:39:15 -04:00
|
|
|
row_attrs = {
|
2021-03-29 10:53:02 -04:00
|
|
|
'class': get_cabletermination_row_class
|
2020-10-16 14:39:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-17 20:15:49 -05:00
|
|
|
class ConsoleServerPortTable(ModularDeviceComponentTable, PathEndpointTable):
|
2021-03-29 12:06:39 -04:00
|
|
|
device = tables.Column(
|
|
|
|
linkify={
|
|
|
|
'viewname': 'dcim:device_consoleserverports',
|
|
|
|
'args': [Accessor('device_id')],
|
|
|
|
}
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
tags = columns.TagColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
url_name='dcim:consoleserverport_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.ConsoleServerPort
|
2021-03-01 21:34:42 -05:00
|
|
|
fields = (
|
2021-12-17 20:15:49 -05:00
|
|
|
'pk', 'id', 'name', 'device', 'module_bay', 'module', 'label', 'type', 'speed', 'description',
|
2022-01-17 11:12:54 -05:00
|
|
|
'mark_connected', 'cable', 'cable_color', 'link_peer', 'connection', 'tags', 'created', 'last_updated',
|
2021-03-01 21:34:42 -05:00
|
|
|
)
|
2021-08-25 15:18:00 -04:00
|
|
|
default_columns = ('pk', 'name', 'device', 'label', 'type', 'speed', 'description')
|
2020-10-16 10:39:13 -04:00
|
|
|
|
|
|
|
|
2020-10-16 15:01:16 -04:00
|
|
|
class DeviceConsoleServerPortTable(ConsoleServerPortTable):
|
|
|
|
name = tables.TemplateColumn(
|
2020-11-13 13:14:10 -05:00
|
|
|
template_code='<i class="mdi mdi-console-network-outline"></i> '
|
|
|
|
'<a href="{{ record.get_absolute_url }}">{{ value }}</a>',
|
2021-04-20 20:21:52 -04:00
|
|
|
order_by=Accessor('_name'),
|
2020-11-13 13:14:10 -05:00
|
|
|
attrs={'td': {'class': 'text-nowrap'}}
|
2020-10-16 15:01:16 -04:00
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
actions = columns.ActionsColumn(
|
2022-01-10 11:17:40 -05:00
|
|
|
extra_buttons=CONSOLESERVERPORT_BUTTONS
|
2020-10-16 15:01:16 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.ConsoleServerPort
|
2020-10-16 15:01:16 -04:00
|
|
|
fields = (
|
2021-12-17 20:15:49 -05:00
|
|
|
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'speed', 'description', 'mark_connected',
|
|
|
|
'cable', 'cable_color', 'link_peer', 'connection', 'tags', 'actions',
|
2020-10-16 15:01:16 -04:00
|
|
|
)
|
2022-01-07 10:36:58 -05:00
|
|
|
default_columns = ('pk', 'name', 'label', 'type', 'speed', 'description', 'cable', 'connection')
|
2020-10-16 15:01:16 -04:00
|
|
|
row_attrs = {
|
2021-03-29 10:53:02 -04:00
|
|
|
'class': get_cabletermination_row_class
|
2020-10-16 15:01:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-17 20:15:49 -05:00
|
|
|
class PowerPortTable(ModularDeviceComponentTable, PathEndpointTable):
|
2021-03-29 12:06:39 -04:00
|
|
|
device = tables.Column(
|
|
|
|
linkify={
|
|
|
|
'viewname': 'dcim:device_powerports',
|
|
|
|
'args': [Accessor('device_id')],
|
|
|
|
}
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
tags = columns.TagColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
url_name='dcim:powerport_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.PowerPort
|
2020-10-16 10:39:13 -04:00
|
|
|
fields = (
|
2021-12-17 20:15:49 -05:00
|
|
|
'pk', 'id', 'name', 'device', 'module_bay', 'module', 'label', 'type', 'description', 'mark_connected',
|
2022-01-17 11:12:54 -05:00
|
|
|
'maximum_draw', 'allocated_draw', 'cable', 'cable_color', 'link_peer', 'connection', 'tags', 'created',
|
|
|
|
'last_updated',
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|
2021-08-25 15:18:00 -04:00
|
|
|
default_columns = ('pk', 'name', 'device', 'label', 'type', 'maximum_draw', 'allocated_draw', 'description')
|
2020-10-16 10:39:13 -04:00
|
|
|
|
|
|
|
|
2020-10-16 15:09:23 -04:00
|
|
|
class DevicePowerPortTable(PowerPortTable):
|
|
|
|
name = tables.TemplateColumn(
|
2020-11-13 13:14:10 -05:00
|
|
|
template_code='<i class="mdi mdi-power-plug-outline"></i> <a href="{{ record.get_absolute_url }}">'
|
|
|
|
'{{ value }}</a>',
|
2021-04-20 20:21:52 -04:00
|
|
|
order_by=Accessor('_name'),
|
2020-11-13 13:14:10 -05:00
|
|
|
attrs={'td': {'class': 'text-nowrap'}}
|
2020-10-16 15:09:23 -04:00
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
actions = columns.ActionsColumn(
|
2022-01-10 11:17:40 -05:00
|
|
|
extra_buttons=POWERPORT_BUTTONS
|
2020-10-16 15:09:23 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.PowerPort
|
2020-10-16 15:09:23 -04:00
|
|
|
fields = (
|
2021-12-17 20:15:49 -05:00
|
|
|
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'maximum_draw', 'allocated_draw',
|
|
|
|
'description', 'mark_connected', 'cable', 'cable_color', 'link_peer', 'connection', 'tags', 'actions',
|
2020-10-16 15:09:23 -04:00
|
|
|
)
|
|
|
|
default_columns = (
|
2020-10-19 13:44:51 -04:00
|
|
|
'pk', 'name', 'label', 'type', 'maximum_draw', 'allocated_draw', 'description', 'cable', 'connection',
|
2020-10-16 15:09:23 -04:00
|
|
|
)
|
|
|
|
row_attrs = {
|
2021-03-29 10:53:02 -04:00
|
|
|
'class': get_cabletermination_row_class
|
2020-10-16 15:09:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-17 20:15:49 -05:00
|
|
|
class PowerOutletTable(ModularDeviceComponentTable, PathEndpointTable):
|
2021-03-29 12:06:39 -04:00
|
|
|
device = tables.Column(
|
|
|
|
linkify={
|
|
|
|
'viewname': 'dcim:device_poweroutlets',
|
|
|
|
'args': [Accessor('device_id')],
|
|
|
|
}
|
|
|
|
)
|
2020-10-16 16:33:08 -04:00
|
|
|
power_port = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
tags = columns.TagColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
url_name='dcim:poweroutlet_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.PowerOutlet
|
2020-10-16 11:11:41 -04:00
|
|
|
fields = (
|
2021-12-17 20:15:49 -05:00
|
|
|
'pk', 'id', 'name', 'device', 'module_bay', 'module', 'label', 'type', 'description', 'power_port',
|
2022-01-17 11:12:54 -05:00
|
|
|
'feed_leg', 'mark_connected', 'cable', 'cable_color', 'link_peer', 'connection', 'tags', 'created',
|
|
|
|
'last_updated',
|
2020-10-16 11:11:41 -04:00
|
|
|
)
|
2021-08-25 15:18:00 -04:00
|
|
|
default_columns = ('pk', 'name', 'device', 'label', 'type', 'power_port', 'feed_leg', 'description')
|
2020-10-16 10:39:13 -04:00
|
|
|
|
|
|
|
|
2020-10-16 15:16:36 -04:00
|
|
|
class DevicePowerOutletTable(PowerOutletTable):
|
|
|
|
name = tables.TemplateColumn(
|
2020-11-13 13:14:10 -05:00
|
|
|
template_code='<i class="mdi mdi-power-socket"></i> <a href="{{ record.get_absolute_url }}">{{ value }}</a>',
|
2021-04-20 20:21:52 -04:00
|
|
|
order_by=Accessor('_name'),
|
2020-11-13 13:14:10 -05:00
|
|
|
attrs={'td': {'class': 'text-nowrap'}}
|
2020-10-16 15:16:36 -04:00
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
actions = columns.ActionsColumn(
|
2022-01-10 11:17:40 -05:00
|
|
|
extra_buttons=POWEROUTLET_BUTTONS
|
2020-10-16 15:16:36 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.PowerOutlet
|
2020-10-16 15:16:36 -04:00
|
|
|
fields = (
|
2021-12-17 20:15:49 -05:00
|
|
|
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'power_port', 'feed_leg', 'description',
|
|
|
|
'mark_connected', 'cable', 'cable_color', 'link_peer', 'connection', 'tags', 'actions',
|
2020-10-16 15:16:36 -04:00
|
|
|
)
|
|
|
|
default_columns = (
|
2022-01-07 10:36:58 -05:00
|
|
|
'pk', 'name', 'label', 'type', 'power_port', 'feed_leg', 'description', 'cable', 'connection',
|
2020-10-16 15:16:36 -04:00
|
|
|
)
|
|
|
|
row_attrs = {
|
2021-03-29 10:53:02 -04:00
|
|
|
'class': get_cabletermination_row_class
|
2020-10-16 15:16:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class BaseInterfaceTable(NetBoxTable):
|
2022-01-27 15:00:10 -05:00
|
|
|
enabled = columns.BooleanColumn()
|
2020-10-16 10:39:13 -04:00
|
|
|
ip_addresses = tables.TemplateColumn(
|
|
|
|
template_code=INTERFACE_IPADDRESSES,
|
|
|
|
orderable=False,
|
|
|
|
verbose_name='IP Addresses'
|
|
|
|
)
|
2021-11-19 10:27:56 -05:00
|
|
|
fhrp_groups = tables.TemplateColumn(
|
|
|
|
accessor=Accessor('fhrp_group_assignments'),
|
|
|
|
template_code=INTERFACE_FHRPGROUPS,
|
|
|
|
orderable=False,
|
|
|
|
verbose_name='FHRP Groups'
|
|
|
|
)
|
2022-09-02 14:26:35 -04:00
|
|
|
l2vpn = tables.Column(
|
|
|
|
accessor=tables.A('l2vpn_termination__l2vpn'),
|
|
|
|
linkify=True,
|
|
|
|
orderable=False,
|
|
|
|
verbose_name='L2VPN'
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
untagged_vlan = tables.Column(linkify=True)
|
2022-01-27 15:00:10 -05:00
|
|
|
tagged_vlans = columns.TemplateColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
template_code=INTERFACE_TAGGED_VLANS,
|
|
|
|
orderable=False,
|
|
|
|
verbose_name='Tagged VLANs'
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-12-17 20:15:49 -05:00
|
|
|
class InterfaceTable(ModularDeviceComponentTable, BaseInterfaceTable, PathEndpointTable):
|
2021-03-29 12:06:39 -04:00
|
|
|
device = tables.Column(
|
|
|
|
linkify={
|
|
|
|
'viewname': 'dcim:device_interfaces',
|
|
|
|
'args': [Accessor('device_id')],
|
|
|
|
}
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
mgmt_only = columns.BooleanColumn()
|
2021-10-13 14:04:53 -04:00
|
|
|
wireless_link = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
wireless_lans = columns.TemplateColumn(
|
2021-10-18 10:05:43 -04:00
|
|
|
template_code=INTERFACE_WIRELESS_LANS,
|
|
|
|
orderable=False,
|
|
|
|
verbose_name='Wireless LANs'
|
|
|
|
)
|
2022-11-17 12:29:30 -05:00
|
|
|
vdcs = columns.ManyToManyColumn(
|
|
|
|
linkify_item=True,
|
|
|
|
verbose_name='VDCs'
|
|
|
|
)
|
2022-01-07 14:57:43 -05:00
|
|
|
vrf = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
tags = columns.TagColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
url_name='dcim:interface_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.Interface
|
2020-10-16 10:39:13 -04:00
|
|
|
fields = (
|
2021-12-17 20:15:49 -05:00
|
|
|
'pk', 'id', 'name', 'device', 'module_bay', 'module', 'label', 'enabled', 'type', 'mgmt_only', 'mtu',
|
2022-06-21 21:22:24 -04:00
|
|
|
'speed', 'duplex', 'mode', 'mac_address', 'wwn', 'poe_mode', 'poe_type', 'rf_role', 'rf_channel',
|
|
|
|
'rf_channel_frequency', 'rf_channel_width', 'tx_power', 'description', 'mark_connected', 'cable',
|
2022-11-17 12:29:30 -05:00
|
|
|
'cable_color', 'wireless_link', 'wireless_lans', 'link_peer', 'connection', 'tags', 'vdcs', 'vrf', 'l2vpn',
|
2022-09-02 14:26:35 -04:00
|
|
|
'ip_addresses', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', 'created', 'last_updated',
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|
2021-08-25 15:18:00 -04:00
|
|
|
default_columns = ('pk', 'name', 'device', 'label', 'enabled', 'type', 'description')
|
2020-10-16 10:39:13 -04:00
|
|
|
|
|
|
|
|
2020-10-16 15:42:48 -04:00
|
|
|
class DeviceInterfaceTable(InterfaceTable):
|
|
|
|
name = tables.TemplateColumn(
|
2021-10-24 03:24:54 +01:00
|
|
|
template_code='<i class="mdi mdi-{% if record.mgmt_only %}wrench{% elif record.is_lag %}reorder-horizontal'
|
2021-10-15 12:24:07 -04:00
|
|
|
'{% elif record.is_virtual %}circle{% elif record.is_wireless %}wifi{% else %}ethernet'
|
2020-11-13 13:14:10 -05:00
|
|
|
'{% endif %}"></i> <a href="{{ record.get_absolute_url }}">{{ value }}</a>',
|
2021-04-20 20:21:52 -04:00
|
|
|
order_by=Accessor('_name'),
|
2020-11-13 13:14:10 -05:00
|
|
|
attrs={'td': {'class': 'text-nowrap'}}
|
2020-10-16 15:42:48 -04:00
|
|
|
)
|
2021-03-05 13:49:41 -05:00
|
|
|
parent = tables.Column(
|
2021-10-21 16:30:18 -04:00
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
bridge = tables.Column(
|
|
|
|
linkify=True
|
2021-03-05 13:49:41 -05:00
|
|
|
)
|
2020-10-16 16:33:08 -04:00
|
|
|
lag = tables.Column(
|
|
|
|
linkify=True,
|
|
|
|
verbose_name='LAG'
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
actions = columns.ActionsColumn(
|
2022-01-10 11:17:40 -05:00
|
|
|
extra_buttons=INTERFACE_BUTTONS
|
2020-10-16 15:42:48 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.Interface
|
2020-10-16 15:42:48 -04:00
|
|
|
fields = (
|
2021-12-17 20:15:49 -05:00
|
|
|
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'enabled', 'type', 'parent', 'bridge', 'lag',
|
|
|
|
'mgmt_only', 'mtu', 'mode', 'mac_address', 'wwn', 'rf_role', 'rf_channel', 'rf_channel_frequency',
|
|
|
|
'rf_channel_width', 'tx_power', 'description', 'mark_connected', 'cable', 'cable_color', 'wireless_link',
|
2022-11-17 12:29:30 -05:00
|
|
|
'wireless_lans', 'link_peer', 'connection', 'tags', 'vdcs', 'vrf', 'l2vpn', 'ip_addresses', 'fhrp_groups',
|
2022-09-02 14:26:35 -04:00
|
|
|
'untagged_vlan', 'tagged_vlans', 'actions',
|
2020-10-16 15:42:48 -04:00
|
|
|
)
|
2021-05-04 09:12:26 -04:00
|
|
|
order_by = ('name',)
|
2020-10-16 15:42:48 -04:00
|
|
|
default_columns = (
|
2021-03-05 13:49:41 -05:00
|
|
|
'pk', 'name', 'label', 'enabled', 'type', 'parent', 'lag', 'mtu', 'mode', 'description', 'ip_addresses',
|
2022-01-07 10:36:58 -05:00
|
|
|
'cable', 'connection',
|
2020-10-16 15:42:48 -04:00
|
|
|
)
|
|
|
|
row_attrs = {
|
2021-10-24 03:31:29 +01:00
|
|
|
'class': get_interface_row_class,
|
2020-12-18 15:02:52 -05:00
|
|
|
'data-name': lambda record: record.name,
|
2021-05-26 16:32:09 -07:00
|
|
|
'data-enabled': get_interface_state_attribute,
|
2020-10-16 15:42:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-17 20:15:49 -05:00
|
|
|
class FrontPortTable(ModularDeviceComponentTable, CableTerminationTable):
|
2021-03-29 12:06:39 -04:00
|
|
|
device = tables.Column(
|
|
|
|
linkify={
|
|
|
|
'viewname': 'dcim:device_frontports',
|
|
|
|
'args': [Accessor('device_id')],
|
|
|
|
}
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
color = columns.ColorColumn()
|
2020-10-16 10:39:13 -04:00
|
|
|
rear_port_position = tables.Column(
|
|
|
|
verbose_name='Position'
|
|
|
|
)
|
2020-10-16 16:33:08 -04:00
|
|
|
rear_port = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
tags = columns.TagColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
url_name='dcim:frontport_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.FrontPort
|
2020-10-16 10:39:13 -04:00
|
|
|
fields = (
|
2021-12-17 20:15:49 -05:00
|
|
|
'pk', 'id', 'name', 'device', 'module_bay', 'module', 'label', 'type', 'color', 'rear_port',
|
|
|
|
'rear_port_position', 'description', 'mark_connected', 'cable', 'cable_color', 'link_peer', 'tags',
|
2022-01-17 11:12:54 -05:00
|
|
|
'created', 'last_updated',
|
2021-06-09 16:51:51 -04:00
|
|
|
)
|
|
|
|
default_columns = (
|
2021-08-25 15:18:00 -04:00
|
|
|
'pk', 'name', 'device', 'label', 'type', 'color', 'rear_port', 'rear_port_position', 'description',
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-10-16 15:28:28 -04:00
|
|
|
class DeviceFrontPortTable(FrontPortTable):
|
|
|
|
name = tables.TemplateColumn(
|
2020-11-06 15:06:45 -05:00
|
|
|
template_code='<i class="mdi mdi-square-rounded{% if not record.cable %}-outline{% endif %}"></i> '
|
2020-11-13 13:14:10 -05:00
|
|
|
'<a href="{{ record.get_absolute_url }}">{{ value }}</a>',
|
2021-04-20 20:21:52 -04:00
|
|
|
order_by=Accessor('_name'),
|
2020-11-13 13:14:10 -05:00
|
|
|
attrs={'td': {'class': 'text-nowrap'}}
|
2020-10-16 15:28:28 -04:00
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
actions = columns.ActionsColumn(
|
2022-01-10 11:17:40 -05:00
|
|
|
extra_buttons=FRONTPORT_BUTTONS
|
2020-10-16 15:28:28 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.FrontPort
|
2020-10-16 15:28:28 -04:00
|
|
|
fields = (
|
2021-12-17 20:15:49 -05:00
|
|
|
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'rear_port', 'rear_port_position',
|
|
|
|
'description', 'mark_connected', 'cable', 'cable_color', 'link_peer', 'tags', 'actions',
|
2020-10-16 15:28:28 -04:00
|
|
|
)
|
|
|
|
default_columns = (
|
2021-10-13 14:04:53 -04:00
|
|
|
'pk', 'name', 'label', 'type', 'rear_port', 'rear_port_position', 'description', 'cable', 'link_peer',
|
2020-10-16 15:28:28 -04:00
|
|
|
)
|
|
|
|
row_attrs = {
|
2021-03-29 10:53:02 -04:00
|
|
|
'class': get_cabletermination_row_class
|
2020-10-16 15:28:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-17 20:15:49 -05:00
|
|
|
class RearPortTable(ModularDeviceComponentTable, CableTerminationTable):
|
2021-03-29 12:06:39 -04:00
|
|
|
device = tables.Column(
|
|
|
|
linkify={
|
|
|
|
'viewname': 'dcim:device_rearports',
|
|
|
|
'args': [Accessor('device_id')],
|
|
|
|
}
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
color = columns.ColorColumn()
|
|
|
|
tags = columns.TagColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
url_name='dcim:rearport_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.RearPort
|
2021-03-01 21:34:42 -05:00
|
|
|
fields = (
|
2021-12-17 20:15:49 -05:00
|
|
|
'pk', 'id', 'name', 'device', 'module_bay', 'module', 'label', 'type', 'color', 'positions', 'description',
|
2022-01-17 11:12:54 -05:00
|
|
|
'mark_connected', 'cable', 'cable_color', 'link_peer', 'tags', 'created', 'last_updated',
|
2021-03-01 21:34:42 -05:00
|
|
|
)
|
2021-08-25 15:18:00 -04:00
|
|
|
default_columns = ('pk', 'name', 'device', 'label', 'type', 'color', 'description')
|
2020-10-16 10:39:13 -04:00
|
|
|
|
|
|
|
|
2020-10-16 15:33:39 -04:00
|
|
|
class DeviceRearPortTable(RearPortTable):
|
|
|
|
name = tables.TemplateColumn(
|
2020-11-16 13:17:43 -05:00
|
|
|
template_code='<i class="mdi mdi-square-rounded{% if not record.cable %}-outline{% endif %}"></i> '
|
2020-11-13 13:14:10 -05:00
|
|
|
'<a href="{{ record.get_absolute_url }}">{{ value }}</a>',
|
2021-04-20 20:21:52 -04:00
|
|
|
order_by=Accessor('_name'),
|
2020-11-13 13:14:10 -05:00
|
|
|
attrs={'td': {'class': 'text-nowrap'}}
|
2020-10-16 15:33:39 -04:00
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
actions = columns.ActionsColumn(
|
2022-01-10 11:17:40 -05:00
|
|
|
extra_buttons=REARPORT_BUTTONS
|
2020-10-16 15:33:39 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.RearPort
|
2020-10-16 15:33:39 -04:00
|
|
|
fields = (
|
2021-12-17 20:15:49 -05:00
|
|
|
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'positions', 'description', 'mark_connected',
|
|
|
|
'cable', 'cable_color', 'link_peer', 'tags', 'actions',
|
2020-10-16 15:33:39 -04:00
|
|
|
)
|
|
|
|
default_columns = (
|
2022-01-07 10:36:58 -05:00
|
|
|
'pk', 'name', 'label', 'type', 'positions', 'description', 'cable', 'link_peer',
|
2020-10-16 15:33:39 -04:00
|
|
|
)
|
|
|
|
row_attrs = {
|
2021-03-29 10:53:02 -04:00
|
|
|
'class': get_cabletermination_row_class
|
2020-10-16 15:33:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-16 10:39:13 -04:00
|
|
|
class DeviceBayTable(DeviceComponentTable):
|
2021-03-29 12:06:39 -04:00
|
|
|
device = tables.Column(
|
|
|
|
linkify={
|
|
|
|
'viewname': 'dcim:device_devicebays',
|
|
|
|
'args': [Accessor('device_id')],
|
|
|
|
}
|
|
|
|
)
|
2022-03-25 10:38:44 -04:00
|
|
|
device_role = columns.ColoredLabelColumn(
|
2022-03-25 09:25:55 +00:00
|
|
|
accessor=Accessor('installed_device__device_role'),
|
|
|
|
verbose_name='Role'
|
|
|
|
)
|
|
|
|
device_type = tables.Column(
|
|
|
|
accessor=Accessor('installed_device__device_type'),
|
|
|
|
linkify=True,
|
|
|
|
verbose_name='Type'
|
|
|
|
)
|
2020-10-16 16:33:08 -04:00
|
|
|
status = tables.TemplateColumn(
|
2021-11-11 14:05:39 +01:00
|
|
|
template_code=DEVICEBAY_STATUS,
|
|
|
|
order_by=Accessor('installed_device__status')
|
2020-10-16 16:33:08 -04:00
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
installed_device = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
tags = columns.TagColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
url_name='dcim:devicebay_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.DeviceBay
|
2022-01-17 11:12:54 -05:00
|
|
|
fields = (
|
2022-03-25 09:25:55 +00:00
|
|
|
'pk', 'id', 'name', 'device', 'label', 'status', 'device_role', 'device_type', 'installed_device', 'description', 'tags',
|
2022-01-17 11:12:54 -05:00
|
|
|
'created', 'last_updated',
|
|
|
|
)
|
|
|
|
|
2021-08-25 15:18:00 -04:00
|
|
|
default_columns = ('pk', 'name', 'device', 'label', 'status', 'installed_device', 'description')
|
2020-10-16 10:39:13 -04:00
|
|
|
|
|
|
|
|
2020-10-16 15:51:46 -04:00
|
|
|
class DeviceDeviceBayTable(DeviceBayTable):
|
|
|
|
name = tables.TemplateColumn(
|
2020-11-06 15:06:45 -05:00
|
|
|
template_code='<i class="mdi mdi-circle{% if record.installed_device %}slice-8{% else %}outline{% endif %}'
|
2020-11-13 13:14:10 -05:00
|
|
|
'"></i> <a href="{{ record.get_absolute_url }}">{{ value }}</a>',
|
2021-04-20 20:21:52 -04:00
|
|
|
order_by=Accessor('_name'),
|
2020-11-13 13:14:10 -05:00
|
|
|
attrs={'td': {'class': 'text-nowrap'}}
|
2020-10-16 15:51:46 -04:00
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
actions = columns.ActionsColumn(
|
2022-01-10 11:17:40 -05:00
|
|
|
extra_buttons=DEVICEBAY_BUTTONS
|
2020-10-16 15:51:46 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.DeviceBay
|
2020-10-16 15:51:46 -04:00
|
|
|
fields = (
|
2021-11-02 16:21:34 -04:00
|
|
|
'pk', 'id', 'name', 'label', 'status', 'installed_device', 'description', 'tags', 'actions',
|
2020-10-16 15:51:46 -04:00
|
|
|
)
|
2022-01-07 10:36:58 -05:00
|
|
|
default_columns = ('pk', 'name', 'label', 'status', 'installed_device', 'description')
|
2020-10-16 15:51:46 -04:00
|
|
|
|
|
|
|
|
2021-12-17 09:35:57 -05:00
|
|
|
class ModuleBayTable(DeviceComponentTable):
|
|
|
|
device = tables.Column(
|
|
|
|
linkify={
|
|
|
|
'viewname': 'dcim:device_modulebays',
|
|
|
|
'args': [Accessor('device_id')],
|
|
|
|
}
|
|
|
|
)
|
2021-12-17 16:12:03 -05:00
|
|
|
installed_module = tables.Column(
|
|
|
|
linkify=True,
|
|
|
|
verbose_name='Installed module'
|
|
|
|
)
|
2022-04-12 09:00:19 -04:00
|
|
|
module_serial = tables.Column(
|
|
|
|
accessor=tables.A('installed_module__serial')
|
|
|
|
)
|
|
|
|
module_asset_tag = tables.Column(
|
|
|
|
accessor=tables.A('installed_module__asset_tag')
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
tags = columns.TagColumn(
|
2021-12-17 09:35:57 -05:00
|
|
|
url_name='dcim:modulebay_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.ModuleBay
|
2022-04-12 09:00:19 -04:00
|
|
|
fields = (
|
|
|
|
'pk', 'id', 'name', 'device', 'label', 'position', 'installed_module', 'module_serial', 'module_asset_tag',
|
|
|
|
'description', 'tags',
|
|
|
|
)
|
2021-12-17 16:12:03 -05:00
|
|
|
default_columns = ('pk', 'name', 'device', 'label', 'installed_module', 'description')
|
2021-12-17 09:35:57 -05:00
|
|
|
|
|
|
|
|
|
|
|
class DeviceModuleBayTable(ModuleBayTable):
|
2022-01-27 15:00:10 -05:00
|
|
|
actions = columns.ActionsColumn(
|
2022-01-10 11:17:40 -05:00
|
|
|
extra_buttons=MODULEBAY_BUTTONS
|
2021-12-17 09:35:57 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.ModuleBay
|
2022-04-12 09:00:19 -04:00
|
|
|
fields = (
|
|
|
|
'pk', 'id', 'name', 'label', 'position', 'installed_module', 'module_serial', 'module_asset_tag',
|
|
|
|
'description', 'tags', 'actions',
|
|
|
|
)
|
2022-02-23 13:02:14 -05:00
|
|
|
default_columns = ('pk', 'name', 'label', 'installed_module', 'description')
|
2021-12-17 09:35:57 -05:00
|
|
|
|
|
|
|
|
2020-10-16 10:39:13 -04:00
|
|
|
class InventoryItemTable(DeviceComponentTable):
|
2021-03-29 12:06:39 -04:00
|
|
|
device = tables.Column(
|
|
|
|
linkify={
|
|
|
|
'viewname': 'dcim:device_inventory',
|
|
|
|
'args': [Accessor('device_id')],
|
|
|
|
}
|
|
|
|
)
|
2022-02-11 12:08:16 -05:00
|
|
|
role = columns.ColoredLabelColumn()
|
2020-10-16 10:39:13 -04:00
|
|
|
manufacturer = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2021-12-27 13:26:17 -05:00
|
|
|
component = tables.Column(
|
2021-12-28 14:06:20 -05:00
|
|
|
orderable=False,
|
2021-12-27 13:26:17 -05:00
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
discovered = columns.BooleanColumn()
|
|
|
|
tags = columns.TagColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
url_name='dcim:inventoryitem_list'
|
|
|
|
)
|
|
|
|
cable = None # Override DeviceComponentTable
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.InventoryItem
|
2020-10-16 10:39:13 -04:00
|
|
|
fields = (
|
2021-12-28 14:06:20 -05:00
|
|
|
'pk', 'id', 'name', 'device', 'component', 'label', 'role', 'manufacturer', 'part_id', 'serial',
|
2022-01-17 11:12:54 -05:00
|
|
|
'asset_tag', 'description', 'discovered', 'tags', 'created', 'last_updated',
|
2021-12-27 13:26:17 -05:00
|
|
|
)
|
|
|
|
default_columns = (
|
|
|
|
'pk', 'name', 'device', 'label', 'role', 'manufacturer', 'part_id', 'serial', 'asset_tag',
|
2021-12-27 10:45:33 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class DeviceInventoryItemTable(InventoryItemTable):
|
|
|
|
name = tables.TemplateColumn(
|
|
|
|
template_code='<a href="{{ record.get_absolute_url }}" style="padding-left: {{ record.level }}0px">'
|
|
|
|
'{{ value }}</a>',
|
|
|
|
order_by=Accessor('_name'),
|
|
|
|
attrs={'td': {'class': 'text-nowrap'}}
|
|
|
|
)
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.InventoryItem
|
2021-12-27 10:45:33 -05:00
|
|
|
fields = (
|
2021-12-27 13:26:17 -05:00
|
|
|
'pk', 'id', 'name', 'label', 'role', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'component',
|
|
|
|
'description', 'discovered', 'tags', 'actions',
|
2021-12-27 10:45:33 -05:00
|
|
|
)
|
|
|
|
default_columns = (
|
2022-01-07 10:36:58 -05:00
|
|
|
'pk', 'name', 'label', 'role', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'component',
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class InventoryItemRoleTable(NetBoxTable):
|
2021-12-27 10:18:39 -05:00
|
|
|
name = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
inventoryitem_count = columns.LinkedCountColumn(
|
2021-12-27 10:18:39 -05:00
|
|
|
viewname='dcim:inventoryitem_list',
|
|
|
|
url_params={'role_id': 'pk'},
|
|
|
|
verbose_name='Items'
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
color = columns.ColorColumn()
|
|
|
|
tags = columns.TagColumn(
|
2021-12-27 10:18:39 -05:00
|
|
|
url_name='dcim:inventoryitemrole_list'
|
|
|
|
)
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.InventoryItemRole
|
2021-12-27 10:18:39 -05:00
|
|
|
fields = (
|
|
|
|
'pk', 'id', 'name', 'inventoryitem_count', 'color', 'description', 'slug', 'tags', 'actions',
|
|
|
|
)
|
2022-01-07 10:36:58 -05:00
|
|
|
default_columns = ('pk', 'name', 'inventoryitem_count', 'color', 'description')
|
2021-12-27 10:18:39 -05:00
|
|
|
|
|
|
|
|
2020-10-16 10:39:13 -04:00
|
|
|
#
|
|
|
|
# Virtual chassis
|
|
|
|
#
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class VirtualChassisTable(NetBoxTable):
|
2020-10-16 10:39:13 -04:00
|
|
|
name = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
master = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
member_count = columns.LinkedCountColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
viewname='dcim:device_list',
|
|
|
|
url_params={'virtual_chassis_id': 'pk'},
|
|
|
|
verbose_name='Members'
|
|
|
|
)
|
2022-11-04 08:28:09 -04:00
|
|
|
comments = columns.MarkdownColumn()
|
2022-01-27 15:00:10 -05:00
|
|
|
tags = columns.TagColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
url_name='dcim:virtualchassis_list'
|
|
|
|
)
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2022-11-04 08:28:09 -04:00
|
|
|
model = models.VirtualChassis
|
|
|
|
fields = (
|
|
|
|
'pk', 'id', 'name', 'domain', 'master', 'member_count', 'description', 'comments', 'tags', 'created',
|
|
|
|
'last_updated',
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
default_columns = ('pk', 'name', 'domain', 'master', 'member_count')
|
2022-11-11 06:55:49 -06:00
|
|
|
|
|
|
|
|
|
|
|
class VirtualDeviceContextTable(TenancyColumnsMixin, NetBoxTable):
|
|
|
|
name = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
device = tables.TemplateColumn(
|
|
|
|
order_by=('_name',),
|
2022-11-18 16:33:06 -05:00
|
|
|
template_code=DEVICE_LINK,
|
|
|
|
linkify=True
|
2022-11-11 06:55:49 -06:00
|
|
|
)
|
|
|
|
status = columns.ChoiceFieldColumn()
|
|
|
|
primary_ip = tables.Column(
|
|
|
|
linkify=True,
|
|
|
|
order_by=('primary_ip4', 'primary_ip6'),
|
|
|
|
verbose_name='IP Address'
|
|
|
|
)
|
|
|
|
primary_ip4 = tables.Column(
|
|
|
|
linkify=True,
|
|
|
|
verbose_name='IPv4 Address'
|
|
|
|
)
|
|
|
|
primary_ip6 = tables.Column(
|
|
|
|
linkify=True,
|
|
|
|
verbose_name='IPv6 Address'
|
|
|
|
)
|
|
|
|
|
|
|
|
comments = columns.MarkdownColumn()
|
|
|
|
|
|
|
|
tags = columns.TagColumn(
|
|
|
|
url_name='dcim:vdc_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(NetBoxTable.Meta):
|
|
|
|
model = models.VirtualDeviceContext
|
|
|
|
fields = (
|
|
|
|
'pk', 'id', 'name', 'status', 'identifier', 'tenant', 'tenant_group',
|
|
|
|
'primary_ip', 'primary_ip4', 'primary_ip6', 'comments', 'tags', 'created', 'last_updated',
|
|
|
|
)
|
|
|
|
default_columns = (
|
|
|
|
'pk', 'name', 'identifier', 'status', 'tenant', 'primary_ip',
|
|
|
|
)
|