2020-10-16 10:39:13 -04:00
|
|
|
import django_tables2 as tables
|
|
|
|
from django_tables2.utils import Accessor
|
|
|
|
|
|
|
|
from dcim.models import (
|
|
|
|
ConsolePort, ConsoleServerPort, Device, DeviceBay, DeviceRole, FrontPort, Interface, InventoryItem, Platform,
|
|
|
|
PowerOutlet, PowerPort, RearPort, VirtualChassis,
|
|
|
|
)
|
2021-03-04 16:07:55 -05:00
|
|
|
from tenancy.tables import TenantColumn
|
2020-10-16 10:39:13 -04:00
|
|
|
from utilities.tables import (
|
|
|
|
BaseTable, BooleanColumn, ButtonsColumn, ChoiceFieldColumn, ColorColumn, ColoredLabelColumn, LinkedCountColumn,
|
2021-09-29 21:00:45 -04:00
|
|
|
MarkdownColumn, TagColumn, TemplateColumn, ToggleColumn,
|
2020-10-16 10:39:13 -04: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',
|
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',
|
|
|
|
'InventoryItemTable',
|
|
|
|
'PlatformTable',
|
|
|
|
'PowerOutletTable',
|
|
|
|
'PowerPortTable',
|
|
|
|
'RearPortTable',
|
|
|
|
'VirtualChassisTable',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-03-29 10:53:02 -04:00
|
|
|
def get_cabletermination_row_class(record):
|
|
|
|
if record.mark_connected:
|
|
|
|
return 'success'
|
|
|
|
elif record.cable:
|
|
|
|
return record.cable.get_status_class()
|
|
|
|
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"
|
|
|
|
|
2020-10-16 10:39:13 -04:00
|
|
|
#
|
|
|
|
# Device roles
|
|
|
|
#
|
|
|
|
|
2021-05-26 16:32:09 -07:00
|
|
|
|
2020-10-16 10:39:13 -04:00
|
|
|
class DeviceRoleTable(BaseTable):
|
|
|
|
pk = ToggleColumn()
|
2021-03-26 14:44:43 -04:00
|
|
|
name = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
device_count = LinkedCountColumn(
|
|
|
|
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'
|
|
|
|
)
|
|
|
|
vm_count = LinkedCountColumn(
|
|
|
|
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'
|
|
|
|
)
|
|
|
|
color = ColorColumn()
|
|
|
|
vm_role = BooleanColumn()
|
2021-10-21 10:51:02 -04:00
|
|
|
tags = TagColumn(
|
|
|
|
url_name='dcim:devicerole_list'
|
|
|
|
)
|
2021-02-26 17:23:23 -05:00
|
|
|
actions = ButtonsColumn(DeviceRole)
|
2020-10-16 10:39:13 -04:00
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = 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-13 09:22:32 +00:00
|
|
|
'actions', 'created', 'last_updated',
|
2021-10-21 10:51:02 -04:00
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
default_columns = ('pk', 'name', 'device_count', 'vm_count', 'color', 'vm_role', 'description', 'actions')
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Platforms
|
|
|
|
#
|
|
|
|
|
|
|
|
class PlatformTable(BaseTable):
|
|
|
|
pk = ToggleColumn()
|
2021-03-26 14:44:43 -04:00
|
|
|
name = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
device_count = LinkedCountColumn(
|
|
|
|
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'
|
|
|
|
)
|
|
|
|
vm_count = LinkedCountColumn(
|
|
|
|
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'
|
|
|
|
)
|
2021-10-21 10:51:02 -04:00
|
|
|
tags = TagColumn(
|
|
|
|
url_name='dcim:platform_list'
|
|
|
|
)
|
2021-02-26 17:23:23 -05:00
|
|
|
actions = ButtonsColumn(Platform)
|
2020-10-16 10:39:13 -04:00
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = Platform
|
|
|
|
fields = (
|
2021-11-02 16:21:34 -04:00
|
|
|
'pk', 'id', 'name', 'manufacturer', 'device_count', 'vm_count', 'slug', 'napalm_driver', 'napalm_args',
|
2022-01-13 09:22:32 +00:00
|
|
|
'description', 'tags', 'actions', 'created', 'last_updated',
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|
|
|
|
default_columns = (
|
|
|
|
'pk', 'name', 'manufacturer', 'device_count', 'vm_count', 'napalm_driver', 'description', 'actions',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Devices
|
|
|
|
#
|
|
|
|
|
|
|
|
class DeviceTable(BaseTable):
|
|
|
|
pk = ToggleColumn()
|
|
|
|
name = tables.TemplateColumn(
|
|
|
|
order_by=('_name',),
|
|
|
|
template_code=DEVICE_LINK
|
|
|
|
)
|
|
|
|
status = ChoiceFieldColumn()
|
2021-03-04 16:07:55 -05:00
|
|
|
tenant = TenantColumn()
|
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
|
|
|
|
)
|
|
|
|
device_role = ColoredLabelColumn(
|
|
|
|
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'
|
|
|
|
)
|
2021-09-17 12:04:22 -04:00
|
|
|
comments = MarkdownColumn()
|
2020-10-16 10:39:13 -04:00
|
|
|
tags = TagColumn(
|
|
|
|
url_name='dcim:device_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = Device
|
|
|
|
fields = (
|
2021-11-02 16:21:34 -04:00
|
|
|
'pk', 'id', 'name', 'status', 'tenant', 'device_role', 'manufacturer', 'device_type', 'platform', 'serial',
|
2021-11-03 10:29:02 -04:00
|
|
|
'asset_tag', 'site', 'location', 'rack', 'position', 'face', 'primary_ip', 'airflow', 'primary_ip4',
|
2022-01-13 09:22:32 +00:00
|
|
|
'primary_ip6', 'cluster', 'virtual_chassis', 'vc_position', 'vc_priority', 'comments', '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
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class DeviceImportTable(BaseTable):
|
|
|
|
name = tables.TemplateColumn(
|
|
|
|
template_code=DEVICE_LINK
|
|
|
|
)
|
|
|
|
status = ChoiceFieldColumn()
|
2021-03-04 16:07:55 -05:00
|
|
|
tenant = TenantColumn()
|
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'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = Device
|
2021-11-02 16:21:34 -04:00
|
|
|
fields = ('id', 'name', 'status', 'tenant', 'site', 'rack', 'position', 'device_role', 'device_type')
|
2020-10-16 10:39:13 -04:00
|
|
|
empty_text = False
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Device components
|
|
|
|
#
|
|
|
|
|
|
|
|
class DeviceComponentTable(BaseTable):
|
|
|
|
pk = ToggleColumn()
|
|
|
|
device = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
name = tables.Column(
|
|
|
|
linkify=True,
|
|
|
|
order_by=('_name',)
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
order_by = ('device', 'name')
|
|
|
|
|
|
|
|
|
2020-10-16 11:11:41 -04:00
|
|
|
class CableTerminationTable(BaseTable):
|
|
|
|
cable = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2021-03-31 15:49:29 -04:00
|
|
|
cable_color = ColorColumn(
|
|
|
|
accessor='cable.color',
|
|
|
|
orderable=False,
|
|
|
|
verbose_name='Cable Color'
|
|
|
|
)
|
2021-10-13 14:04:53 -04:00
|
|
|
link_peer = TemplateColumn(
|
|
|
|
accessor='_link_peer',
|
|
|
|
template_code=LINKTERMINATION,
|
2020-10-30 13:57:17 -04:00
|
|
|
orderable=False,
|
2021-10-13 14:04:53 -04:00
|
|
|
verbose_name='Link Peer'
|
2020-10-16 11:11:41 -04:00
|
|
|
)
|
2021-03-01 21:34:42 -05:00
|
|
|
mark_connected = BooleanColumn()
|
2020-10-16 11:11:41 -04:00
|
|
|
|
|
|
|
|
2020-10-16 11:41:24 -04:00
|
|
|
class PathEndpointTable(CableTerminationTable):
|
2021-09-29 21:00:45 -04:00
|
|
|
connection = TemplateColumn(
|
2021-04-01 21:29:46 -04:00
|
|
|
accessor='_path.last_node',
|
2021-10-13 14:04:53 -04:00
|
|
|
template_code=LINKTERMINATION,
|
2020-10-16 11:41:24 -04:00
|
|
|
verbose_name='Connection',
|
|
|
|
orderable=False
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class ConsolePortTable(DeviceComponentTable, PathEndpointTable):
|
2021-03-29 12:06:39 -04:00
|
|
|
device = tables.Column(
|
|
|
|
linkify={
|
|
|
|
'viewname': 'dcim:device_consoleports',
|
|
|
|
'args': [Accessor('device_id')],
|
|
|
|
}
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
tags = TagColumn(
|
|
|
|
url_name='dcim:consoleport_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
|
model = ConsolePort
|
2020-10-16 11:41:24 -04:00
|
|
|
fields = (
|
2021-11-02 16:21:34 -04:00
|
|
|
'pk', 'id', 'name', 'device', 'label', 'type', 'speed', 'description', 'mark_connected', 'cable', 'cable_color',
|
2022-01-13 09:22:32 +00:00
|
|
|
'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
|
|
|
)
|
|
|
|
actions = ButtonsColumn(
|
|
|
|
model=ConsolePort,
|
|
|
|
buttons=('edit', 'delete'),
|
2020-11-13 15:00:12 -05:00
|
|
|
prepend_template=CONSOLEPORT_BUTTONS
|
2020-10-16 14:39:15 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
|
model = ConsolePort
|
|
|
|
fields = (
|
2021-11-02 16:21:34 -04:00
|
|
|
'pk', 'id', 'name', 'label', 'type', 'speed', 'description', 'mark_connected', 'cable', 'cable_color',
|
2021-10-13 14:04:53 -04:00
|
|
|
'link_peer', 'connection', 'tags', 'actions'
|
2020-10-16 14:39:15 -04:00
|
|
|
)
|
2021-03-03 10:20:08 -05:00
|
|
|
default_columns = ('pk', 'name', 'label', 'type', 'speed', 'description', 'cable', 'connection', 'actions')
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-16 11:41:24 -04:00
|
|
|
class ConsoleServerPortTable(DeviceComponentTable, PathEndpointTable):
|
2021-03-29 12:06:39 -04:00
|
|
|
device = tables.Column(
|
|
|
|
linkify={
|
|
|
|
'viewname': 'dcim:device_consoleserverports',
|
|
|
|
'args': [Accessor('device_id')],
|
|
|
|
}
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
tags = TagColumn(
|
|
|
|
url_name='dcim:consoleserverport_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
|
model = ConsoleServerPort
|
2021-03-01 21:34:42 -05:00
|
|
|
fields = (
|
2021-11-03 10:29:02 -04:00
|
|
|
'pk', 'id', 'name', 'device', 'label', 'type', 'speed', 'description', 'mark_connected', 'cable',
|
2022-01-13 09:22:32 +00:00
|
|
|
'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
|
|
|
)
|
|
|
|
actions = ButtonsColumn(
|
|
|
|
model=ConsoleServerPort,
|
|
|
|
buttons=('edit', 'delete'),
|
2020-11-13 15:00:12 -05:00
|
|
|
prepend_template=CONSOLESERVERPORT_BUTTONS
|
2020-10-16 15:01:16 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
|
model = ConsoleServerPort
|
|
|
|
fields = (
|
2021-11-02 16:21:34 -04:00
|
|
|
'pk', 'id', 'name', 'label', 'type', 'speed', 'description', 'mark_connected', 'cable', 'cable_color',
|
2021-10-13 14:04:53 -04:00
|
|
|
'link_peer', 'connection', 'tags', 'actions',
|
2020-10-16 15:01:16 -04:00
|
|
|
)
|
2021-03-03 10:20:08 -05:00
|
|
|
default_columns = ('pk', 'name', 'label', 'type', 'speed', 'description', 'cable', 'connection', 'actions')
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-16 11:41:24 -04:00
|
|
|
class PowerPortTable(DeviceComponentTable, PathEndpointTable):
|
2021-03-29 12:06:39 -04:00
|
|
|
device = tables.Column(
|
|
|
|
linkify={
|
|
|
|
'viewname': 'dcim:device_powerports',
|
|
|
|
'args': [Accessor('device_id')],
|
|
|
|
}
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
tags = TagColumn(
|
|
|
|
url_name='dcim:powerport_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
|
model = PowerPort
|
|
|
|
fields = (
|
2021-11-03 10:29:02 -04:00
|
|
|
'pk', 'id', 'name', 'device', 'label', 'type', 'description', 'mark_connected', 'maximum_draw',
|
2022-01-13 09:22:32 +00:00
|
|
|
'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
|
|
|
)
|
|
|
|
actions = ButtonsColumn(
|
|
|
|
model=PowerPort,
|
|
|
|
buttons=('edit', 'delete'),
|
2020-11-13 15:00:12 -05:00
|
|
|
prepend_template=POWERPORT_BUTTONS
|
2020-10-16 15:09:23 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
|
model = PowerPort
|
|
|
|
fields = (
|
2021-11-03 10:29:02 -04:00
|
|
|
'pk', 'id', 'name', '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
|
|
|
'actions',
|
|
|
|
)
|
|
|
|
row_attrs = {
|
2021-03-29 10:53:02 -04:00
|
|
|
'class': get_cabletermination_row_class
|
2020-10-16 15:09:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-16 11:41:24 -04:00
|
|
|
class PowerOutletTable(DeviceComponentTable, 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
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
tags = TagColumn(
|
|
|
|
url_name='dcim:poweroutlet_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
|
model = PowerOutlet
|
2020-10-16 11:11:41 -04:00
|
|
|
fields = (
|
2021-11-03 10:29:02 -04:00
|
|
|
'pk', 'id', 'name', 'device', 'label', 'type', 'description', 'power_port', 'feed_leg', 'mark_connected',
|
2022-01-13 09:22:32 +00:00
|
|
|
'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
|
|
|
)
|
|
|
|
actions = ButtonsColumn(
|
|
|
|
model=PowerOutlet,
|
|
|
|
buttons=('edit', 'delete'),
|
2020-11-13 15:00:12 -05:00
|
|
|
prepend_template=POWEROUTLET_BUTTONS
|
2020-10-16 15:16:36 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
|
model = PowerOutlet
|
|
|
|
fields = (
|
2021-11-02 16:21:34 -04:00
|
|
|
'pk', 'id', 'name', 'label', 'type', 'power_port', 'feed_leg', 'description', 'mark_connected', 'cable',
|
2021-10-13 14:04:53 -04:00
|
|
|
'cable_color', 'link_peer', 'connection', 'tags', 'actions',
|
2020-10-16 15:16:36 -04:00
|
|
|
)
|
|
|
|
default_columns = (
|
2020-10-19 13:44:51 -04:00
|
|
|
'pk', 'name', 'label', 'type', 'power_port', 'feed_leg', 'description', 'cable', 'connection', 'actions',
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-16 10:39:13 -04:00
|
|
|
class BaseInterfaceTable(BaseTable):
|
|
|
|
enabled = BooleanColumn()
|
|
|
|
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'
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
untagged_vlan = tables.Column(linkify=True)
|
2021-09-29 21:00:45 -04:00
|
|
|
tagged_vlans = TemplateColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
template_code=INTERFACE_TAGGED_VLANS,
|
|
|
|
orderable=False,
|
|
|
|
verbose_name='Tagged VLANs'
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-10-16 11:41:24 -04:00
|
|
|
class InterfaceTable(DeviceComponentTable, BaseInterfaceTable, PathEndpointTable):
|
2021-03-29 12:06:39 -04:00
|
|
|
device = tables.Column(
|
|
|
|
linkify={
|
|
|
|
'viewname': 'dcim:device_interfaces',
|
|
|
|
'args': [Accessor('device_id')],
|
|
|
|
}
|
|
|
|
)
|
2021-01-07 11:29:59 -05:00
|
|
|
mgmt_only = BooleanColumn()
|
2021-10-13 14:04:53 -04:00
|
|
|
wireless_link = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2021-10-18 10:05:43 -04:00
|
|
|
wireless_lans = TemplateColumn(
|
|
|
|
template_code=INTERFACE_WIRELESS_LANS,
|
|
|
|
orderable=False,
|
|
|
|
verbose_name='Wireless LANs'
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
tags = TagColumn(
|
|
|
|
url_name='dcim:interface_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
|
model = Interface
|
|
|
|
fields = (
|
2021-11-03 10:29:02 -04:00
|
|
|
'pk', 'id', 'name', 'device', 'label', 'enabled', 'type', 'mgmt_only', 'mtu', 'mode', 'mac_address', 'wwn',
|
2021-10-28 09:31:45 -04:00
|
|
|
'rf_role', 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'tx_power', 'description',
|
|
|
|
'mark_connected', 'cable', 'cable_color', 'wireless_link', 'wireless_lans', 'link_peer', 'connection',
|
2022-01-13 09:22:32 +00:00
|
|
|
'tags', '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'
|
|
|
|
)
|
2020-10-16 15:42:48 -04:00
|
|
|
actions = ButtonsColumn(
|
|
|
|
model=Interface,
|
|
|
|
buttons=('edit', 'delete'),
|
2020-11-13 15:00:12 -05:00
|
|
|
prepend_template=INTERFACE_BUTTONS
|
2020-10-16 15:42:48 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
|
model = Interface
|
|
|
|
fields = (
|
2021-11-03 10:29:02 -04:00
|
|
|
'pk', 'id', 'name', 'label', 'enabled', 'type', 'parent', 'bridge', 'lag', 'mgmt_only', 'mtu', 'mode',
|
2021-11-19 10:27:56 -05:00
|
|
|
'mac_address', 'wwn', 'rf_role', 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'tx_power',
|
|
|
|
'description', 'mark_connected', 'cable', 'cable_color', 'wireless_link', 'wireless_lans', 'link_peer',
|
|
|
|
'connection', 'tags', 'ip_addresses', 'fhrp_groups', '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',
|
|
|
|
'cable', 'connection', 'actions',
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-16 11:11:41 -04:00
|
|
|
class FrontPortTable(DeviceComponentTable, CableTerminationTable):
|
2021-03-29 12:06:39 -04:00
|
|
|
device = tables.Column(
|
|
|
|
linkify={
|
|
|
|
'viewname': 'dcim:device_frontports',
|
|
|
|
'args': [Accessor('device_id')],
|
|
|
|
}
|
|
|
|
)
|
2021-06-09 16:51:51 -04:00
|
|
|
color = 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
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
tags = TagColumn(
|
|
|
|
url_name='dcim:frontport_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
|
model = FrontPort
|
|
|
|
fields = (
|
2021-11-02 16:21:34 -04:00
|
|
|
'pk', 'id', 'name', 'device', 'label', 'type', 'color', 'rear_port', 'rear_port_position', 'description',
|
2022-01-13 09:22:32 +00:00
|
|
|
'mark_connected', 'cable', 'cable_color', 'link_peer', 'tags', '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
|
|
|
)
|
|
|
|
actions = ButtonsColumn(
|
|
|
|
model=FrontPort,
|
|
|
|
buttons=('edit', 'delete'),
|
2020-11-13 15:00:12 -05:00
|
|
|
prepend_template=FRONTPORT_BUTTONS
|
2020-10-16 15:28:28 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
|
model = FrontPort
|
|
|
|
fields = (
|
2021-11-02 16:21:34 -04:00
|
|
|
'pk', 'id', 'name', 'label', 'type', 'rear_port', 'rear_port_position', 'description', 'mark_connected', 'cable',
|
2021-10-13 14:04:53 -04:00
|
|
|
'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
|
|
|
'actions',
|
|
|
|
)
|
|
|
|
row_attrs = {
|
2021-03-29 10:53:02 -04:00
|
|
|
'class': get_cabletermination_row_class
|
2020-10-16 15:28:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-16 11:11:41 -04:00
|
|
|
class RearPortTable(DeviceComponentTable, CableTerminationTable):
|
2021-03-29 12:06:39 -04:00
|
|
|
device = tables.Column(
|
|
|
|
linkify={
|
|
|
|
'viewname': 'dcim:device_rearports',
|
|
|
|
'args': [Accessor('device_id')],
|
|
|
|
}
|
|
|
|
)
|
2021-06-09 16:51:51 -04:00
|
|
|
color = ColorColumn()
|
2020-10-16 10:39:13 -04:00
|
|
|
tags = TagColumn(
|
|
|
|
url_name='dcim:rearport_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
|
model = RearPort
|
2021-03-01 21:34:42 -05:00
|
|
|
fields = (
|
2021-11-02 16:21:34 -04:00
|
|
|
'pk', 'id', 'name', 'device', 'label', 'type', 'color', 'positions', 'description', 'mark_connected', 'cable',
|
2022-01-13 09:22:32 +00:00
|
|
|
'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
|
|
|
)
|
|
|
|
actions = ButtonsColumn(
|
|
|
|
model=RearPort,
|
|
|
|
buttons=('edit', 'delete'),
|
2020-11-13 15:00:12 -05:00
|
|
|
prepend_template=REARPORT_BUTTONS
|
2020-10-16 15:33:39 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
|
model = RearPort
|
|
|
|
fields = (
|
2021-11-02 16:21:34 -04:00
|
|
|
'pk', 'id', 'name', 'label', 'type', 'positions', 'description', 'mark_connected', 'cable', 'cable_color',
|
2021-10-13 14:04:53 -04:00
|
|
|
'link_peer', 'tags', 'actions',
|
2020-10-16 15:33:39 -04:00
|
|
|
)
|
|
|
|
default_columns = (
|
2021-10-13 14:04:53 -04:00
|
|
|
'pk', 'name', 'label', 'type', 'positions', 'description', 'cable', 'link_peer', 'actions',
|
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')],
|
|
|
|
}
|
|
|
|
)
|
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
|
|
|
|
)
|
|
|
|
tags = TagColumn(
|
|
|
|
url_name='dcim:devicebay_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
|
model = DeviceBay
|
2022-01-13 09:22:32 +00:00
|
|
|
fields = (
|
|
|
|
'pk', 'id', 'name', 'device', 'label', 'status', 'installed_device', 'description', 'tags',
|
|
|
|
'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
|
|
|
)
|
|
|
|
actions = ButtonsColumn(
|
|
|
|
model=DeviceBay,
|
|
|
|
buttons=('edit', 'delete'),
|
2020-11-13 15:00:12 -05:00
|
|
|
prepend_template=DEVICEBAY_BUTTONS
|
2020-10-16 15:51:46 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
|
model = DeviceBay
|
|
|
|
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
|
|
|
)
|
|
|
|
default_columns = (
|
2020-10-16 16:33:08 -04:00
|
|
|
'pk', 'name', 'label', 'status', 'installed_device', 'description', 'actions',
|
2020-10-16 15:51:46 -04: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')],
|
|
|
|
}
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
manufacturer = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
discovered = BooleanColumn()
|
|
|
|
tags = TagColumn(
|
|
|
|
url_name='dcim:inventoryitem_list'
|
|
|
|
)
|
|
|
|
cable = None # Override DeviceComponentTable
|
|
|
|
|
2021-06-10 14:27:42 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2020-10-16 10:39:13 -04:00
|
|
|
model = InventoryItem
|
|
|
|
fields = (
|
2021-11-02 16:21:34 -04:00
|
|
|
'pk', 'id', 'name', 'device', 'label', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'description',
|
2022-01-13 09:22:32 +00:00
|
|
|
'discovered', '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', 'manufacturer', 'part_id', 'serial', 'asset_tag')
|
2020-10-16 10:39:13 -04:00
|
|
|
|
|
|
|
|
2020-10-19 13:44:51 -04:00
|
|
|
class DeviceInventoryItemTable(InventoryItemTable):
|
2020-10-16 16:00:25 -04:00
|
|
|
name = tables.TemplateColumn(
|
|
|
|
template_code='<a href="{{ record.get_absolute_url }}" style="padding-left: {{ record.level }}0px">'
|
2020-11-13 13:14:10 -05:00
|
|
|
'{{ 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 16:00:25 -04:00
|
|
|
)
|
|
|
|
actions = ButtonsColumn(
|
|
|
|
model=InventoryItem,
|
2020-11-13 15:00:12 -05:00
|
|
|
buttons=('edit', 'delete')
|
2020-10-16 16:00:25 -04:00
|
|
|
)
|
|
|
|
|
2021-06-10 14:27:42 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2020-10-16 16:00:25 -04:00
|
|
|
model = InventoryItem
|
|
|
|
fields = (
|
2021-11-02 16:21:34 -04:00
|
|
|
'pk', 'id', 'name', 'label', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'description', 'discovered',
|
2020-10-16 16:33:08 -04:00
|
|
|
'tags', 'actions',
|
2020-10-16 16:00:25 -04:00
|
|
|
)
|
|
|
|
default_columns = (
|
2020-10-19 13:44:51 -04:00
|
|
|
'pk', 'name', 'label', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'description', 'discovered',
|
|
|
|
'actions',
|
2020-10-16 16:00:25 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-10-16 10:39:13 -04:00
|
|
|
#
|
|
|
|
# Virtual chassis
|
|
|
|
#
|
|
|
|
|
|
|
|
class VirtualChassisTable(BaseTable):
|
|
|
|
pk = ToggleColumn()
|
|
|
|
name = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
master = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
member_count = LinkedCountColumn(
|
|
|
|
viewname='dcim:device_list',
|
|
|
|
url_params={'virtual_chassis_id': 'pk'},
|
|
|
|
verbose_name='Members'
|
|
|
|
)
|
|
|
|
tags = TagColumn(
|
|
|
|
url_name='dcim:virtualchassis_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = VirtualChassis
|
2022-01-13 09:22:32 +00:00
|
|
|
fields = ('pk', 'id', 'name', 'domain', 'master', 'member_count', 'tags', 'created', 'last_updated',)
|
2020-10-16 10:39:13 -04:00
|
|
|
default_columns = ('pk', 'name', 'domain', 'master', 'member_count')
|