diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py
index c614c534b..334947263 100644
--- a/netbox/dcim/tables/devices.py
+++ b/netbox/dcim/tables/devices.py
@@ -10,7 +10,7 @@ from utilities.tables import (
BaseTable, BooleanColumn, ButtonsColumn, ChoiceFieldColumn, ColorColumn, ColoredLabelColumn, LinkedCountColumn,
TagColumn, ToggleColumn,
)
-from .template_code import DEVICE_LINK, INTERFACE_IPADDRESSES, INTERFACE_TAGGED_VLANS
+from .template_code import CABLETERMINATION, DEVICE_LINK, INTERFACE_IPADDRESSES, INTERFACE_TAGGED_VLANS
__all__ = (
'ConsolePortTable',
@@ -204,29 +204,40 @@ class DeviceComponentTable(BaseTable):
order_by = ('device', 'name')
-class ConsolePortTable(DeviceComponentTable):
+class CableTerminationTable(BaseTable):
+ cable = tables.Column(
+ linkify=True
+ )
+ cable_peer = tables.TemplateColumn(
+ accessor='get_cable_peer',
+ template_code=CABLETERMINATION,
+ orderable=False
+ )
+
+
+class ConsolePortTable(DeviceComponentTable, CableTerminationTable):
tags = TagColumn(
url_name='dcim:consoleport_list'
)
class Meta(DeviceComponentTable.Meta):
model = ConsolePort
- fields = ('pk', 'device', 'name', 'label', 'type', 'description', 'cable', 'tags')
+ fields = ('pk', 'device', 'name', 'label', 'type', 'description', 'cable', 'cable_peer', 'tags')
default_columns = ('pk', 'device', 'name', 'label', 'type', 'description')
-class ConsoleServerPortTable(DeviceComponentTable):
+class ConsoleServerPortTable(DeviceComponentTable, CableTerminationTable):
tags = TagColumn(
url_name='dcim:consoleserverport_list'
)
class Meta(DeviceComponentTable.Meta):
model = ConsoleServerPort
- fields = ('pk', 'device', 'name', 'label', 'type', 'description', 'cable', 'tags')
+ fields = ('pk', 'device', 'name', 'label', 'type', 'description', 'cable', 'cable_peer', 'tags')
default_columns = ('pk', 'device', 'name', 'label', 'type', 'description')
-class PowerPortTable(DeviceComponentTable):
+class PowerPortTable(DeviceComponentTable, CableTerminationTable):
tags = TagColumn(
url_name='dcim:powerport_list'
)
@@ -234,19 +245,23 @@ class PowerPortTable(DeviceComponentTable):
class Meta(DeviceComponentTable.Meta):
model = PowerPort
fields = (
- 'pk', 'device', 'name', 'label', 'type', 'description', 'maximum_draw', 'allocated_draw', 'cable', 'tags',
+ 'pk', 'device', 'name', 'label', 'type', 'description', 'maximum_draw', 'allocated_draw', 'cable',
+ 'cable_peer', 'tags',
)
default_columns = ('pk', 'device', 'name', 'label', 'type', 'maximum_draw', 'allocated_draw', 'description')
-class PowerOutletTable(DeviceComponentTable):
+class PowerOutletTable(DeviceComponentTable, CableTerminationTable):
tags = TagColumn(
url_name='dcim:poweroutlet_list'
)
class Meta(DeviceComponentTable.Meta):
model = PowerOutlet
- fields = ('pk', 'device', 'name', 'label', 'type', 'description', 'power_port', 'feed_leg', 'cable', 'tags')
+ fields = (
+ 'pk', 'device', 'name', 'label', 'type', 'description', 'power_port', 'feed_leg', 'cable', 'cable_peer',
+ 'tags',
+ )
default_columns = ('pk', 'device', 'name', 'label', 'type', 'power_port', 'feed_leg', 'description')
@@ -265,7 +280,7 @@ class BaseInterfaceTable(BaseTable):
)
-class InterfaceTable(DeviceComponentTable, BaseInterfaceTable):
+class InterfaceTable(DeviceComponentTable, BaseInterfaceTable, CableTerminationTable):
tags = TagColumn(
url_name='dcim:interface_list'
)
@@ -274,12 +289,12 @@ class InterfaceTable(DeviceComponentTable, BaseInterfaceTable):
model = Interface
fields = (
'pk', 'device', 'name', 'label', 'enabled', 'type', 'mgmt_only', 'mtu', 'mode', 'mac_address',
- 'description', 'cable', 'tags', 'ip_addresses', 'untagged_vlan', 'tagged_vlans',
+ 'description', 'cable', 'cable_peer', 'tags', 'ip_addresses', 'untagged_vlan', 'tagged_vlans',
)
default_columns = ('pk', 'device', 'name', 'label', 'enabled', 'type', 'description')
-class FrontPortTable(DeviceComponentTable):
+class FrontPortTable(DeviceComponentTable, CableTerminationTable):
rear_port_position = tables.Column(
verbose_name='Position'
)
@@ -290,19 +305,20 @@ class FrontPortTable(DeviceComponentTable):
class Meta(DeviceComponentTable.Meta):
model = FrontPort
fields = (
- 'pk', 'device', 'name', 'label', 'type', 'rear_port', 'rear_port_position', 'description', 'cable', 'tags',
+ 'pk', 'device', 'name', 'label', 'type', 'rear_port', 'rear_port_position', 'description', 'cable',
+ 'cable_peer', 'tags',
)
default_columns = ('pk', 'device', 'name', 'label', 'type', 'rear_port', 'rear_port_position', 'description')
-class RearPortTable(DeviceComponentTable):
+class RearPortTable(DeviceComponentTable, CableTerminationTable):
tags = TagColumn(
url_name='dcim:rearport_list'
)
class Meta(DeviceComponentTable.Meta):
model = RearPort
- fields = ('pk', 'device', 'name', 'label', 'type', 'positions', 'description', 'cable', 'tags')
+ fields = ('pk', 'device', 'name', 'label', 'type', 'positions', 'description', 'cable', 'cable_peer', 'tags')
default_columns = ('pk', 'device', 'name', 'label', 'type', 'description')
diff --git a/netbox/dcim/tables/power.py b/netbox/dcim/tables/power.py
index 8d90fb620..471b1bb3a 100644
--- a/netbox/dcim/tables/power.py
+++ b/netbox/dcim/tables/power.py
@@ -3,6 +3,7 @@ from django_tables2.utils import Accessor
from dcim.models import PowerFeed, PowerPanel
from utilities.tables import BaseTable, ChoiceFieldColumn, LinkedCountColumn, TagColumn, ToggleColumn
+from .devices import CableTerminationTable
from .template_code import POWERFEED_CABLE, POWERFEED_CABLETERMINATION
__all__ = (
@@ -41,7 +42,7 @@ class PowerPanelTable(BaseTable):
# Power feeds
#
-class PowerFeedTable(BaseTable):
+class PowerFeedTable(CableTerminationTable):
pk = ToggleColumn()
name = tables.LinkColumn()
power_panel = tables.Column(
@@ -55,15 +56,6 @@ class PowerFeedTable(BaseTable):
max_utilization = tables.TemplateColumn(
template_code="{{ value }}%"
)
- cable = tables.TemplateColumn(
- template_code=POWERFEED_CABLE,
- orderable=False
- )
- connection = tables.TemplateColumn(
- accessor='get_cable_peer',
- template_code=POWERFEED_CABLETERMINATION,
- orderable=False
- )
available_power = tables.Column(
verbose_name='Available power (VA)'
)
@@ -75,9 +67,9 @@ class PowerFeedTable(BaseTable):
model = PowerFeed
fields = (
'pk', 'name', 'power_panel', 'rack', 'status', 'type', 'supply', 'voltage', 'amperage', 'phase',
- 'max_utilization', 'cable', 'connection', 'available_power', 'tags',
+ 'max_utilization', 'cable', 'cable_peer', 'connection', 'available_power', 'tags',
)
default_columns = (
'pk', 'name', 'power_panel', 'rack', 'status', 'type', 'supply', 'voltage', 'amperage', 'phase', 'cable',
- 'connection',
+ 'cable_peer',
)
diff --git a/netbox/dcim/tables/template_code.py b/netbox/dcim/tables/template_code.py
index b3840b48b..7278de113 100644
--- a/netbox/dcim/tables/template_code.py
+++ b/netbox/dcim/tables/template_code.py
@@ -1,3 +1,13 @@
+CABLETERMINATION = """
+{% if value %}
+ {{ value.parent }}
+
+ {{ value }}
+{% else %}
+ —
+{% endif %}
+"""
+
CABLE_LENGTH = """
{% if record.length %}{{ record.length }} {{ record.get_length_unit_display }}{% else %}—{% endif %}
"""