From cd128e557c695e447317f0a5f15e509794a89d1a Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Fri, 19 Nov 2021 10:27:56 -0500 Subject: [PATCH] Closes #7884: Add FHRP groups column to interface tables --- docs/release-notes/version-3.1.md | 1 + netbox/dcim/tables/devices.py | 14 ++++++++++---- netbox/dcim/tables/template_code.py | 8 ++++++++ netbox/virtualization/tables.py | 4 ++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/docs/release-notes/version-3.1.md b/docs/release-notes/version-3.1.md index a4deaa488..dba962b9f 100644 --- a/docs/release-notes/version-3.1.md +++ b/docs/release-notes/version-3.1.md @@ -14,6 +14,7 @@ * [#7775](https://github.com/netbox-community/netbox/issues/7775) - Enable dynamic config for `CHANGELOG_RETENTION`, `CUSTOM_VALIDATORS`, and `GRAPHQL_ENABLED` * [#7812](https://github.com/netbox-community/netbox/issues/7812) - Enable change logging for image attachments * [#7858](https://github.com/netbox-community/netbox/issues/7858) - Standardize the representation of content types across import & export functions +* [#7884](https://github.com/netbox-community/netbox/issues/7884) - Add FHRP groups column to interface tables ### Bug Fixes diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py index 20fa2bc19..f0e9c9bb0 100644 --- a/netbox/dcim/tables/devices.py +++ b/netbox/dcim/tables/devices.py @@ -475,6 +475,12 @@ class BaseInterfaceTable(BaseTable): orderable=False, verbose_name='IP Addresses' ) + fhrp_groups = tables.TemplateColumn( + accessor=Accessor('fhrp_group_assignments'), + template_code=INTERFACE_FHRPGROUPS, + orderable=False, + verbose_name='FHRP Groups' + ) untagged_vlan = tables.Column(linkify=True) tagged_vlans = TemplateColumn( template_code=INTERFACE_TAGGED_VLANS, @@ -509,7 +515,7 @@ class InterfaceTable(DeviceComponentTable, BaseInterfaceTable, PathEndpointTable 'pk', 'id', 'name', 'device', 'label', 'enabled', 'type', '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', 'wireless_lans', 'link_peer', 'connection', - 'tags', 'ip_addresses', 'untagged_vlan', 'tagged_vlans', + 'tags', 'ip_addresses', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', ) default_columns = ('pk', 'name', 'device', 'label', 'enabled', 'type', 'description') @@ -542,9 +548,9 @@ class DeviceInterfaceTable(InterfaceTable): model = Interface fields = ( 'pk', 'id', 'name', 'label', 'enabled', 'type', 'parent', 'bridge', 'lag', 'mgmt_only', 'mtu', 'mode', - 'mac_address', 'wwn', 'rf_role', 'rf_channel', 'rf_channel_width', 'tx_power', 'description', - 'mark_connected', 'cable', 'cable_color', 'wireless_link', 'wireless_lans', 'link_peer', 'connection', - 'tags', 'ip_addresses', 'untagged_vlan', 'tagged_vlans', 'actions', + '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', ) order_by = ('name',) default_columns = ( diff --git a/netbox/dcim/tables/template_code.py b/netbox/dcim/tables/template_code.py index c6304e4df..12b0fe4a2 100644 --- a/netbox/dcim/tables/template_code.py +++ b/netbox/dcim/tables/template_code.py @@ -50,6 +50,14 @@ INTERFACE_IPADDRESSES = """ """ +INTERFACE_FHRPGROUPS = """ +
+ {% for assignment in value.all %} + {{ assignment.group.group_id }} ({{ assignment.group.get_protocol_display }}) + {% endfor %} +
+""" + INTERFACE_TAGGED_VLANS = """ {% if record.mode == 'tagged' %} {% for vlan in record.tagged_vlans.all %} diff --git a/netbox/virtualization/tables.py b/netbox/virtualization/tables.py index 28a57c7ef..501b5c0c7 100644 --- a/netbox/virtualization/tables.py +++ b/netbox/virtualization/tables.py @@ -171,7 +171,7 @@ class VMInterfaceTable(BaseInterfaceTable): model = VMInterface fields = ( 'pk', 'id', 'name', 'virtual_machine', 'enabled', 'mac_address', 'mtu', 'mode', 'description', 'tags', - 'ip_addresses', 'untagged_vlan', 'tagged_vlans', + 'ip_addresses', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', ) default_columns = ('pk', 'name', 'virtual_machine', 'enabled', 'description') @@ -193,7 +193,7 @@ class VirtualMachineVMInterfaceTable(VMInterfaceTable): model = VMInterface fields = ( 'pk', 'id', 'name', 'enabled', 'parent', 'bridge', 'mac_address', 'mtu', 'mode', 'description', 'tags', - 'ip_addresses', 'untagged_vlan', 'tagged_vlans', 'actions', + 'ip_addresses', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', 'actions', ) default_columns = ( 'pk', 'name', 'enabled', 'mac_address', 'mtu', 'mode', 'description', 'ip_addresses', 'actions',