mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Added cable column to console/power/interface connection tables
This commit is contained in:
@ -672,7 +672,7 @@ class CableTable(BaseTable):
|
|||||||
|
|
||||||
class ConsoleConnectionTable(BaseTable):
|
class ConsoleConnectionTable(BaseTable):
|
||||||
console_server = tables.LinkColumn(
|
console_server = tables.LinkColumn(
|
||||||
'dcim:device',
|
viewname='dcim:device',
|
||||||
accessor=Accessor('connected_endpoint.device'),
|
accessor=Accessor('connected_endpoint.device'),
|
||||||
args=[Accessor('connected_endpoint.device.pk')],
|
args=[Accessor('connected_endpoint.device.pk')],
|
||||||
verbose_name='Console server'
|
verbose_name='Console server'
|
||||||
@ -680,15 +680,19 @@ class ConsoleConnectionTable(BaseTable):
|
|||||||
connected_endpoint = tables.Column(verbose_name='Port')
|
connected_endpoint = tables.Column(verbose_name='Port')
|
||||||
device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device')
|
device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device')
|
||||||
name = tables.Column(verbose_name='Console port')
|
name = tables.Column(verbose_name='Console port')
|
||||||
|
cable = tables.LinkColumn(
|
||||||
|
viewname='dcim:cable',
|
||||||
|
args=[Accessor('cable.pk')]
|
||||||
|
)
|
||||||
|
|
||||||
class Meta(BaseTable.Meta):
|
class Meta(BaseTable.Meta):
|
||||||
model = ConsolePort
|
model = ConsolePort
|
||||||
fields = ('console_server', 'connected_endpoint', 'device', 'name')
|
fields = ('console_server', 'connected_endpoint', 'device', 'name', 'cable')
|
||||||
|
|
||||||
|
|
||||||
class PowerConnectionTable(BaseTable):
|
class PowerConnectionTable(BaseTable):
|
||||||
pdu = tables.LinkColumn(
|
pdu = tables.LinkColumn(
|
||||||
'dcim:device',
|
viewname='dcim:device',
|
||||||
accessor=Accessor('connected_endpoint.device'),
|
accessor=Accessor('connected_endpoint.device'),
|
||||||
args=[Accessor('connected_endpoint.device.pk')],
|
args=[Accessor('connected_endpoint.device.pk')],
|
||||||
verbose_name='PDU'
|
verbose_name='PDU'
|
||||||
@ -696,10 +700,14 @@ class PowerConnectionTable(BaseTable):
|
|||||||
connected_endpoint = tables.Column(verbose_name='Outlet')
|
connected_endpoint = tables.Column(verbose_name='Outlet')
|
||||||
device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device')
|
device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device')
|
||||||
name = tables.Column(verbose_name='Power Port')
|
name = tables.Column(verbose_name='Power Port')
|
||||||
|
cable = tables.LinkColumn(
|
||||||
|
viewname='dcim:cable',
|
||||||
|
args=[Accessor('cable.pk')]
|
||||||
|
)
|
||||||
|
|
||||||
class Meta(BaseTable.Meta):
|
class Meta(BaseTable.Meta):
|
||||||
model = PowerPort
|
model = PowerPort
|
||||||
fields = ('pdu', 'connected_endpoint', 'device', 'name')
|
fields = ('pdu', 'connected_endpoint', 'device', 'name', 'cable')
|
||||||
|
|
||||||
|
|
||||||
class InterfaceConnectionTable(BaseTable):
|
class InterfaceConnectionTable(BaseTable):
|
||||||
@ -727,10 +735,14 @@ class InterfaceConnectionTable(BaseTable):
|
|||||||
args=[Accessor('connected_endpoint.pk')],
|
args=[Accessor('connected_endpoint.pk')],
|
||||||
verbose_name='Interface B'
|
verbose_name='Interface B'
|
||||||
)
|
)
|
||||||
|
cable = tables.LinkColumn(
|
||||||
|
viewname='dcim:cable',
|
||||||
|
args=[Accessor('cable.pk')]
|
||||||
|
)
|
||||||
|
|
||||||
class Meta(BaseTable.Meta):
|
class Meta(BaseTable.Meta):
|
||||||
model = Interface
|
model = Interface
|
||||||
fields = ('device_a', 'interface_a', 'device_b', 'interface_b')
|
fields = ('device_a', 'interface_a', 'device_b', 'interface_b', 'cable')
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -1692,7 +1692,7 @@ class ConsoleConnectionsListView(ObjectListView):
|
|||||||
).filter(
|
).filter(
|
||||||
connected_endpoint__isnull=False
|
connected_endpoint__isnull=False
|
||||||
).order_by(
|
).order_by(
|
||||||
'connected_endpoint__device__name', 'connected_endpoint__name'
|
'cable', 'connected_endpoint__device__name', 'connected_endpoint__name'
|
||||||
)
|
)
|
||||||
filter = filters.ConsoleConnectionFilter
|
filter = filters.ConsoleConnectionFilter
|
||||||
filter_form = forms.ConsoleConnectionFilterForm
|
filter_form = forms.ConsoleConnectionFilterForm
|
||||||
@ -1706,7 +1706,7 @@ class PowerConnectionsListView(ObjectListView):
|
|||||||
).filter(
|
).filter(
|
||||||
connected_endpoint__isnull=False
|
connected_endpoint__isnull=False
|
||||||
).order_by(
|
).order_by(
|
||||||
'connected_endpoint__device__name', 'connected_endpoint__name'
|
'cable', 'connected_endpoint__device__name', 'connected_endpoint__name'
|
||||||
)
|
)
|
||||||
filter = filters.PowerConnectionFilter
|
filter = filters.PowerConnectionFilter
|
||||||
filter_form = forms.PowerConnectionFilterForm
|
filter_form = forms.PowerConnectionFilterForm
|
||||||
@ -1716,7 +1716,7 @@ class PowerConnectionsListView(ObjectListView):
|
|||||||
|
|
||||||
class InterfaceConnectionsListView(ObjectListView):
|
class InterfaceConnectionsListView(ObjectListView):
|
||||||
queryset = Interface.objects.select_related(
|
queryset = Interface.objects.select_related(
|
||||||
'device', '_connected_interface__device'
|
'device', 'cable', '_connected_interface__device'
|
||||||
).filter(
|
).filter(
|
||||||
# Avoid duplicate connections by only selecting the lower PK in a connected pair
|
# Avoid duplicate connections by only selecting the lower PK in a connected pair
|
||||||
_connected_interface__isnull=False,
|
_connected_interface__isnull=False,
|
||||||
|
Reference in New Issue
Block a user